mechiru / ptr

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ptr

ci

A pointer utilities for golang.

before:

func TakeReferenceFunc(s *string) {
	value = "fuga"
	if s != nil {
		value = *s
	}
	fmt.Println(value)
}

func main() {
	tmp := "hoge"
	TakeReferenceFunc(&tmp)
}

after:

func TakeReferenceFunc(s *string) {
	fmt.Println(ptr.DerefString(s, "fuga"))
}

func main() {
	TakeReferenceFunc(ptr.RefString("hoge"))
}

About

License:MIT License


Languages

Language:Go 100.0%