According to the Go language spec, I can embed a type in a struct.
There is a weird case with the error
interface. It is not uppercased, so I assume it is not exported as a type. But it is defined by the language. So if I have a struct like this:
package foo
type Err struct {
error
}
is the embedded error
exported? Does Err
satisfy the error
interface?
Can I access it from another package, i.e. is the following ok?
package main
import "errors"
import "fmt"
import "foo"
func main() {
e := foo.Err{}
e.error = errors.New("Hello world!") // is this okay?
fmt.Println(e.Error())
}