package main
var Number int = 100
func main() {
}
--
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...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
--
package main
var Number int = 100
func main() {}
package hello2019年1月24日木曜日 11時27分57秒 UTC+9 伊藤和也:
import "fmt"
func abc() {
fmt.Println(Number)
}
--
Not sure if this has been answered.
Yes, you can make a global value public in the main package, but it is more or less meaningless as there is no way for another package to import your main package. It is possible there is some way that it might happen in the testing infrastructure, but that is probably not what you are looking for.
I have sometimes made public values in package main, but simply to give them more visibility.
Why do you want to make a value public in the main package? What problem are you trying to solve?
-Paul