goatlang / goat

Extended flavor of the Go programming language, aiming for increased value safety and maintainability
MIT License
63 stars 1 forks source link

Interface Field Support #4

Open avivcarmis opened 2 years ago

avivcarmis commented 2 years ago

Since getters are not idiomatic Go when there's no functional requirement, creating getter functions simply to allow interface to match structs does feel idiomatic. This use case only gets less idiomatic when the getter-ed fields need to be public on their own to support reflection like in the case of json unmarshaled fields.

How about interface field support

type User interface {
  Name string
}

type user struct {
  Name string `json:"name"`
}