files wouldn't be compiled into the package unless you ran the "go test"
command. After trying unsuccessfully to do some init() methods within test
files for Exported variables, I played around with some simple code to test
scoping. My tests are in this repo:
This is what I discovered:
* Exported package identifiers within *_test.go files aren't visible
outside the package.
* Initialization functions "init()" within *_test.go files can change
package-level variables but those changes are only visible within test
files and not in non-test files of the same package.
It feels like the test files in a package form a subpackage. Since this
wasn't what I expected, I could be doing something stupid or it could be
expected behavior that isn't obvious from the docs.
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 firstname.lastname@example.org.
For more options, visit https://groups.google.com/d/optout.