gobuch/golang-language-samples/pointer-struct/pointer.go

15 lines
194 B
Go
Raw Normal View History

2020-08-21 04:26:40 +00:00
package main
import "fmt"
type Person struct {
Name string
}
func main() {
p := &Person{}
p.Name = "Kristian"
(*p).Name = "Kristian" //beide Zeilen sind gleichbedeutend
fmt.Println(p)
}