Last active
September 9, 2020 14:27
-
-
Save Agilulfe/c7593b2253fc3a825d4e70e4dbea3e36 to your computer and use it in GitHub Desktop.
Go scope with a global variable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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