当前位置:网站首页>Problems encountered in upgrading golang to version 1.18.4
Problems encountered in upgrading golang to version 1.18.4
2022-07-28 09:21:00 【alphaTao】
background
Used before golang Outdated Version Upgrade to the latest 1.18.4 edition
There are several problems when compiling the project
Document solutions 
problem
1. misuse of unbuffered os.Signal channel as argument to signal.Notify
translate : Abuse unbuffered os.Signal Channel as signal.Notify Parameters of
Code
ch := make(chan os.Signal)
signal.Notify(ch, syscall.SIGUSR1, syscall.SIGUSR2)
You can find the channel we created ch No, buffer So I made a mistake But before using the old version go It's always possible
To
Check the description of the package https://pkg.go.dev/os/signal#Notify
Clearly written We must use a buffered channel or risk missing the signal
It must be buffered chan So change it according to the example
ch := make(chan os.Signal,1)
2. conversion from int to string yields a string of one rune, not a string of digits (did you mean fmt.Sprint(x)?)
Code
func Test_func(t *testing.T) {
var v int
v = 65
fmt.Println(string(v))
}
The question is int Use it directly string Forced conversion
The old version Even as rune The result of conversion is A No errors are reported
however 1.18.4 In this case, an error will be reported
If you want to output as "A"
It can be changed to
string(rune(v))
If you want to output "65"
It can be changed to
fmt.Sprint(v)
// perhaps
strconv.Itoa(v)
边栏推荐
猜你喜欢

训练一个自己的分类 | 【包教包会,数据都准备好了】

The chess robot pinched the finger of a 7-year-old boy, and the pot of a software testing engineer? I smiled.

golang升级到1.18.4版本 遇到的问题

5 运算符、表达式和语句

MDM data quality application description

Linux initializes MySQL with fatal error: could not find my-default.cnf

Get started quickly with flask (I) understand the framework flask, project structure and development environment

JSON file storage
![[附下载]推荐几款暴力破解和字典生成的工具](/img/c6/f4a9c566ff21a8e133a8a991108201.png)
[附下载]推荐几款暴力破解和字典生成的工具

MDM数据质量应用说明
随机推荐
【多线程】println方法底层原理
RGB-T追踪——【多模态融合】Visible-Thermal UAV Tracking: A Large-Scale Benchmark and New Baseline
Code management platform SVN deployment practice
从开发转测试:我从零开始,一干就是6年的自动化测试历程
修改虚拟机IP地址
CSV file storage
这两套代码有什么区别呢?
【打包部署】
OpenShift 4 之AMQ Streams(1) - 多个Consumer从Partition接收数据
推荐一个摆脱变量名纠结的神器和批量修改文件名方法
Leetcode 452. minimum number of arrows to burst balloons (medium)
IntelliJ idea associated database
FPGA开发学习开源网站汇总
侯捷STL标准库和泛型编程
golang升级到1.18.4版本 遇到的问题
正则表达式为十六进制数字?
Sword finger offer
使用 GBase C API 执行存储过程是怎样的?
ES6 let and Const
实现批量数据增强 | keras ImageDataGenerator使用