summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--README.md11
-rw-r--r--main.go14
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
diff --git a/README.md b/README.md
index 326768f..3fd1447 100644
--- a/README.md
+++ b/README.md
@@ -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
+```
diff --git a/main.go b/main.go
index d7c5f7b..947bc90 100644
--- a/main.go
+++ b/main.go
@@ -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")
}