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
Post a Comment