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 -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -