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
From: Michael Banzon <[email protected]> on behalf of
Michael Banzon <[email protected]>
Date: Thursday, January 24, 2019 at 12:17 AM
To: 伊藤和也 <[email protected]>
Cc: golang-nuts <[email protected]>
Subject: Re: [go-nuts] Re: Is it possible to export a variable from main
package? If impossible, why?
Can you provide the output you get and the source you are compiling?
If you could also include the command line input+output it would probably help.
/M
Den 24. jan. 2019 kl. 07.13 skrev 伊藤和也
<[email protected]<mailto:[email protected]>>:
Now I tried to use "Number" in the same package "main" in a different .go file
in the same directly but I got the compile error "undefined: Number".
2019年1月24日木曜日 11時27分57秒 UTC+9 伊藤和也:
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
[email protected]<mailto:[email protected]>.
For more options, visit
https://groups.google.com/d/optout<https://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Foptout&data=02%7C01%7C%7C90a9f524d62a42171db208d681c2feae%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636839071819772011&sdata=bjXUKeuLNOYQjqyPs%2Ft6HwIrPC%2BGS36MmFet1%2Fxby%2Fk%3D&reserved=0>.
--
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
[email protected]<mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.