I have the following dir structure:
github.com
meee
projectA
foo
foo.go
bar
bar.go
In foo.go:
package foo
import(
"github.com/meee/projectA/bar"
)
type Foo struct {
Name string
Bars []Bar
}
In bar.go:
package bar
type Bar struct {
Name string
}
This will not compile/build, the error I get is:
undefined: Bar
Since I have it imported, I do not know why it will not compile.
If you import fmt
, you cannot call Println
directly. You must call fmt.Println
instead; otherwise, you get the undefined: Println
error.
It's the same for your bar
package. This should work now:
type Foo struct {
Name string
Bars []bar.Bar
}