本文整理匯總了Golang中syscall.Errstr函數的典型用法代碼示例。如果您正苦於以下問題:Golang Errstr函數的具體用法?Golang Errstr怎麽用?Golang Errstr使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Errstr函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getProcAddr
func getProcAddr(lib syscall.Handle, name string) uintptr {
addr, err := syscall.GetProcAddress(lib, name)
if err != 0 {
panic(name + " " + syscall.Errstr(err))
}
return addr
}
示例2: lastError
func lastError(win32FuncName string) os.Error {
if errno := GetLastError(); errno != ERROR_SUCCESS {
return newError(fmt.Sprintf("%s: %s", win32FuncName, syscall.Errstr(int(errno))))
}
return nil
}
示例3: MustLoadLibrary
func MustLoadLibrary(name string) uint32 {
lib, errno := syscall.LoadLibrary(name)
if errno != 0 {
panic(fmt.Sprintf(`syscall.LoadLibrary("%s") failed: %s`, name, syscall.Errstr(errno)))
}
return lib
}
示例4: MustGetProcAddress
func MustGetProcAddress(lib uintptr, name string) uintptr {
addr, errno := syscall.GetProcAddress(syscall.Handle(lib), name)
if errno != 0 {
panic(fmt.Sprintf(`syscall.GetProcAddress(%d, "%s") failed: %s`, lib, name, syscall.Errstr(errno)))
}
return uintptr(addr)
}
示例5: readAndPrint
func readAndPrint(fd int, buf []byte) {
_, errno := syscall.Read(fd, buf)
if errno != 0 {
fmt.Printf("readAndPrint: %v: %v\n", errno, syscall.Errstr(errno))
os.Exit(1)
}
println(string(buf))
}
示例6: MustGetProcAddress
func MustGetProcAddress(lib uint32, name string) uint32 {
addr, errno := syscall.GetProcAddress(lib, name)
if errno != 0 {
panic(fmt.Sprintf(`syscall.GetProcAddress(%d, "%s") failed: %s`, lib, name, syscall.Errstr(errno)))
}
return addr
}
示例7: reffile
func reffile(filename string) (int64, int64) {
var st syscall.Stat_t
if e := syscall.Stat(filename, &st); e != 0 {
fmt.Fprintf(os.Stderr, "stat: Error %s\n", syscall.Errstr(e))
os.Exit(1)
}
//FIXME: bug in Go! Amd64 has following rest have Atimespec and Mtimespec
return st.Atim.Sec, st.Mtim.Sec
}
示例8: cgoLookupIPCNAME
func cgoLookupIPCNAME(name string) (addrs []IP, cname string, err os.Error, completed bool) {
var res *syscall.Addrinfo
var hints syscall.Addrinfo
// NOTE(rsc): In theory there are approximately balanced
// arguments for and against including AI_ADDRCONFIG
// in the flags (it includes IPv4 results only on IPv4 systems,
// and similarly for IPv6), but in practice setting it causes
// getaddrinfo to return the wrong canonical name on Linux.
// So definitely leave it out.
hints.Ai_flags = int32((syscall.AI_ALL | syscall.AI_V4MAPPED | syscall.AI_CANONNAME) & cgoAddrInfoMask())
h := syscall.StringBytePtr(name)
gerrno := libc_getaddrinfo(h, nil, &hints, &res)
if gerrno != 0 {
var str string
if gerrno == syscall.EAI_NONAME {
str = noSuchHost
} else if gerrno == syscall.EAI_SYSTEM {
str = syscall.Errstr(syscall.GetErrno())
} else {
str = bytePtrToString(libc_gai_strerror(gerrno))
}
return nil, "", &DNSError{Error: str, Name: name}, true
}
defer libc_freeaddrinfo(res)
if res != nil {
cname = bytePtrToString((*byte)(unsafe.Pointer(res.Ai_canonname)))
if cname == "" {
cname = name
}
if len(cname) > 0 && cname[len(cname)-1] != '.' {
cname += "."
}
}
for r := res; r != nil; r = r.Ai_next {
// Everything comes back twice, once for UDP and once for TCP.
if r.Ai_socktype != syscall.SOCK_STREAM {
continue
}
switch r.Ai_family {
default:
continue
case syscall.AF_INET:
sa := (*syscall.RawSockaddrInet4)(unsafe.Pointer(r.Ai_addr))
addrs = append(addrs, copyIP(sa.Addr[:]))
case syscall.AF_INET6:
sa := (*syscall.RawSockaddrInet6)(unsafe.Pointer(r.Ai_addr))
addrs = append(addrs, copyIP(sa.Addr[:]))
}
}
return addrs, cname, nil, true
}
示例9: main
func main() {
fds, errno := syscall.Socketpair(syscall.AF_UNIX, syscall.SOCK_STREAM, 0)
if errno != 0 {
fmt.Printf("mycat: socketpair: %v: %v\n", errno, syscall.Errstr(errno))
os.Exit(errno)
}
fd0, fd1 := fds[0], fds[1]
syscall.CloseOnExec(fd0)
bin := "./openfile/openfile"
argv := []string{bin, strconv.Itoa(fd1), os.Args[1]}
pid, errno := syscall.ForkExec(bin, argv, nil)
if errno != 0 {
fmt.Printf("getFdFromChild: ForkExec: %v\n", syscall.Errstr(errno))
os.Exit(1)
}
syscall.Close(fd1)
getFdFromChild(pid, fd0)
syscall.Close(fd0)
}
示例10: startServer
func startServer() {
resultsrv = new(resultSrv)
var errno int
resultsrv.iocp, errno = syscall.CreateIoCompletionPort(syscall.InvalidHandle, 0, 0, 1)
if errno != 0 {
panic("CreateIoCompletionPort failed " + syscall.Errstr(errno))
}
go resultsrv.Run()
iosrv = new(ioSrv)
iosrv.submchan = make(chan anOpIface)
iosrv.canchan = make(chan anOpIface)
go iosrv.ProcessRemoteIO()
}
示例11: init
func init() {
k32, err := syscall.LoadLibrary("kernel32.dll")
if err != 0 {
panic("LoadLibrary " + syscall.Errstr(err))
}
defer syscall.FreeLibrary(k32)
nSetCommState = getProcAddr(k32, "SetCommState")
nSetCommTimeouts = getProcAddr(k32, "SetCommTimeouts")
nSetCommMask = getProcAddr(k32, "SetCommMask")
nSetupComm = getProcAddr(k32, "SetupComm")
nGetOverlappedResult = getProcAddr(k32, "GetOverlappedResult")
nCreateEvent = getProcAddr(k32, "CreateEventW")
nResetEvent = getProcAddr(k32, "ResetEvent")
}
示例12: Start
func (self Timer) Start(verbose bool) (err os.Error) {
if verbose {
fmt.Printf("Pid %d : waiting for %f seconds to send %d\n", self.Pid, self.tickSecs(), self.Signal)
}
time.Sleep(self.Ticks)
eno := syscall.Kill(self.Pid, self.Signal)
if self.Signal > 0 && eno != 0 {
err = os.NewError(syscall.Errstr(eno))
if verbose {
fmt.Printf("Pid %d : Couldn't signal: %v\n", self.Pid, err)
}
} else if self.Signal == 0 && eno == 0 {
err = os.NewError(fmt.Sprintf("alive after %f seconds\n", self.tickSecs()))
fmt.Printf("Pid %d : %s", self.Pid, err.String())
}
return
}
示例13: init
func init() {
// Library
libole32 = MustLoadLibrary("ole32.dll")
// Functions
coGetClassObject = MustGetProcAddress(libole32, "CoGetClassObject")
oleInitialize = MustGetProcAddress(libole32, "OleInitialize")
oleSetContainedObject = MustGetProcAddress(libole32, "OleSetContainedObject")
oleUninitialize = MustGetProcAddress(libole32, "OleUninitialize")
// Initialize OLE stuff
// FIXME: Find a way to call OleUninitialize at app shutdown
// Maybe we should require explicit walk.Initialize/walk.Shutdown?
if hr := OleInitialize(); FAILED(hr) {
panic("OleInitialize Error: " + syscall.Errstr(int(hr)))
}
}
示例14: Run
func (s *resultSrv) Run() {
var o *syscall.Overlapped
var key uint32
var r ioResult
for {
r.err = syscall.GetQueuedCompletionStatus(s.iocp, &(r.qty), &key, &o, syscall.INFINITE)
switch {
case r.err == 0:
// Dequeued successfully completed io packet.
case r.err == syscall.WAIT_TIMEOUT && o == nil:
// Wait has timed out (should not happen now, but might be used in the future).
panic("GetQueuedCompletionStatus timed out")
case o == nil:
// Failed to dequeue anything -> report the error.
panic("GetQueuedCompletionStatus failed " + syscall.Errstr(r.err))
default:
// Dequeued failed io packet.
}
(*anOp)(unsafe.Pointer(o)).resultc <- r
}
}
示例15: getFdFromChild
func getFdFromChild(pid, fd int) {
var wstatus syscall.WaitStatus
_, errno := syscall.Wait4(pid, &wstatus, 0, nil)
if errno != 0 {
fmt.Printf("getFdFromChild: Wait4: %v: %v\n", errno, syscall.Errstr(errno))
os.Exit(1)
}
if wstatus.ExitStatus() != 0 {
fmt.Printf("openfile exited(%v) with status %v\n", wstatus.Exited(), wstatus.ExitStatus())
os.Exit(1)
}
var smallbuf [10]byte
var largebuf [4096]byte
readAndPrint(fd, smallbuf[:])
recvfd, err := fdpass.Receive(fd)
if err != nil {
fmt.Printf("getFdFromChild: fdpass.Receive: %v\n", err)
os.Exit(1)
}
readAndPrint(recvfd, largebuf[:])
readAndPrint(fd, smallbuf[:])
}