golang获取架构
在Go语言中获取系统架构,可以使用runtime包中的GOARCH变量,该变量包含当前系统的架构信息。
示例代码:
package main
import (
"fmt"
"runtime"
)
func main() {
fmt.Println("当前系统架构为:", runtime.GOARCH)
}
输出结果:
当前系统架构为: amd64
其中,GOARCH的值可能为以下之一:
- 386
- amd64
- arm
- arm64
- ppc64
- ppc64le
- mips
- mipsle
- mips64
- mips64le
- s390x
原文地址: https://www.cveoy.top/t/topic/wuT 著作权归作者所有。请勿转载和采集!