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

import "fmt"

type Hoge struct {
	Name string
}

type Parent interface {
	hoge(b bool)
	fuga()
}

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

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


func main() {
	v := Hoge{"taro"}
	//fuga(&v) // build error
	fmt.Println(v)
}