golang 64位linux环境下编译出32位程序操作
作者:天天water 时间:2024-05-02 16:26:09
目标:在64位linux系统上编译出32位程序。
操作:
1.执行 go env 查看当前go环境配置
2.执行 export GOARCH=386 配置go输出系统平台为32位
3.go build 编译程序
4.使用file main 指令查看编译出的可执行程序是否为32位
实践图片:
补充:golang float32/64与[]byte互转
网络协议开发中经常需要将int、float、bool等转为二进制数据,float32、64 与[]byte处理:
import (
"encoding/binary"
"math"
)
func Float32ToByte(float float32) []byte {
bits := math.Float32bits(float)
bytes := make([]byte, 4)
binary.LittleEndian.PutUint32(bytes, bits)
return bytes
}
func ByteToFloat32(bytes []byte) float32 {
bits := binary.LittleEndian.Uint32(bytes)
return math.Float32frombits(bits)
}
func Float64ToByte(float float64) []byte {
bits := math.Float64bits(float)
bytes := make([]byte, 8)
binary.LittleEndian.PutUint64(bytes, bits)
return bytes
}
func ByteToFloat64(bytes []byte) float64 {
bits := binary.LittleEndian.Uint64(bytes)
return math.Float64frombits(bits)
}
以上为个人经验,希望能给大家一个参考,也希望大家多多支持asp之家。如有错误或未考虑完全的地方,望不吝赐教。
来源:https://water.blog.csdn.net/article/details/79472335
标签:golang,64位,32位
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
uniapp封装小程序雷达图组件的完整代码
2024-04-17 09:55:26
![](https://img.aspxhome.com/file/2023/4/136464_0s.png)
MYSQL SET类型字段的SQL操作知识介绍
2024-01-20 20:00:38
Python NumPy库安装使用笔记
2022-05-20 17:49:56
python解决方案:WindowsError: [Error 2]
2022-07-09 00:11:34
python修改微信和支付宝步数的示例代码
2021-08-31 08:45:06
![](https://img.aspxhome.com/file/2023/8/78838_0s.png)
jQuery中文入门教程
2007-12-09 19:20:00
![](https://img.aspxhome.com/file/UploadPic/up/2007120919444529.gif)
Python环境下搭建属于自己的pip源的教程
2021-12-19 05:57:54
Pandas读取csv时如何设置列名
2023-11-25 19:54:55
javascript在线游戏:找相同的图片
2008-03-12 12:18:00
解决pandas中读取中文名称的csv文件报错的问题
2021-08-07 00:53:40
Python模块glob函数示例详解教程
2023-10-27 15:49:36
![](https://img.aspxhome.com/file/2023/3/85173_0s.png)
使用有趣的自定义标记布局页面
2012-07-12 01:29:03
Python Web框架Flask中使用新浪SAE云存储实例
2022-11-03 06:27:16
python实现简单聊天应用 python群聊和点对点均实现
2023-01-16 08:35:55
![](https://img.aspxhome.com/file/2023/4/99424_0s.png)
如何调用SQL Server的存储过程?
2009-11-15 20:15:00
详解Django+Uwsgi+Nginx的生产环境部署
2022-10-30 10:54:17
![](https://img.aspxhome.com/file/2023/3/89193_0s.png)
2个asp获取安全字符串的方法
2007-10-19 15:08:00
利用python实现蝴蝶曲线
2022-09-30 18:51:51
![](https://img.aspxhome.com/file/2023/2/114532_0s.png)
python实现二分查找算法
2022-08-30 21:58:54
python解释器安装教程的方法步骤
2023-02-09 14:04:08
![](https://img.aspxhome.com/file/2023/5/118505_0s.jpg)