Closed
Description
When you embed a type alias within a struct, the resulting struct type has a field of the alias's apparent name, but its run-time type descriptor uses the alias's original name. For example:
package main
import "fmt"
import "bytes"
type buffer => bytes.Buffer
type S struct {
buffer
}
func main() {
var s S
_ = s.buffer
// _ = s.Buffer // compile error: s has no field Buffer
fmt.Printf("%#v\n", s) // "main.S{Buffer:bytes.Buffer{...}}"
}
This is potentially confusing to the reader, and I suspect it will break a number of analysis tools that assume the name in the syntax of the embedded field declaration is the same as the name of the field.
Something to think about.
Metadata
Metadata
Assignees
Labels
No labels