-
Notifications
You must be signed in to change notification settings - Fork 42
Open
Description
First of all, thanks for the work you're putting into this!
There are couple of places in the Go API where the type of a field is only known at runtime (eg. Page.Properties
), so the field is typed as interface{}
in Go. One approach that's used eg. by the protobuf runtime is to use an interface with a "dummy" method that uniquely identifies the implementors, which helps both IDEs/language servers to do autocompletion and the compiler to ensure that the code is correct.
A simple example
type Page struct {
Properties IsPageProperties
}
type IsPageProperties interface { isPageProperties() }
type PageProperties struct { /* ... */ }
func (PageProperties) isPageProperties() {}
type DatabasePageProperties struct { /* ... */ }
func (DatabasePageProperties) isPageProperties() {}
let me know if you think this approach makes sense, and I can try to send a PR.
Metadata
Metadata
Assignees
Labels
No labels