I'm facing a strange problem with unexported and embedded fields. I have two packages, shown below.
In file exp/exp.go
func GetLeStuff() (Exported, error) {
val := shell{Exported{42}, nil}
return val.Exported, val.error
And then in imp/imp.go
i, err := exp.GetLeStuff()
(The import path are specified for the Github repository linked below)
Compiling fails with the following error messages:
# imp
imp/imp.go:5: unknown exp.shell field 'exp.error' in struct literal
imp/imp.go:5: exp.val·3.error undefined (cannot refer to unexported field or method exp.error)
imp/imp.go:9: tempname called with nil type
I don't understand that. error is a built in type, the type shell is unexported and I don't try to expose it to the user. The fields of shell are picked out and exposed to the user individually, leaving us with values of types Exported and error.
Is this expected to fail? If so, where is the mistake in my reasoning? If not, is this a bug? (Inlining? :) )
If you want to get the code easily, try