操作符表示指针指向的底层值 切片 nill 清空 按值引用赋值 获取地址赋值
package main
import "fmt"
var thisVisitedUrls [] string
func tf() {
p := &thisVisitedUrls
*p = append(*p, "url")
}
func main() {
tf()
fmt.Println(thisVisitedUrls)
p := &thisVisitedUrls
*p = append(*p, "url2")
fmt.Println(thisVisitedUrls)
*p = nil
fmt.Println(thisVisitedUrls)
*p = append(*p, "urlINIT")
fmt.Println(thisVisitedUrls)
}
package main
import "fmt"
var t = 12
var t1 = t
func main() {
fmt.Println(t)
fmt.Println(t1)
t1 = 123
fmt.Println(t)
fmt.Println(t1)
p1 := &t
*p1 = 1234
fmt.Println(t)
fmt.Println(t1)
var t2 = &t
fmt.Println(t)
fmt.Println(t2)
*t2 = 12345
fmt.Println(t)
fmt.Println(t2)
var t3 = &t
fmt.Println(t)
fmt.Println(t3)
*t3 = 123456
var t4 = *t3
fmt.Println(t)
fmt.Println(t3)
fmt.Println(t4)
*t3 = 1234567
fmt.Println(t)
fmt.Println(t3)
fmt.Println(t4)
}
12
12
12
123
1234
123
1234
0x5211e8
12345
0x5211e8
12345
0x5211e8
123456
0x5211e8
123456
1234567
0x5211e8
123456