diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | README.md | 11 | ||||
-rw-r--r-- | main.go | 14 |
3 files changed, 26 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ba2906d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +main @@ -11,3 +11,14 @@ sudo pacman -S zed zeditor file ``` However, it seems that the window that starts up does not close properly with `:wq`... I would be happy if vim mode was officially supported. + +## joke +```bash +$ go build -gcflags '-N -l -m' main.go +# command-line-arguments +./main.go:8:2: moved to heap: a +./main.go:19:11: ... argument does not escape +./main.go:19:12: *g escapes to heap +./main.go:20:11: ... argument does not escape +./main.go:20:12: "Hello, Zed!\n" escapes to heap +``` @@ -2,6 +2,20 @@ package main import "fmt" +var g *int + +func first() { + a := 1 + g = &a +} + +func second() { + b := 2 + _ = b +} func main() { + first() + second() + fmt.Print(*g, "\n") fmt.Print("Hello, Zed!\n") } |