Skip to content

Instantly share code, notes, and snippets.

Created May 19, 2019 14:24
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Method Overriding in Go
package main
import "fmt"
type foo struct{}
func (f foo) Start() {
fmt.Println("Foo Started")
func (f foo) Call() {
fmt.Println("Foo Called")
func (f baz) Call() {
fmt.Println("Baz Called")
type baz struct {
func main() {
foo{}.Call() // This output: Foo Called
foo{}.Start() // This output: Foo Started
baz{}.Call() // This outputs: Baz Called
baz{}.Start() // This outputs: Foo Started
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment