@kjk1/

gobook defer gotcha 3

Go

No description

fork
loading
Files
  • main.go

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.38206218222770727","path":"main.go","file":{"path":"main.go","content":{"asEncoding":{"base64":"cGFja2FnZSBtYWluCgppbXBvcnQgImZtdCIKCi8vIDpzaG93IHN0YXJ0CgpmdW5jIG1haW4oKSB7Cglmb3IgaSA6PSAwOyBpIDwgMjsgaSsrIHsKCQlkZWZlciBmdW5jKGkyIGludCkgewoJCQlmbXQuUHJpbnRmKCIlZFxuIiwgaTIpCgkJfShpKQoJfQp9CgovLyA6c2hvdyBlbmQ="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package main

import "fmt"

// :show start

func main() {
	for i := 0; i < 2; i++ {
		defer func(i2 int) {
			fmt.Printf("%d\n", i2)
		}(i)
	}
}

// :show end