Closed
Description
$go version
go version go1.5 darwin/amd64
$uname -a
Darwin TonydeMacBook-Air-2.local 13.1.0 Darwin Kernel Version 13.1.0: Thu Jan 16 19:40:37 PST 2014; root:xnu-2422.90.20~2/RELEASE_X86_64 x86_64
the project layout is below: (GOPATH=/home/bigwhite/gotestinternal)
/home/bigwhite/gotestinternal
└── src
├── mypkg
│ ├── internal
│ │ └── foo
│ │ └── foo.go
│ ├── main.o
│ └── pkg1
│ ├── main
│ └── main.go
└── otherpkg
└── main.go
I am trying to test the internal package in go 1.5 final release. according to the internal design doc, if we import internal/foo in mypkg/main.go or mypkg/pkg1/main.go, it is ok. but if we import mypkg/internal/foo in otherpkg/main.go, it should be invalid.
But the test result is not as the above:
//otherpkg/main.go
package main
import "mypkg/internal/foo"
func main() {
foo.Foo()
}
we build otherpkg/main.go in otherpkg directory, but no error occurs. It is not the result expected.
but go list -json tell us we has a not-allowed use of internal package:
"DepsErrors": [
{
"ImportStack": [
"otherpkg",
"mypkg/internal/foo"
],
"Pos": "",
"Err": "use of internal package not allowed"
}
]
I'm not sure whether it is a problem of go1.5.