I try understand how to organize go code using "internal" packages. Let me show what the structure I have:
project/
internal/
foo/
foo.go # package foo
bar/
bar.go # package bar
main.go
# here is the code from main.go
package main
import (
"project/internal/foo"
"project/internal/bar"
)
project/
is outside from GOPATH tree. Whatever path I try to import from main.go
nothing works, the only case working fine is import "./internal/foo|bar"
. I think I do something wrong or get "internal" package idea wrong in general. Could anybody make things clearer, please?
UPDATE
The example above is correct the only what I need was to place project/
folder under $GOPATH/src
. So the thing is import path like the project/internal/foo|bar
is workable if we only import it from project/
subtree and not from the outside.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…