Samples
Samples
interfaces-are-satisfied-implicitly
Language: Gold, Platform: Echoes, Category: Tour of Go
https://github.com/remobjects/ElementsSamples/tree/master/Gold/Echoes/Tour of Go/interfaces-are-satisfied-implicitly
-
interfaces-are-satisfied-implicitly.Echoes
-
References
- #
- Source Files
-
Other Files
-
References
interfaces-are-satisfied-implicitly.go
// Ignored build directive: +build OMIT
package main
import "fmt"
type I interface {
M()
}
type T struct {
S string
}
// This method means type T implements the interface I,
// but we don't need to explicitly declare that it does so.
func (t T) M() {
fmt.Println(t.S)
}
func main() {
var i I = T{"hello"}
i.M()
}
