1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-04 12:52:28 +08:00

System: Add the system bits judgment (#44)

Co-authored-by: anyanfei <anyanfei@yungengxin.com>
This commit is contained in:
anyanfei
2022-07-20 17:25:14 +08:00
committed by GitHub
parent 2fd23f02f6
commit 35a50bd792
2 changed files with 16 additions and 0 deletions

View File

@@ -70,3 +70,9 @@ func ExecCommand(command string) (stdout, stderr string, err error) {
return
}
// GetOsBits get this system bits 32bit or 64bit
// return bit int (32/64)
func GetOsBits() int {
return 32 << (^uint(0) >> 63)
}

View File

@@ -60,3 +60,13 @@ func TestExecCommand(t *testing.T) {
assert.IsNotNil(err)
}
}
func TestGetOsBits(t *testing.T) {
osBits := GetOsBits()
switch osBits {
case 32, 64:
t.Logf("os is %d", osBits)
default:
t.Error("os is not 32 or 64 bits")
}
}