The sample code: // main.go in varglobal/ package main import( "fmt" "varglobal/db" )
var MyGlobalVar string ="Any value :)" func main(){ db.TryDisplayMyVar() } // db.go in varglobal/db/ package db import "fmt" func TryDisplayMyVar(){ fmt.Println("Value:",MyGlobalVar) } Results of compilation: # varglobal/db db/db.go:15:23: undefined: MyGlobalVar Why can not access global var MyGlobalVar? Any idea? According Golang docs should be possible. It works when both files are in the same directory. But when db.go is in another doesn't work. I tried this sample because I need to update big bunch of code implementing one global variable from packages. Some good samaritan out there? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.