是否有任何标准方法来检查操作系统是32位还是64位?我检查了运行时和os包,但找不到. http://play.golang.org/p/d6NywMDMcY
package main
import "fmt"
import "runtime"
func main() {
fmt.Println(runtime.GOOS, runtime.GOARCH)
}
Run Code Online (Sandbox Code Playgroud)
pet*_*rSO 11
32位或64位操作系统是什么意思?例如,GOARCH=amd64p32
用于的GOOS=nacl
是amd64
具有32位指针和32位类型int
s和uint
s的64位指令.
package main
import (
"fmt"
"runtime"
"strconv"
)
func main() {
const PtrSize = 32 << uintptr(^uintptr(0)>>63)
fmt.Println(runtime.GOOS, runtime.GOARCH)
fmt.Println(strconv.IntSize, PtrSize)
}
Run Code Online (Sandbox Code Playgroud)
游乐场:http://play.golang.org/p/TKnCA0gqsI
输出:
nacl amd64p32
32 32
Run Code Online (Sandbox Code Playgroud)
和
linux amd64
64 64
Run Code Online (Sandbox Code Playgroud)