go - Golang Global Variable access -


i'm new golang, should simple answer i've tried searching every no luck.

how access global variable declared/init in main.go in different .go package/file? keeps telling me variable undefined (i know global variables bad used timestamp)

in main.go

var starttime = time.now() func main(){...} 

trying access starttime in different .go file keep getting starttime undefined

i "inject" starttime variable instead, otherwise have circular dependency between packages.

main.go

var starttime = time.now() func main() {    otherpackage.starttime = starttime } 

otherpackage.go

var starttime time.time 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -