Newer
Older
01_hello / interface / interface.go
yhornisse on 1 Oct 2021 243 bytes add interface sample
package main

import "fmt"

type Hoge struct {
	Name string
}

type Parent interface {
	hoge(b bool)
}

func (p *Hoge) hoge(b bool) {
	fmt.Println(p.Name)
}

func fuga(v Parent) {
	v.hoge(true)
}


func main() {
	v := Hoge{"taro"}
	fuga(&v)
}