mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-19 03:50:11 +08:00
@@ -27,14 +27,14 @@ package main
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
x := Min(1, 3, 2, 0)
|
||||
x := min(1, 3, 2, 0)
|
||||
fmt.Printf("The minimum is: %d\n", x)
|
||||
arr := []int{7,9,3,5,1}
|
||||
x = Min(arr...)
|
||||
x = min(arr...)
|
||||
fmt.Printf("The minimum in the array arr is: %d", x)
|
||||
}
|
||||
|
||||
func Min(a ...int) int {
|
||||
func min(a ...int) int {
|
||||
if len(a)==0 {
|
||||
return 0
|
||||
}
|
||||
|
@@ -11,17 +11,17 @@ package main
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
Function1()
|
||||
function1()
|
||||
}
|
||||
|
||||
func Function1() {
|
||||
fmt.Printf("In Function1 at the top\n")
|
||||
defer Function2()
|
||||
fmt.Printf("In Function1 at the bottom!\n")
|
||||
func function1() {
|
||||
fmt.Printf("In function1 at the top\n")
|
||||
defer function2()
|
||||
fmt.Printf("In function1 at the bottom!\n")
|
||||
}
|
||||
|
||||
func Function2() {
|
||||
fmt.Printf("Function2: Deferred until the end of the calling function!")
|
||||
func function2() {
|
||||
fmt.Printf("function2: Deferred until the end of the calling function!")
|
||||
}
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user