Golang 利用unsafe.Pointer进行指针操作 Jackey Golang 2021-09-24 1,856 次浏览 Golang, 指针 func main() { data := []int{1, 2, 3} for i := 0; i < len(data); i++ { ptr := unsafe.Pointer(uintptr(unsafe.Pointer(&data[0])) + uintptr(i)*unsafe.Sizeof(data[0])) fmt.Printf("%d ", *...
Golang 方法中指针传值的陷阱 Jackey Golang 2020-03-04 2,841 次浏览 Golang, 指针 package main import "fmt" type Person struct { Name string } func (p Person) test1() { p.Name = "www.gopher.cc" fmt.Println(p.Name) } func (p *Person) test2() { p.Name = "www.gopher.cc" ...