My source files tree is like this:
/src
/pkg
/foo
foo.go
foo_test.go
Inside foo.go:
package foo
func bar(n int) {
...
}
inside foo_test.go:
package foo
func testBar(t *testing.T) {
bar(10)
...
}
My questions are:
- Does package name relates to directory name, source file name?
- If there is only one source file for a package, need I put it in a directory?
- Should I put foo.go and foo_test.go in the same package?
- In the foo_test.go, as it's in the same package as foo.go, I didn't import foo. But when I compile foo_test.go with 6g, it says bar() is undefined. What should I do?