当前位置:网站首页>golang升级到1.18.4版本 遇到的问题
golang升级到1.18.4版本 遇到的问题
2022-07-28 08:46:00 【alphaTao】
背景
之前使用的golang版本太低 升级到了最新的1.18.4版本
编译项目时遇到了几个问题
记录解决方法
问题
1. misuse of unbuffered os.Signal channel as argument to signal.Notify
翻译:滥用无缓冲的 os.Signal 通道作为 signal.Notify 的参数
代码
ch := make(chan os.Signal)
signal.Notify(ch, syscall.SIGUSR1, syscall.SIGUSR2)
可以发现我们创建的通道ch没有buffer 所以报了错 但之前使用老版本go一直都是可以的
到
查看包的说明 https://pkg.go.dev/os/signal#Notify
明确写了We must use a buffered channel or risk missing the signal
必须要用带缓冲的chan 所以按照例子改一下即可
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)?)
代码
func Test_func(t *testing.T) {
var v int
v = 65
fmt.Println(string(v))
}
这个问题是int直接使用string强制转换造成的
老版本 即使当作rune进行转换结果为A 并不会报错
但是1.18.4在这种情况下会报错
如果想要输出为"A"
可以改为
string(rune(v))
如果想要输出"65"
可以改为
fmt.Sprint(v)
//或者
strconv.Itoa(v)
边栏推荐
猜你喜欢

Marketing play is changeable, and understanding the rules is the key!

Principle of line of sight tracking and explanation of the paper

OpenShift 4 之AMQ Streams(1) - 多个Consumer从Partition接收数据

Promise learning notes

2022年危险化学品经营单位安全管理人员上岗证题目及答案

【高数】高数平面立体几何

【vscode】vscode使用

Huid learning 7: Hudi and Flink integration

JSON 文件存储

js数组去重,id相同对某值相加合并
随机推荐
OpenShift 4 - 使用 VerticalPodAutoscaler 优化应用资源 Request 和 Limit
Code management platform SVN deployment practice
478-82(56、128、718、129)
Oracle-11gR2默认的系统JOB
信息学奥赛一本通 1617:转圈游戏 | 1875:【13NOIP提高组】转圈游戏 | 洛谷 P1965 [NOIP2013 提高组] 转圈游戏
OpenShift 4 之AMQ Streams(1) - 多个Consumer从Partition接收数据
3D全景展示新模式,成为破局的关键
Sword finger offer
Centralized log management with sentry
ES6 let and Const
Go panic and recover
Detailed explanation of DHCP distribution address of routing / layer 3 switch [Huawei ENSP]
关闭页面时向后台发送消息
[附下载]推荐几款暴力破解和字典生成的工具
Why setting application.targetframerate doesn't work
【leetcode周赛总结】LeetCode第 83场双周赛(7.23)
Solution and implementation of APP accelerating reading and displaying IPFs pictures
(IROS 2022) 基于事件相机的单目视觉惯性里程计 / Event-based Monocular Visual Inertial Odometry
使用 GBase C API 执行存储过程是怎样的?
7 C控制语句:分支和跳转