Is there an equivalent in Golang to raising a NotImplementedException
in Python when you define an interface with methods that you don't want to implement yet? Is this idiomatic Golang?
For example:
type MyInterface interface {
Method1() bool
Method2() bool
}
// Implement this interface
type Thing struct {}
func (t *Thing) Method1() bool {
return true
}
func (t *Thing) Method2() bool {
// I don't want to implement this yet
}
Usually in golang if you want to implement error handling you return an error
type MyInterface interface {
Method1() bool
Method2() (bool, error)
}
Then you can return an error. You can also log, or panic as @coredump said in the comments.
a empty var will do this
var _ MyInterface = &Thing{}
if Thing
doesn't implement the interface MyInterface
, compile will fail