Skip to content

Instantly share code, notes, and snippets.

@lizrice
Created August 17, 2019 06:27
Show Gist options
  • Save lizrice/dc97eee360282811bac259b7fa4fc1c6 to your computer and use it in GitHub Desktop.
Save lizrice/dc97eee360282811bac259b7fa4fc1c6 to your computer and use it in GitHub Desktop.
Variables in functions in Go
func main() {
x := 1
f := func() {
fmt.Printf("x is %d\n", x)
}
x = 2
f()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment