我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

Go编译器是否连接由加号分隔的字符串?

Let's say I have the following in my code:

err := "This is a very long error message"+
    "that spans multiple lines."

Will Go compile this under the hood into one string, or is there some small penalty associated with doing the addition there?

It's a constant expression and is specified to be evaluated at compile time.

It's compiled as one string for Go 1.3.

go.string."This is a very long error messagethat spans multiple lines."

It's probably one string for earlier versions too.

近期文章

  • 使用string()时添加随机字节
  • 为什么binary.Read()无法正确读取整数?
  • 学习编写单元测试
  • 每秒计算事物并保持运行平均值的算法
  • 从套接字读取消息时如何获得字节序?
  • 如何导入官方的mongodb驱动程序包
  • golang与PHP / Ruby的unpack(“ C *”,。)等效吗?
  • 有没有更简单的方法可以在Go中解码此json?
  • 如何保护服务免受gzip炸弹的侵害?
  • 进行错误跟踪/报告系统?
  • 在Go中添加默认的HTTP标头
  • 来自MongoDB的alpha驱动程序的简单CRUD示例
  • 为归档功能fs创建单元测试
  • 使用main.go在其他程序包中声明的结构
  • Go中的实数[重复]
  • 接口实现中的非接口方法
  • 将执行get命令更新本地计算机中的软件包
  • 使用iota定义const变量时如何跳过很多值?
  • 如何通过包含JavaScript的mongo_go_driver运行汇总查询?
  • 我应该将指针作为参数传递吗

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华