Newer
Older
01_hello / struct / pointer.go
yhornisse on 1 Oct 2021 210 bytes fix and add sample
package main

import "fmt"

type Hoge struct {
	Name string
}

func (h Hoge) foo() {
	fmt.Println(h.Name)
}

func (p *Hoge) bar() {
	fmt.Println(p.Name)
}

func main() {
	v := Hoge{"hoge"}
	v.foo()
	v.bar()
}