本文整理匯總了Golang中C.uname函數的典型用法代碼示例。如果您正苦於以下問題:Golang uname函數的具體用法?Golang uname怎麽用?Golang uname使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了uname函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: setScreen
//export setScreen
func setScreen(scale int) {
C.uname(&C.sysInfo)
name := C.GoString(&C.sysInfo.machine[0])
var v float32
switch {
case strings.HasPrefix(name, "iPhone"):
v = 163
case strings.HasPrefix(name, "iPad"):
// TODO: is there a better way to distinguish the iPad Mini?
switch name {
case "iPad2,5", "iPad2,6", "iPad2,7", "iPad4,4", "iPad4,5", "iPad4,6", "iPad4,7":
v = 163 // iPad Mini
default:
v = 132
}
default:
v = 163 // names like i386 and x86_64 are the simulator
}
if v == 0 {
log.Printf("unknown machine: %s", name)
v = 163 // emergency fallback
}
pixelsPerPt = v * float32(scale) / 72
screenScale = scale
}
示例2: getFromUname
func (self *SystemInfo) getFromUname() {
var unameBuf C.struct_utsname
C.uname(&unameBuf)
self.Version = C.GoString(&unameBuf.release[0])
self.VendorName = C.GoString(&unameBuf.sysname[0])
self.Name = C.GoString(&unameBuf.sysname[0])
self.Machine = C.GoString(&unameBuf.machine[0])
self.Arch = C.GoString(&unameBuf.machine[0])
self.PatchLevel = "unknown"
}
示例3: uname
// uname returns strings similar to the Unix uname command:
// sysname, nodename, release, version, machine
func uname() (string, string, string, string, string, error) {
var name C.struct_utsname
_, err := C.uname(&name)
if err != nil {
var errno syscall.Errno = err.(syscall.Errno)
return "", "", "", "", "", fmt.Errorf("Failed to call uname: %s", errno)
}
return C.GoString(&name.sysname[0]), C.GoString(&name.nodename[0]),
C.GoString(&name.release[0]), C.GoString(&name.version[0]),
C.GoString(&name.machine[0]), nil
}
示例4: Uname
func Uname(utsname *Utsname) error {
var cstruct C.struct_utsname
if err := C.uname(&cstruct); err != 0 {
return errors.New("utsname error")
}
// XXX: this may crash if any value is exactly 256 characters (no 0 terminator)
utsname.Sysname = C.GoString(&cstruct.sysname[0])
utsname.Nodename = C.GoString(&cstruct.nodename[0])
utsname.Release = C.GoString(&cstruct.release[0])
utsname.Version = C.GoString(&cstruct.version[0])
utsname.Machine = C.GoString(&cstruct.machine[0])
return nil
}
示例5: OSRelease
func OSRelease() string {
var utsname C.struct_utsname
C.uname(&utsname)
return C.GoString(&utsname.release[0])
}