go变量

沉默术士
• 阅读 630
package main

import (
    "fmt"
    "reflect"
    "unsafe"
)

func main() {
    var s1, s2 string
    var sh1, sh2 *reflect.StringHeader
    s1 = "abcd"
    s2 = s1

    sh1 = (*reflect.StringHeader)(unsafe.Pointer(&s1))
    fmt.Println(sh1.Data, sh1.Len, &s1)

    sh2 = (*reflect.StringHeader)(unsafe.Pointer(&s2))
    fmt.Println(sh2.Data, sh2.Len, &s2)

    s2 = "cdef123"

    sh2 = (*reflect.StringHeader)(unsafe.Pointer(&s2))
    fmt.Println(sh2.Data, sh2.Len, &s2)

}
点赞
收藏
评论区
推荐文章
Jacquelyn38 Jacquelyn38
4年前
用了这 7 个 VS Code 插件,想写一辈子代码
0\.往期精彩工具推荐译文来自https://levelup.gitconnected.com/7vscodeextensionsthatmakeyouwanttokeepcodingforeverf205e597ae34原作者Daan译者:蓝色的秋风(github
Wesley13 Wesley13
3年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
美凌格栋栋酱 美凌格栋栋酱
7个月前
Oracle 分组与拼接字符串同时使用
SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(
Easter79 Easter79
3年前
tcp和udp协议的聊天 和udp协议的时间同步机制
tcp协议聊天服务端::!(https://oscimg.oschina.net/oscnet/f3f8ed14e43656a322309ac6040261fb707.png)客户端!(https://oscimg.oschina.net/oscnet/b54670b34c0df68b0c52110478ff9e1b4f4.png)
Stella981 Stella981
3年前
Node.js VS PHP—你应该选择哪一个?
!(https://oscimg.oschina.net/oscnet/de8155e0d2e74fe9996e4805124e8434.png)!(https://oscimg.oschina.net/oscnet/2d4a9febeaa34b018e89c475efc6c4e0.jpg)现在,公司和开发人员可以选择多种技术
Wesley13 Wesley13
3年前
mysql设置时区
mysql设置时区mysql\_query("SETtime\_zone'8:00'")ordie('时区设置失败,请联系管理员!');中国在东8区所以加8方法二:selectcount(user\_id)asdevice,CONVERT\_TZ(FROM\_UNIXTIME(reg\_time),'08:00','0
Wesley13 Wesley13
3年前
Oracle JDK7 bug 发现、分析与解决实战
本文首发于vivo互联网技术微信公众号链接:https://mp.weixin.qq.com/s/8f34CaTpWz5pTHKA0Xeg(https://www.oschina.net/action/GoToLink?urlhttps%3A%2F%2Fmp.weixin.qq.com%2Fs%2F8f34CaTpWz5p
Stella981 Stella981
3年前
Redis4.0.0 安装及配置 (Linux — Centos7)
Redis4.0.0安装及配置(Linux—Centos7)!96(http://cdn2.jianshu.io/assets/default_avatar/43397163ecdb3855a0a4139c34a695885.jpg?imageMogr2/autoor
Stella981 Stella981
3年前
Kali Day01
1root@kali:~/文档arpspoofieth0t172.20.151.172.20.151.1234:64:a9:36:4:b70:0:0:0:0:0080642:arpreply172.20.151.1isat34:64:a9:36:4:b7334:64:a9:36:4
Stella981 Stella981
3年前
Android蓝牙连接汽车OBD设备
//设备连接public class BluetoothConnect implements Runnable {    private static final UUID CONNECT_UUID  UUID.fromString("0000110100001000800000805F9B34FB");
Stella981 Stella981
3年前
Sentinel 调用上下文环境实现原理(含原理图)
点击上方“中间件兴趣圈”,选择“设为星标”做积极的人,越努力越幸运!!(https://oscimg.oschina.net/oscnet/33cec0d20fe42d2f34e7ea0ccb472821287.png)(https://www.oschina.net/action/GoToLink?urlhttp%3A%2F%2Fmp