Skip to content

Instantly share code, notes, and snippets.

@Agilulfe
Last active September 9, 2020 14:27
Show Gist options
  • Save Agilulfe/c7593b2253fc3a825d4e70e4dbea3e36 to your computer and use it in GitHub Desktop.
Save Agilulfe/c7593b2253fc3a825d4e70e4dbea3e36 to your computer and use it in GitHub Desktop.
Go scope with a global variable
package main
import "fmt"
var x = "Hello, Scope!"
func main() {
fmt.Println(x)
testScope()
}
func testScope() {
fmt.Println(x, "test")
}
// This will print "Hello, Scope!" and "Hello, Scope! test" To the console
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment