• 操作符表示指针指向的底层值 切片 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

    
    
  • 相关阅读:
    Unity3D热更新
    js
    xshell安装运行时提示缺少mfc110.dll
    Linux 分区的概念
    js
    Web 安全测试
    php 获取客户端的浏览器信息
    H5 获取地理位置
    JS -判断、监听屏幕横竖屏切换事件
    css 禁用移动端部分特性
  • 原文地址:https://www.cnblogs.com/rsapaper/p/9588025.html
Copyright © 2020-2023  润新知