GitBucket
4.23.0
Toggle navigation
Sign in
Files
Branches
1
Releases
Issues
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
sample-golang
/
01_hello
Browse code
add sample
master
1 parent
fe6c716
commit
0dd4767ab59408dc76da69b9fdf62768f675b7c6
yhornisse
authored
on 27 Sep 2021
Patch
Showing
3 changed files
defer.go
func/defer.go
func/loop.go
Show notes
View
defer.go
100755 → 0
package main import "fmt" func hoge() { defer fmt.Println("3") // 4th defer fmt.Println("4") // 3rd fmt.Println("5") // 2nd } func fuga() { defer fmt.Println("1") // 5th fmt.Println("2") // 1st hoge() } func main() { fuga() }
Ignore Space
Show notes
View
func/defer.go
0 → 100755
package main import "fmt" func hoge() { defer fmt.Println("3") // 4th defer fmt.Println("4") // 3rd fmt.Println("5") // 2nd } func fuga() { defer fmt.Println("1") // 5th fmt.Println("2") // 1st hoge() } func main() { fuga() }
Ignore Space
Show notes
View
func/loop.go
0 → 100644
package main import "fmt" // NG Sample func hoge() { for i := 0; i < 5; i++ { f := func() { fmt.Println(i) } defer f() } } // OK Sample func fuga() { for i := 0; i < 5; i++ { i := i // important f := func() { fmt.Println(i) } defer f() } } func main() { hoge() /* 5 5 5 5 5 */ fmt.Println() fuga() /* 4 3 2 1 0 */ }
Show line notes below