├── vendor ├── github.com │ ├── mattn │ │ ├── go-isatty │ │ │ ├── doc.go │ │ │ ├── isatty_others.go │ │ │ ├── isatty_solaris.go │ │ │ ├── isatty_linux.go │ │ │ ├── isatty_appengine.go │ │ │ ├── isatty_bsd.go │ │ │ ├── isatty_linux_ppc64x.go │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ └── isatty_windows.go │ │ └── go-colorable │ │ │ ├── colorable_appengine.go │ │ │ ├── colorable_others.go │ │ │ ├── LICENSE │ │ │ ├── noncolorable.go │ │ │ └── README.md │ ├── ianlancetaylor │ │ └── demangle │ │ │ ├── README.md │ │ │ └── LICENSE │ ├── dustin │ │ └── go-humanize │ │ │ ├── humanize.go │ │ │ ├── ordinals.go │ │ │ ├── ftoa.go │ │ │ ├── big.go │ │ │ ├── commaf.go │ │ │ ├── LICENSE │ │ │ ├── comma.go │ │ │ ├── si.go │ │ │ ├── bytes.go │ │ │ ├── README.markdown │ │ │ ├── times.go │ │ │ ├── bigbytes.go │ │ │ └── number.go │ ├── fatih │ │ └── color │ │ │ ├── LICENSE.md │ │ │ ├── doc.go │ │ │ └── README.md │ └── shawnsmithdev │ │ └── zermelo │ │ ├── LICENSE │ │ ├── zuint │ │ └── zuint.go │ │ ├── zuint32 │ │ └── zuint32.go │ │ ├── zuint64 │ │ └── zuint64.go │ │ ├── zint64 │ │ └── zint64.go │ │ ├── zint32 │ │ └── zint32.go │ │ ├── zint │ │ └── zint.go │ │ ├── zfloat64 │ │ └── zfloat64.go │ │ ├── zfloat32 │ │ └── zfloat32.go │ │ └── README.md ├── golang.org │ └── x │ │ └── sys │ │ ├── unix │ │ ├── endian_big.go │ │ ├── endian_little.go │ │ ├── constants.go │ │ ├── syscall_linux_amd64_gc.go │ │ ├── pagesize_unix.go │ │ ├── flock_linux_32bit.go │ │ ├── asm_solaris_amd64.s │ │ ├── gccgo_linux_amd64.go │ │ ├── syscall_linux_gc.go │ │ ├── race0.go │ │ ├── syscall_unix_gc.go │ │ ├── dirent.go │ │ ├── str.go │ │ ├── race.go │ │ ├── env_unix.go │ │ ├── flock.go │ │ ├── asm_freebsd_arm.s │ │ ├── asm_netbsd_arm.s │ │ ├── asm_openbsd_arm.s │ │ ├── asm_darwin_386.s │ │ ├── asm_freebsd_386.s │ │ ├── asm_netbsd_386.s │ │ ├── asm_openbsd_386.s │ │ ├── asm_darwin_amd64.s │ │ ├── asm_freebsd_amd64.s │ │ ├── asm_netbsd_amd64.s │ │ ├── asm_openbsd_amd64.s │ │ ├── asm_dragonfly_amd64.s │ │ ├── syscall_solaris_amd64.go │ │ ├── asm_darwin_arm.s │ │ ├── bluetooth_linux.go │ │ ├── asm_darwin_arm64.s │ │ ├── dev_darwin.go │ │ ├── syscall_openbsd_amd64.go │ │ ├── syscall_netbsd_amd64.go │ │ ├── syscall_netbsd_386.go │ │ ├── syscall_netbsd_arm.go │ │ ├── syscall_openbsd_386.go │ │ ├── syscall_openbsd_arm.go │ │ ├── mksysnum_darwin.pl │ │ ├── dev_netbsd.go │ │ ├── dev_openbsd.go │ │ ├── openbsd_pledge.go │ │ ├── dev_freebsd.go │ │ ├── dev_dragonfly.go │ │ ├── sockcmsg_linux.go │ │ ├── mksysnum_dragonfly.pl │ │ ├── mksysnum_freebsd.pl │ │ ├── mksysnum_openbsd.pl │ │ ├── asm_linux_arm64.s │ │ ├── asm_linux_arm.s │ │ ├── asm_linux_s390x.s │ │ ├── zptracearm_linux.go │ │ ├── asm_linux_mipsx.s │ │ ├── asm_linux_mips64x.s │ │ ├── asm_linux_ppc64x.s │ │ ├── syscall_dragonfly_amd64.go │ │ ├── syscall_freebsd_amd64.go │ │ ├── asm_linux_amd64.s │ │ ├── gccgo_c.c │ │ ├── syscall_freebsd_arm.go │ │ ├── syscall_freebsd_386.go │ │ ├── mksysnum_netbsd.pl │ │ ├── zptracemips_linux.go │ │ ├── zptracemipsle_linux.go │ │ ├── asm_linux_386.s │ │ ├── dev_linux.go │ │ ├── syscall_darwin_amd64.go │ │ ├── syscall_darwin_arm64.go │ │ ├── syscall_darwin_arm.go │ │ ├── syscall_darwin_386.go │ │ ├── syscall.go │ │ ├── zptrace386_linux.go │ │ ├── gccgo.go │ │ ├── timestruct.go │ │ ├── sockcmsg_unix.go │ │ ├── affinity_linux.go │ │ └── syscall_linux_ppc64x.go │ │ ├── PATENTS │ │ └── LICENSE └── vendor.json ├── output.go ├── README.md ├── elfread.go ├── util.go └── main.go /vendor/github.com/mattn/go-isatty/doc.go: -------------------------------------------------------------------------------- 1 | // Package isatty implements interface to isatty 2 | package isatty 3 | -------------------------------------------------------------------------------- /vendor/github.com/ianlancetaylor/demangle/README.md: -------------------------------------------------------------------------------- 1 | # github.com/ianlancetaylor/demangle 2 | 3 | A Go package that can be used to demangle C++ symbol names. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_big.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | // +build ppc64 s390x mips mips64 6 | 7 | package unix 8 | 9 | const isBigEndian = true 10 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_others.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | // IsCygwinTerminal return true if the file descriptor is a cygwin or msys2 7 | // terminal. This is also always false on this environment. 8 | func IsCygwinTerminal(fd uintptr) bool { 9 | return false 10 | } 11 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/humanize.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package humanize converts boring ugly numbers to human-friendly strings and back. 3 | 4 | Durations can be turned into strings such as "3 days ago", numbers 5 | representing sizes like 82854982 into useful strings like, "83 MB" or 6 | "79 MiB" (whichever you prefer). 7 | */ 8 | package humanize 9 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_little.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | // +build 386 amd64 amd64p32 arm arm64 ppc64le mipsle mips64le 6 | 7 | package unix 8 | 9 | const isBigEndian = false 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/constants.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | const ( 10 | R_OK = 0x4 11 | W_OK = 0x2 12 | X_OK = 0x1 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_amd64_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,linux 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | //go:noescape 13 | func gettimeofday(tv *Timeval) (err syscall.Errno) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/pagesize_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // For Unix, get the pagesize from the runtime. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getpagesize() int { 14 | return syscall.Getpagesize() 15 | } 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/flock_linux_32bit.go: -------------------------------------------------------------------------------- 1 | // +build linux,386 linux,arm linux,mips linux,mipsle 2 | 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | package unix 8 | 9 | func init() { 10 | // On 32-bit Linux systems, the fcntl syscall that matches Go's 11 | // Flock_t type is SYS_FCNTL64, not SYS_FCNTL. 12 | fcntl64Syscall = SYS_FCNTL64 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_solaris.go: -------------------------------------------------------------------------------- 1 | // +build solaris 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "golang.org/x/sys/unix" 8 | ) 9 | 10 | // IsTerminal returns true if the given file descriptor is a terminal. 11 | // see: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libbc/libc/gen/common/isatty.c 12 | func IsTerminal(fd uintptr) bool { 13 | var termio unix.Termio 14 | err := unix.IoctlSetTermio(int(fd), unix.TCGETA, &termio) 15 | return err == nil 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/ordinals.go: -------------------------------------------------------------------------------- 1 | package humanize 2 | 3 | import "strconv" 4 | 5 | // Ordinal gives you the input number in a rank/ordinal format. 6 | // 7 | // Ordinal(3) -> 3rd 8 | func Ordinal(x int) string { 9 | suffix := "th" 10 | switch x % 10 { 11 | case 1: 12 | if x%100 != 11 { 13 | suffix = "st" 14 | } 15 | case 2: 16 | if x%100 != 12 { 17 | suffix = "nd" 18 | } 19 | case 3: 20 | if x%100 != 13 { 21 | suffix = "rd" 22 | } 23 | } 24 | return strconv.Itoa(x) + suffix 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_linux.go: -------------------------------------------------------------------------------- 1 | // +build linux 2 | // +build !appengine,!ppc64,!ppc64le 3 | 4 | package isatty 5 | 6 | import ( 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | const ioctlReadTermios = syscall.TCGETS 12 | 13 | // IsTerminal return true if the file descriptor is terminal. 14 | func IsTerminal(fd uintptr) bool { 15 | var termios syscall.Termios 16 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 17 | return err == 0 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package isatty 4 | 5 | // IsTerminal returns true if the file descriptor is terminal which 6 | // is always false on on appengine classic which is a sandboxed PaaS. 7 | func IsTerminal(fd uintptr) bool { 8 | return false 9 | } 10 | 11 | // IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2 12 | // terminal. This is also always false on this environment. 13 | func IsCygwinTerminal(fd uintptr) bool { 14 | return false 15 | } 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_solaris_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go 11 | // 12 | 13 | TEXT ·sysvicall6(SB),NOSPLIT,$0-88 14 | JMP syscall·sysvicall6(SB) 15 | 16 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-88 17 | JMP syscall·rawSysvicall6(SB) 18 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/ftoa.go: -------------------------------------------------------------------------------- 1 | package humanize 2 | 3 | import "strconv" 4 | 5 | func stripTrailingZeros(s string) string { 6 | offset := len(s) - 1 7 | for offset > 0 { 8 | if s[offset] == '.' { 9 | offset-- 10 | break 11 | } 12 | if s[offset] != '0' { 13 | break 14 | } 15 | offset-- 16 | } 17 | return s[:offset+1] 18 | } 19 | 20 | // Ftoa converts a float to a string with no trailing zeros. 21 | func Ftoa(num float64) string { 22 | return stripTrailingZeros(strconv.FormatFloat(num, 'f', 6, 64)) 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd openbsd netbsd dragonfly 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | const ioctlReadTermios = syscall.TIOCGETA 12 | 13 | // IsTerminal return true if the file descriptor is terminal. 14 | func IsTerminal(fd uintptr) bool { 15 | var termios syscall.Termios 16 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 17 | return err == 0 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_linux_ppc64x.go: -------------------------------------------------------------------------------- 1 | // +build linux 2 | // +build ppc64 ppc64le 3 | 4 | package isatty 5 | 6 | import ( 7 | "unsafe" 8 | 9 | syscall "golang.org/x/sys/unix" 10 | ) 11 | 12 | const ioctlReadTermios = syscall.TCGETS 13 | 14 | // IsTerminal return true if the file descriptor is terminal. 15 | func IsTerminal(fd uintptr) bool { 16 | var termios syscall.Termios 17 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 18 | return err == 0 19 | } 20 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo,linux,amd64 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //extern gettimeofday 12 | func realGettimeofday(*Timeval, *byte) int32 13 | 14 | func gettimeofday(tv *Timeval) (err syscall.Errno) { 15 | r := realGettimeofday(tv, nil) 16 | if r < 0 { 17 | return syscall.GetErrno() 18 | } 19 | return 0 20 | } 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux,!gccgo 6 | 7 | package unix 8 | 9 | // SyscallNoError may be used instead of Syscall for syscalls that don't fail. 10 | func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) 11 | 12 | // RawSyscallNoError may be used instead of RawSyscall for syscalls that don't 13 | // fail. 14 | func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/race0.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin,!race linux,!race freebsd,!race netbsd openbsd solaris dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | const raceenabled = false 14 | 15 | func raceAcquire(addr unsafe.Pointer) { 16 | } 17 | 18 | func raceReleaseMerge(addr unsafe.Pointer) { 19 | } 20 | 21 | func raceReadRange(addr unsafe.Pointer, len int) { 22 | } 23 | 24 | func raceWriteRange(addr unsafe.Pointer, len int) { 25 | } 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_unix_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 13 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 14 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 15 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dirent.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // ParseDirent parses up to max directory entries in buf, 12 | // appending the names to names. It returns the number of 13 | // bytes consumed from buf, the number of entries added 14 | // to names, and the new names slice. 15 | func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) { 16 | return syscall.ParseDirent(buf, max, names) 17 | } 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/str.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 10 | if val < 0 { 11 | return "-" + uitoa(uint(-val)) 12 | } 13 | return uitoa(uint(val)) 14 | } 15 | 16 | func uitoa(val uint) string { 17 | var buf [32]byte // big enough for int64 18 | i := len(buf) - 1 19 | for val >= 10 { 20 | buf[i] = byte(val%10 + '0') 21 | i-- 22 | val /= 10 23 | } 24 | buf[i] = byte(val + '0') 25 | return string(buf[i:]) 26 | } 27 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/race.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin,race linux,race freebsd,race 6 | 7 | package unix 8 | 9 | import ( 10 | "runtime" 11 | "unsafe" 12 | ) 13 | 14 | const raceenabled = true 15 | 16 | func raceAcquire(addr unsafe.Pointer) { 17 | runtime.RaceAcquire(addr) 18 | } 19 | 20 | func raceReleaseMerge(addr unsafe.Pointer) { 21 | runtime.RaceReleaseMerge(addr) 22 | } 23 | 24 | func raceReadRange(addr unsafe.Pointer, len int) { 25 | runtime.RaceReadRange(addr, len) 26 | } 27 | 28 | func raceWriteRange(addr unsafe.Pointer, len int) { 29 | runtime.RaceWriteRange(addr, len) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Unix environment variables. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getenv(key string) (value string, found bool) { 14 | return syscall.Getenv(key) 15 | } 16 | 17 | func Setenv(key, value string) error { 18 | return syscall.Setenv(key, value) 19 | } 20 | 21 | func Clearenv() { 22 | syscall.Clearenv() 23 | } 24 | 25 | func Environ() []string { 26 | return syscall.Environ() 27 | } 28 | 29 | func Unsetenv(key string) error { 30 | return syscall.Unsetenv(key) 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/big.go: -------------------------------------------------------------------------------- 1 | package humanize 2 | 3 | import ( 4 | "math/big" 5 | ) 6 | 7 | // order of magnitude (to a max order) 8 | func oomm(n, b *big.Int, maxmag int) (float64, int) { 9 | mag := 0 10 | m := &big.Int{} 11 | for n.Cmp(b) >= 0 { 12 | n.DivMod(n, b, m) 13 | mag++ 14 | if mag == maxmag && maxmag >= 0 { 15 | break 16 | } 17 | } 18 | return float64(n.Int64()) + (float64(m.Int64()) / float64(b.Int64())), mag 19 | } 20 | 21 | // total order of magnitude 22 | // (same as above, but with no upper limit) 23 | func oom(n, b *big.Int) (float64, int) { 24 | mag := 0 25 | m := &big.Int{} 26 | for n.Cmp(b) >= 0 { 27 | n.DivMod(n, b, m) 28 | mag++ 29 | } 30 | return float64(n.Int64()) + (float64(m.Int64()) / float64(b.Int64())), mag 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/colorable_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package colorable 4 | 5 | import ( 6 | "io" 7 | "os" 8 | 9 | _ "github.com/mattn/go-isatty" 10 | ) 11 | 12 | // NewColorable return new instance of Writer which handle escape sequence. 13 | func NewColorable(file *os.File) io.Writer { 14 | if file == nil { 15 | panic("nil passed instead of *os.File to NewColorable()") 16 | } 17 | 18 | return file 19 | } 20 | 21 | // NewColorableStdout return new instance of Writer which handle escape sequence for stdout. 22 | func NewColorableStdout() io.Writer { 23 | return os.Stdout 24 | } 25 | 26 | // NewColorableStderr return new instance of Writer which handle escape sequence for stderr. 27 | func NewColorableStderr() io.Writer { 28 | return os.Stderr 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/flock.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux 12 | // systems by flock_linux_32bit.go to be SYS_FCNTL64. 13 | var fcntl64Syscall uintptr = SYS_FCNTL 14 | 15 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 16 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 17 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 18 | if errno == 0 { 19 | return nil 20 | } 21 | return errno 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/colorable_others.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | // +build !appengine 3 | 4 | package colorable 5 | 6 | import ( 7 | "io" 8 | "os" 9 | 10 | _ "github.com/mattn/go-isatty" 11 | ) 12 | 13 | // NewColorable return new instance of Writer which handle escape sequence. 14 | func NewColorable(file *os.File) io.Writer { 15 | if file == nil { 16 | panic("nil passed instead of *os.File to NewColorable()") 17 | } 18 | 19 | return file 20 | } 21 | 22 | // NewColorableStdout return new instance of Writer which handle escape sequence for stdout. 23 | func NewColorableStdout() io.Writer { 24 | return os.Stdout 25 | } 26 | 27 | // NewColorableStderr return new instance of Writer which handle escape sequence for stderr. 28 | func NewColorableStderr() io.Writer { 29 | return os.Stderr 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, DragonFly 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-64 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-88 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-112 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-64 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-88 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,solaris 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: usec} 15 | } 16 | 17 | func (iov *Iovec) SetLen(length int) { 18 | iov.Len = uint64(length) 19 | } 20 | 21 | func (cmsg *Cmsghdr) SetLen(length int) { 22 | cmsg.Len = uint32(length) 23 | } 24 | 25 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 26 | // TODO(aram): implement this, see issue 5847. 27 | panic("unimplemented") 28 | } 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for ARM, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-28 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/bluetooth_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Bluetooth sockets and messages 6 | 7 | package unix 8 | 9 | // Bluetooth Protocols 10 | const ( 11 | BTPROTO_L2CAP = 0 12 | BTPROTO_HCI = 1 13 | BTPROTO_SCO = 2 14 | BTPROTO_RFCOMM = 3 15 | BTPROTO_BNEP = 4 16 | BTPROTO_CMTP = 5 17 | BTPROTO_HIDP = 6 18 | BTPROTO_AVDTP = 7 19 | ) 20 | 21 | const ( 22 | HCI_CHANNEL_RAW = 0 23 | HCI_CHANNEL_USER = 1 24 | HCI_CHANNEL_MONITOR = 2 25 | HCI_CHANNEL_CONTROL = 3 26 | ) 27 | 28 | // Socketoption Level 29 | const ( 30 | SOL_BLUETOOTH = 0x112 31 | SOL_HCI = 0x0 32 | SOL_L2CAP = 0x6 33 | SOL_RFCOMM = 0x12 34 | SOL_SCO = 0x11 35 | ) 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm64,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for AMD64, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-56 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in Darwin's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of a Darwin device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev >> 24) & 0xff) 13 | } 14 | 15 | // Minor returns the minor component of a Darwin device number. 16 | func Minor(dev uint64) uint32 { 17 | return uint32(dev & 0xffffff) 18 | } 19 | 20 | // Mkdev returns a Darwin device number generated from the given major and minor 21 | // components. 22 | func Mkdev(major, minor uint32) uint64 { 23 | return (uint64(major) << 24) | uint64(minor) 24 | } 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: usec} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint64(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint64(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint64(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint64(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/commaf.go: -------------------------------------------------------------------------------- 1 | // +build go1.6 2 | 3 | package humanize 4 | 5 | import ( 6 | "bytes" 7 | "math/big" 8 | "strings" 9 | ) 10 | 11 | // BigCommaf produces a string form of the given big.Float in base 10 12 | // with commas after every three orders of magnitude. 13 | func BigCommaf(v *big.Float) string { 14 | buf := &bytes.Buffer{} 15 | if v.Sign() < 0 { 16 | buf.Write([]byte{'-'}) 17 | v.Abs(v) 18 | } 19 | 20 | comma := []byte{','} 21 | 22 | parts := strings.Split(v.Text('f', -1), ".") 23 | pos := 0 24 | if len(parts[0])%3 != 0 { 25 | pos += len(parts[0]) % 3 26 | buf.WriteString(parts[0][:pos]) 27 | buf.Write(comma) 28 | } 29 | for ; pos < len(parts[0]); pos += 3 { 30 | buf.WriteString(parts[0][pos : pos+3]) 31 | buf.Write(comma) 32 | } 33 | buf.Truncate(buf.Len() - 1) 34 | 35 | if len(parts) > 1 { 36 | buf.Write([]byte{'.'}) 37 | buf.WriteString(parts[1]) 38 | } 39 | return buf.String() 40 | } 41 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mksysnum_darwin.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # Copyright 2009 The Go Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style 4 | # license that can be found in the LICENSE file. 5 | # 6 | # Generate system call table for Darwin from sys/syscall.h 7 | 8 | use strict; 9 | 10 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") { 11 | print STDERR "GOARCH or GOOS not defined in environment\n"; 12 | exit 1; 13 | } 14 | 15 | my $command = "mksysnum_darwin.pl " . join(' ', @ARGV); 16 | 17 | print <){ 29 | if(/^#define\s+SYS_(\w+)\s+([0-9]+)/){ 30 | my $name = $1; 31 | my $num = $2; 32 | $name =~ y/a-z/A-Z/; 33 | print " SYS_$name = $num;" 34 | } 35 | } 36 | 37 | print <> 8) 13 | } 14 | 15 | // Minor returns the minor component of a NetBSD device number. 16 | func Minor(dev uint64) uint32 { 17 | minor := uint32((dev & 0x000000ff) >> 0) 18 | minor |= uint32((dev & 0xfff00000) >> 12) 19 | return minor 20 | } 21 | 22 | // Mkdev returns a NetBSD device number generated from the given major and minor 23 | // components. 24 | func Mkdev(major, minor uint32) uint64 { 25 | dev := (uint64(major) << 8) & 0x000fff00 26 | dev |= (uint64(minor) << 12) & 0xfff00000 27 | dev |= (uint64(minor) << 0) & 0x000000ff 28 | return dev 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_openbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in OpenBSD's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of an OpenBSD device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev & 0x0000ff00) >> 8) 13 | } 14 | 15 | // Minor returns the minor component of an OpenBSD device number. 16 | func Minor(dev uint64) uint32 { 17 | minor := uint32((dev & 0x000000ff) >> 0) 18 | minor |= uint32((dev & 0xffff0000) >> 8) 19 | return minor 20 | } 21 | 22 | // Mkdev returns an OpenBSD device number generated from the given major and minor 23 | // components. 24 | func Mkdev(major, minor uint32) uint64 { 25 | dev := (uint64(major) << 8) & 0x0000ff00 26 | dev |= (uint64(minor) << 8) & 0xffff0000 27 | dev |= (uint64(minor) << 0) & 0x000000ff 28 | return dev 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/openbsd_pledge.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build openbsd 6 | // +build 386 amd64 arm 7 | 8 | package unix 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | const ( 16 | SYS_PLEDGE = 108 17 | ) 18 | 19 | // Pledge implements the pledge syscall. For more information see pledge(2). 20 | func Pledge(promises string, paths []string) error { 21 | promisesPtr, err := syscall.BytePtrFromString(promises) 22 | if err != nil { 23 | return err 24 | } 25 | promisesUnsafe, pathsUnsafe := unsafe.Pointer(promisesPtr), unsafe.Pointer(nil) 26 | if paths != nil { 27 | var pathsPtr []*byte 28 | if pathsPtr, err = syscall.SlicePtrFromStrings(paths); err != nil { 29 | return err 30 | } 31 | pathsUnsafe = unsafe.Pointer(&pathsPtr[0]) 32 | } 33 | _, _, e := syscall.Syscall(SYS_PLEDGE, uintptr(promisesUnsafe), uintptr(pathsUnsafe), 0) 34 | if e != 0 { 35 | return e 36 | } 37 | return nil 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) Yasuhiro MATSUMOTO 2 | 3 | MIT License (Expat) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_freebsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in FreeBSD's sys/types.h header. 7 | // 8 | // The information below is extracted and adapted from sys/types.h: 9 | // 10 | // Minor gives a cookie instead of an index since in order to avoid changing the 11 | // meanings of bits 0-15 or wasting time and space shifting bits 16-31 for 12 | // devices that don't use them. 13 | 14 | package unix 15 | 16 | // Major returns the major component of a FreeBSD device number. 17 | func Major(dev uint64) uint32 { 18 | return uint32((dev >> 8) & 0xff) 19 | } 20 | 21 | // Minor returns the minor component of a FreeBSD device number. 22 | func Minor(dev uint64) uint32 { 23 | return uint32(dev & 0xffff00ff) 24 | } 25 | 26 | // Mkdev returns a FreeBSD device number generated from the given major and 27 | // minor components. 28 | func Mkdev(major, minor uint32) uint64 { 29 | return (uint64(major) << 8) | uint64(minor) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/fatih/color/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Fatih Arslan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /vendor/github.com/shawnsmithdev/zermelo/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Shawn Smith 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_dragonfly.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in Dragonfly's sys/types.h header. 7 | // 8 | // The information below is extracted and adapted from sys/types.h: 9 | // 10 | // Minor gives a cookie instead of an index since in order to avoid changing the 11 | // meanings of bits 0-15 or wasting time and space shifting bits 16-31 for 12 | // devices that don't use them. 13 | 14 | package unix 15 | 16 | // Major returns the major component of a DragonFlyBSD device number. 17 | func Major(dev uint64) uint32 { 18 | return uint32((dev >> 8) & 0xff) 19 | } 20 | 21 | // Minor returns the minor component of a DragonFlyBSD device number. 22 | func Minor(dev uint64) uint32 { 23 | return uint32(dev & 0xffff00ff) 24 | } 25 | 26 | // Mkdev returns a DragonFlyBSD device number generated from the given major and 27 | // minor components. 28 | func Mkdev(major, minor uint32) uint64 { 29 | return (uint64(major) << 8) | uint64(minor) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Yasuhiro Matsumoto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/noncolorable.go: -------------------------------------------------------------------------------- 1 | package colorable 2 | 3 | import ( 4 | "bytes" 5 | "io" 6 | ) 7 | 8 | // NonColorable hold writer but remove escape sequence. 9 | type NonColorable struct { 10 | out io.Writer 11 | } 12 | 13 | // NewNonColorable return new instance of Writer which remove escape sequence from Writer. 14 | func NewNonColorable(w io.Writer) io.Writer { 15 | return &NonColorable{out: w} 16 | } 17 | 18 | // Write write data on console 19 | func (w *NonColorable) Write(data []byte) (n int, err error) { 20 | er := bytes.NewReader(data) 21 | var bw [1]byte 22 | loop: 23 | for { 24 | c1, err := er.ReadByte() 25 | if err != nil { 26 | break loop 27 | } 28 | if c1 != 0x1b { 29 | bw[0] = c1 30 | w.out.Write(bw[:]) 31 | continue 32 | } 33 | c2, err := er.ReadByte() 34 | if err != nil { 35 | break loop 36 | } 37 | if c2 != 0x5b { 38 | continue 39 | } 40 | 41 | var buf bytes.Buffer 42 | for { 43 | c, err := er.ReadByte() 44 | if err != nil { 45 | break loop 46 | } 47 | if ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '@' { 48 | break 49 | } 50 | buf.Write([]byte(string(c))) 51 | } 52 | } 53 | 54 | return len(data), nil 55 | } 56 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2005-2008 Dustin Sallings 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | 21 | 22 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sockcmsg_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Socket control messages 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // UnixCredentials encodes credentials into a socket control message 12 | // for sending to another process. This can be used for 13 | // authentication. 14 | func UnixCredentials(ucred *Ucred) []byte { 15 | b := make([]byte, CmsgSpace(SizeofUcred)) 16 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 17 | h.Level = SOL_SOCKET 18 | h.Type = SCM_CREDENTIALS 19 | h.SetLen(CmsgLen(SizeofUcred)) 20 | *((*Ucred)(cmsgData(h))) = *ucred 21 | return b 22 | } 23 | 24 | // ParseUnixCredentials decodes a socket control message that contains 25 | // credentials in a Ucred structure. To receive such a message, the 26 | // SO_PASSCRED option must be enabled on the socket. 27 | func ParseUnixCredentials(m *SocketControlMessage) (*Ucred, error) { 28 | if m.Header.Level != SOL_SOCKET { 29 | return nil, EINVAL 30 | } 31 | if m.Header.Type != SCM_CREDENTIALS { 32 | return nil, EINVAL 33 | } 34 | ucred := *(*Ucred)(unsafe.Pointer(&m.Data[0])) 35 | return &ucred, nil 36 | } 37 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mksysnum_dragonfly.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # Copyright 2009 The Go Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style 4 | # license that can be found in the LICENSE file. 5 | # 6 | # Generate system call table for DragonFly from master list 7 | # (for example, /usr/src/sys/kern/syscalls.master). 8 | 9 | use strict; 10 | 11 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") { 12 | print STDERR "GOARCH or GOOS not defined in environment\n"; 13 | exit 1; 14 | } 15 | 16 | my $command = "mksysnum_dragonfly.pl " . join(' ', @ARGV); 17 | 18 | print <){ 30 | if(/^([0-9]+)\s+STD\s+({ \S+\s+(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $2; 33 | my $name = "SYS_$3"; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print <){ 30 | if(/^([0-9]+)\s+\S+\s+STD\s+({ \S+\s+(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $2; 33 | my $name = "SYS_$3"; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print <){ 30 | if(/^([0-9]+)\s+STD\s+(NOLOCK\s+)?({ \S+\s+\*?(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $3; 33 | my $name = $4; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print < 8 | #include 9 | #include 10 | 11 | #define _STRINGIFY2_(x) #x 12 | #define _STRINGIFY_(x) _STRINGIFY2_(x) 13 | #define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__) 14 | 15 | // Call syscall from C code because the gccgo support for calling from 16 | // Go to C does not support varargs functions. 17 | 18 | struct ret { 19 | uintptr_t r; 20 | uintptr_t err; 21 | }; 22 | 23 | struct ret 24 | gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 25 | { 26 | struct ret r; 27 | 28 | errno = 0; 29 | r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 30 | r.err = errno; 31 | return r; 32 | } 33 | 34 | uintptr_t 35 | gccgoRealSyscallNoError(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 36 | { 37 | return syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 38 | } 39 | 40 | // Define the use function in C so that it is not inlined. 41 | 42 | extern void use(void *) __asm__ (GOSYM_PREFIX GOPKGPATH ".use") __attribute__((noinline)); 43 | 44 | void 45 | use(void *p __attribute__ ((unused))) 46 | { 47 | } 48 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: int32(nsec)} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: int32(usec)} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint32(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint32(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mksysnum_netbsd.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # Copyright 2009 The Go Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style 4 | # license that can be found in the LICENSE file. 5 | # 6 | # Generate system call table for OpenBSD from master list 7 | # (for example, /usr/src/sys/kern/syscalls.master). 8 | 9 | use strict; 10 | 11 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") { 12 | print STDERR "GOARCH or GOOS not defined in environment\n"; 13 | exit 1; 14 | } 15 | 16 | my $command = "mksysnum_netbsd.pl " . join(' ', @ARGV); 17 | 18 | print <){ 31 | if($line =~ /^(.*)\\$/) { 32 | # Handle continuation 33 | $line = $1; 34 | $_ =~ s/^\s+//; 35 | $line .= $_; 36 | } else { 37 | # New line 38 | $line = $_; 39 | } 40 | next if $line =~ /\\$/; 41 | if($line =~ /^([0-9]+)\s+((STD)|(NOERR))\s+(RUMP\s+)?({\s+\S+\s*\*?\s*\|(\S+)\|(\S*)\|(\w+).*\s+})(\s+(\S+))?$/) { 42 | my $num = $1; 43 | my $proto = $6; 44 | my $compat = $8; 45 | my $name = "$7_$9"; 46 | 47 | $name = "$7_$11" if $11 ne ''; 48 | $name =~ y/a-z/A-Z/; 49 | 50 | if($compat eq '' || $compat eq '13' || $compat eq '30' || $compat eq '50') { 51 | print " $name = $num; // $proto\n"; 52 | } 53 | } 54 | } 55 | 56 | print <> 8) 23 | major |= uint32((dev & 0xfffff00000000000) >> 32) 24 | return major 25 | } 26 | 27 | // Minor returns the minor component of a Linux device number. 28 | func Minor(dev uint64) uint32 { 29 | minor := uint32((dev & 0x00000000000000ff) >> 0) 30 | minor |= uint32((dev & 0x00000ffffff00000) >> 12) 31 | return minor 32 | } 33 | 34 | // Mkdev returns a Linux device number generated from the given major and minor 35 | // components. 36 | func Mkdev(major, minor uint32) uint64 { 37 | dev := (uint64(major) & 0x00000fff) << 8 38 | dev |= (uint64(major) & 0xfffff000) << 32 39 | dev |= (uint64(minor) & 0x000000ff) << 0 40 | dev |= (uint64(minor) & 0xffffff00) << 12 41 | return dev 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: int32(usec)} 20 | } 21 | 22 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 23 | func Gettimeofday(tv *Timeval) (err error) { 24 | // The tv passed to gettimeofday must be non-nil 25 | // but is otherwise unused. The answers come back 26 | // in the two registers. 27 | sec, usec, err := gettimeofday(tv) 28 | tv.Sec = sec 29 | tv.Usec = usec 30 | return err 31 | } 32 | 33 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 34 | k.Ident = uint64(fd) 35 | k.Filter = int16(mode) 36 | k.Flags = uint16(flags) 37 | } 38 | 39 | func (iov *Iovec) SetLen(length int) { 40 | iov.Len = uint64(length) 41 | } 42 | 43 | func (msghdr *Msghdr) SetControllen(length int) { 44 | msghdr.Controllen = uint32(length) 45 | } 46 | 47 | func (cmsg *Cmsghdr) SetLen(length int) { 48 | cmsg.Len = uint32(length) 49 | } 50 | 51 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 52 | var length = uint64(count) 53 | 54 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 55 | 56 | written = int(length) 57 | 58 | if e1 != 0 { 59 | err = e1 60 | } 61 | return 62 | } 63 | 64 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 65 | 66 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 67 | // of darwin/amd64 the syscall is called sysctl instead of __sysctl. 68 | const SYS___SYSCTL = SYS_SYSCTL 69 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: int32(usec)} 20 | } 21 | 22 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 23 | func Gettimeofday(tv *Timeval) (err error) { 24 | // The tv passed to gettimeofday must be non-nil 25 | // but is otherwise unused. The answers come back 26 | // in the two registers. 27 | sec, usec, err := gettimeofday(tv) 28 | tv.Sec = sec 29 | tv.Usec = usec 30 | return err 31 | } 32 | 33 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 34 | k.Ident = uint64(fd) 35 | k.Filter = int16(mode) 36 | k.Flags = uint16(flags) 37 | } 38 | 39 | func (iov *Iovec) SetLen(length int) { 40 | iov.Len = uint64(length) 41 | } 42 | 43 | func (msghdr *Msghdr) SetControllen(length int) { 44 | msghdr.Controllen = uint32(length) 45 | } 46 | 47 | func (cmsg *Cmsghdr) SetLen(length int) { 48 | cmsg.Len = uint32(length) 49 | } 50 | 51 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 52 | var length = uint64(count) 53 | 54 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 55 | 56 | written = int(length) 57 | 58 | if e1 != 0 { 59 | err = e1 60 | } 61 | return 62 | } 63 | 64 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 65 | 66 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 67 | // of darwin/arm64 the syscall is called sysctl instead of __sysctl. 68 | const SYS___SYSCTL = SYS_SYSCTL 69 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package unix 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | func setTimespec(sec, nsec int64) Timespec { 13 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 14 | } 15 | 16 | func setTimeval(sec, usec int64) Timeval { 17 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 18 | } 19 | 20 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 21 | func Gettimeofday(tv *Timeval) (err error) { 22 | // The tv passed to gettimeofday must be non-nil 23 | // but is otherwise unused. The answers come back 24 | // in the two registers. 25 | sec, usec, err := gettimeofday(tv) 26 | tv.Sec = int32(sec) 27 | tv.Usec = int32(usec) 28 | return err 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint32(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint32(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var length = uint64(count) 51 | 52 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 53 | 54 | written = int(length) 55 | 56 | if e1 != 0 { 57 | err = e1 58 | } 59 | return 60 | } 61 | 62 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 63 | 64 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 65 | // of darwin/arm the syscall is called sysctl instead of __sysctl. 66 | const SYS___SYSCTL = SYS_SYSCTL 67 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 20 | } 21 | 22 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 23 | func Gettimeofday(tv *Timeval) (err error) { 24 | // The tv passed to gettimeofday must be non-nil 25 | // but is otherwise unused. The answers come back 26 | // in the two registers. 27 | sec, usec, err := gettimeofday(tv) 28 | tv.Sec = int32(sec) 29 | tv.Usec = int32(usec) 30 | return err 31 | } 32 | 33 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 34 | k.Ident = uint32(fd) 35 | k.Filter = int16(mode) 36 | k.Flags = uint16(flags) 37 | } 38 | 39 | func (iov *Iovec) SetLen(length int) { 40 | iov.Len = uint32(length) 41 | } 42 | 43 | func (msghdr *Msghdr) SetControllen(length int) { 44 | msghdr.Controllen = uint32(length) 45 | } 46 | 47 | func (cmsg *Cmsghdr) SetLen(length int) { 48 | cmsg.Len = uint32(length) 49 | } 50 | 51 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 52 | var length = uint64(count) 53 | 54 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 55 | 56 | written = int(length) 57 | 58 | if e1 != 0 { 59 | err = e1 60 | } 61 | return 62 | } 63 | 64 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 65 | 66 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 67 | // of darwin/386 the syscall is called sysctl instead of __sysctl. 68 | const SYS___SYSCTL = SYS_SYSCTL 69 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Package unix contains an interface to the low-level operating system 8 | // primitives. OS details vary depending on the underlying system, and 9 | // by default, godoc will display OS-specific documentation for the current 10 | // system. If you want godoc to display OS documentation for another 11 | // system, set $GOOS and $GOARCH to the desired system. For example, if 12 | // you want to view documentation for freebsd/arm on linux/amd64, set $GOOS 13 | // to freebsd and $GOARCH to arm. 14 | // The primary use of this package is inside other packages that provide a more 15 | // portable interface to the system, such as "os", "time" and "net". Use 16 | // those packages rather than this one if you can. 17 | // For details of the functions and data types in this package consult 18 | // the manuals for the appropriate operating system. 19 | // These calls return err == nil to indicate success; otherwise 20 | // err represents an operating system error describing the failure and 21 | // holds a value of type syscall.Errno. 22 | package unix // import "golang.org/x/sys/unix" 23 | 24 | // ByteSliceFromString returns a NUL-terminated slice of bytes 25 | // containing the text of s. If s contains a NUL byte at any 26 | // location, it returns (nil, EINVAL). 27 | func ByteSliceFromString(s string) ([]byte, error) { 28 | for i := 0; i < len(s); i++ { 29 | if s[i] == 0 { 30 | return nil, EINVAL 31 | } 32 | } 33 | a := make([]byte, len(s)+1) 34 | copy(a, s) 35 | return a, nil 36 | } 37 | 38 | // BytePtrFromString returns a pointer to a NUL-terminated array of 39 | // bytes containing the text of s. If s contains a NUL byte at any 40 | // location, it returns (nil, EINVAL). 41 | func BytePtrFromString(s string) (*byte, error) { 42 | a, err := ByteSliceFromString(s) 43 | if err != nil { 44 | return nil, err 45 | } 46 | return &a[0], nil 47 | } 48 | 49 | // Single-word zero for use when we need a valid pointer to 0 bytes. 50 | // See mkunix.pl. 51 | var _zero uintptr 52 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptrace386_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair(386, amd64). DO NOT EDIT. 2 | 3 | // +build linux 4 | // +build 386 amd64 5 | 6 | package unix 7 | 8 | import "unsafe" 9 | 10 | // PtraceRegs386 is the registers used by 386 binaries. 11 | type PtraceRegs386 struct { 12 | Ebx int32 13 | Ecx int32 14 | Edx int32 15 | Esi int32 16 | Edi int32 17 | Ebp int32 18 | Eax int32 19 | Xds int32 20 | Xes int32 21 | Xfs int32 22 | Xgs int32 23 | Orig_eax int32 24 | Eip int32 25 | Xcs int32 26 | Eflags int32 27 | Esp int32 28 | Xss int32 29 | } 30 | 31 | // PtraceGetRegs386 fetches the registers used by 386 binaries. 32 | func PtraceGetRegs386(pid int, regsout *PtraceRegs386) error { 33 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 34 | } 35 | 36 | // PtraceSetRegs386 sets the registers used by 386 binaries. 37 | func PtraceSetRegs386(pid int, regs *PtraceRegs386) error { 38 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 39 | } 40 | 41 | // PtraceRegsAmd64 is the registers used by amd64 binaries. 42 | type PtraceRegsAmd64 struct { 43 | R15 uint64 44 | R14 uint64 45 | R13 uint64 46 | R12 uint64 47 | Rbp uint64 48 | Rbx uint64 49 | R11 uint64 50 | R10 uint64 51 | R9 uint64 52 | R8 uint64 53 | Rax uint64 54 | Rcx uint64 55 | Rdx uint64 56 | Rsi uint64 57 | Rdi uint64 58 | Orig_rax uint64 59 | Rip uint64 60 | Cs uint64 61 | Eflags uint64 62 | Rsp uint64 63 | Ss uint64 64 | Fs_base uint64 65 | Gs_base uint64 66 | Ds uint64 67 | Es uint64 68 | Fs uint64 69 | Gs uint64 70 | } 71 | 72 | // PtraceGetRegsAmd64 fetches the registers used by amd64 binaries. 73 | func PtraceGetRegsAmd64(pid int, regsout *PtraceRegsAmd64) error { 74 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 75 | } 76 | 77 | // PtraceSetRegsAmd64 sets the registers used by amd64 binaries. 78 | func PtraceSetRegsAmd64(pid int, regs *PtraceRegsAmd64) error { 79 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 80 | } 81 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // We can't use the gc-syntax .s files for gccgo. On the plus side 12 | // much of the functionality can be written directly in Go. 13 | 14 | //extern gccgoRealSyscallNoError 15 | func realSyscallNoError(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r uintptr) 16 | 17 | //extern gccgoRealSyscall 18 | func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr) 19 | 20 | func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) { 21 | syscall.Entersyscall() 22 | r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 23 | syscall.Exitsyscall() 24 | return r, 0 25 | } 26 | 27 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 28 | syscall.Entersyscall() 29 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 30 | syscall.Exitsyscall() 31 | return r, 0, syscall.Errno(errno) 32 | } 33 | 34 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 35 | syscall.Entersyscall() 36 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 37 | syscall.Exitsyscall() 38 | return r, 0, syscall.Errno(errno) 39 | } 40 | 41 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) { 42 | syscall.Entersyscall() 43 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9) 44 | syscall.Exitsyscall() 45 | return r, 0, syscall.Errno(errno) 46 | } 47 | 48 | func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) { 49 | r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 50 | return r, 0 51 | } 52 | 53 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 54 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 55 | return r, 0, syscall.Errno(errno) 56 | } 57 | 58 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 59 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 60 | return r, 0, syscall.Errno(errno) 61 | } 62 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "strings" 8 | "syscall" 9 | "unicode/utf16" 10 | "unsafe" 11 | ) 12 | 13 | const ( 14 | fileNameInfo uintptr = 2 15 | fileTypePipe = 3 16 | ) 17 | 18 | var ( 19 | kernel32 = syscall.NewLazyDLL("kernel32.dll") 20 | procGetConsoleMode = kernel32.NewProc("GetConsoleMode") 21 | procGetFileInformationByHandleEx = kernel32.NewProc("GetFileInformationByHandleEx") 22 | procGetFileType = kernel32.NewProc("GetFileType") 23 | ) 24 | 25 | func init() { 26 | // Check if GetFileInformationByHandleEx is available. 27 | if procGetFileInformationByHandleEx.Find() != nil { 28 | procGetFileInformationByHandleEx = nil 29 | } 30 | } 31 | 32 | // IsTerminal return true if the file descriptor is terminal. 33 | func IsTerminal(fd uintptr) bool { 34 | var st uint32 35 | r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, fd, uintptr(unsafe.Pointer(&st)), 0) 36 | return r != 0 && e == 0 37 | } 38 | 39 | // Check pipe name is used for cygwin/msys2 pty. 40 | // Cygwin/MSYS2 PTY has a name like: 41 | // \{cygwin,msys}-XXXXXXXXXXXXXXXX-ptyN-{from,to}-master 42 | func isCygwinPipeName(name string) bool { 43 | token := strings.Split(name, "-") 44 | if len(token) < 5 { 45 | return false 46 | } 47 | 48 | if token[0] != `\msys` && token[0] != `\cygwin` { 49 | return false 50 | } 51 | 52 | if token[1] == "" { 53 | return false 54 | } 55 | 56 | if !strings.HasPrefix(token[2], "pty") { 57 | return false 58 | } 59 | 60 | if token[3] != `from` && token[3] != `to` { 61 | return false 62 | } 63 | 64 | if token[4] != "master" { 65 | return false 66 | } 67 | 68 | return true 69 | } 70 | 71 | // IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2 72 | // terminal. 73 | func IsCygwinTerminal(fd uintptr) bool { 74 | if procGetFileInformationByHandleEx == nil { 75 | return false 76 | } 77 | 78 | // Cygwin/msys's pty is a pipe. 79 | ft, _, e := syscall.Syscall(procGetFileType.Addr(), 1, fd, 0, 0) 80 | if ft != fileTypePipe || e != 0 { 81 | return false 82 | } 83 | 84 | var buf [2 + syscall.MAX_PATH]uint16 85 | r, _, e := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(), 86 | 4, fd, fileNameInfo, uintptr(unsafe.Pointer(&buf)), 87 | uintptr(len(buf)*2), 0, 0) 88 | if r == 0 || e != 0 { 89 | return false 90 | } 91 | 92 | l := *(*uint32)(unsafe.Pointer(&buf)) 93 | return isCygwinPipeName(string(utf16.Decode(buf[2 : 2+l/2]))) 94 | } 95 | -------------------------------------------------------------------------------- /output.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/json" 5 | "encoding/xml" 6 | "errors" 7 | "os" 8 | "strings" 9 | ) 10 | 11 | // WriterFormat to emulate an emum to make my constants nicer 12 | type WriterFormat int32 13 | 14 | // OutputStructure is the structure of that data that will be output 15 | type OutputStructure struct { 16 | Content string `json:"content" xml:"content"` 17 | Offset uint64 `json:"offset" xml:"offset"` 18 | } 19 | 20 | // OutWriter is the context that the output module utilises 21 | type OutWriter struct { 22 | fd *os.File 23 | format WriterFormat 24 | } 25 | 26 | // Types of formatting that may be used 27 | const ( 28 | JSON WriterFormat = iota 29 | XML 30 | plain 31 | end 32 | ) 33 | 34 | // NewOutWriter creates a new instance of OutWriter 35 | // with the desired format 36 | func NewOutWriter(path string, format WriterFormat) (*OutWriter, error) { 37 | var writer OutWriter 38 | var err error 39 | 40 | if !ValidType(format) { 41 | return nil, errors.New("this output type does not exist") 42 | } 43 | 44 | writer.format = format 45 | 46 | writer.fd, err = os.OpenFile(path, os.O_RDWR|os.O_APPEND|os.O_CREATE, 0777) 47 | if err != nil { 48 | return nil, err 49 | } 50 | 51 | return &writer, nil 52 | } 53 | 54 | // WriteResult appends to the currently opened file 55 | // using the specified format, with the result. 56 | func (o *OutWriter) WriteResult(str string, offset uint64) bool { 57 | output := &OutputStructure{ 58 | Content: str, 59 | Offset: offset, 60 | } 61 | 62 | buf := str 63 | 64 | if o.format == JSON { 65 | j, err := json.Marshal(output) 66 | if err != nil { 67 | return false 68 | } 69 | 70 | buf = string(j) 71 | } else if o.format == XML { 72 | x, err := xml.Marshal(output) 73 | if err != nil { 74 | return false 75 | } 76 | 77 | buf = string(x) 78 | } 79 | 80 | o.fd.WriteString(buf + "\n") 81 | 82 | return true 83 | } 84 | 85 | // OutParseTypeStr converts from a string to a constant type 86 | // default is plaintext output 87 | func OutParseTypeStr(typ string) WriterFormat { 88 | outType := strings.ToUpper(typ) 89 | if outType == "JSON" { 90 | return JSON 91 | } else if outType == "XML" { 92 | return XML 93 | } 94 | 95 | return plain 96 | } 97 | 98 | // ValidType makes sure that the passed type exists 99 | func ValidType(val WriterFormat) bool { 100 | return val < end 101 | } 102 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # elf-strings 2 | 3 | The better `strings` utility for the reverse engineer. 4 | 5 | elf-strings will programmatically read an ELF binary's string sections within a given binary. This is meant to be much like the `strings` UNIX utility, however is purpose built for ELF binaries. 6 | 7 | This means that you can get suitable information about the strings within the binary, such as the section they reside in, the offset in the section, etc.. This utility also has the functionality to 'demangle' C++ symbols, iterate linked libraries and print basic information about the ELF. 8 | 9 | This can prove extremely useful for quickly grabbing strings when analysing a binary. 10 | 11 | # Output 12 | ![alt text](https://i.imgur.com/plIdQCF.png "example of demangled strings") 13 | 14 | # Building 15 | ``` 16 | git clone https://github.com/LloydLabs/elf-strings 17 | cd elf-strings 18 | go build 19 | ``` 20 | 21 | # Arguments 22 | ``` 23 | -binary string 24 | the path to the ELF you wish to parse 25 | -demangle 26 | demangle C++ symbols into their original source identifiers, prettify found C++ symbols (optional) 27 | -hex 28 | output the strings as a hexadecimal literal (optional) 29 | -libs 30 | show the linked libraries in the binary (optional) 31 | -max-count uint 32 | the maximum amount of strings that you wish to be output (optional) 33 | -min uint 34 | the minimum length of the string 35 | -no-color 36 | disable color output in the results 37 | -no-human 38 | don't validate that its a human readable string, this could increase the amount of junk. 39 | -no-info 40 | don't show any information about the binary 41 | -no-trim 42 | disable triming whitespace and trailing newlines 43 | -offset 44 | show the offset of the string in the section (default, recommended) (default true) 45 | -output-file string 46 | the path of the output file that you want to output to (optional) 47 | -output-format string 48 | the format you want to output as (optional, plain/json/xml) (default "plain") 49 | ``` 50 | 51 | # Example 52 | 53 | An example grabbing the strings from the `echo` utility. 54 | 55 | ``` 56 | ./elf-strings --binary=/bin/echo --min=4 --max-count=10 57 | 58 | [+] Size: 31 kB 59 | [+] Arch: x86_64 60 | [+] Entry point: 0x401800 61 | [+] Class: ELFCLASS64 62 | [+] Byte order: LittleEndian 63 | 64 | [.dynstr+0x0]: libc.so.6 65 | [.dynstr+0xa]: fflush 66 | [.dynstr+0x11]: __printf_chk 67 | [.dynstr+0x1e]: setlocale 68 | [.dynstr+0x28]: mbrtowc 69 | [.dynstr+0x30]: strncmp 70 | [.dynstr+0x38]: strrchr 71 | [.dynstr+0x40]: dcgettext 72 | [.dynstr+0x4a]: error 73 | [.dynstr+0x50]: __stack_chk_fail 74 | ``` 75 | -------------------------------------------------------------------------------- /elfread.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bytes" 5 | "debug/elf" 6 | "errors" 7 | "os" 8 | ) 9 | 10 | // ElfReader instance containing information 11 | // about said ELF binary 12 | type ElfReader struct { 13 | ExecReader *elf.File 14 | File *os.File 15 | } 16 | 17 | // NewELFReader will create a new instance of ElfReader 18 | func NewELFReader(path string) (*ElfReader, error) { 19 | var r ElfReader 20 | var err error 21 | 22 | r.File, err = os.OpenFile(path, os.O_RDONLY, os.ModePerm) 23 | if err != nil { 24 | return nil, errors.New("failed to open the file") 25 | } 26 | 27 | r.ExecReader, err = elf.NewFile(r.File) 28 | if err != nil { 29 | return nil, errors.New("failed to parse the ELF file succesfully") 30 | } 31 | 32 | return &r, nil 33 | } 34 | 35 | // ReaderParseSection will parse the ELF section and 36 | // return an array of bytes containing the content 37 | // of the section, using the file instance.. 38 | func (r *ElfReader) ReaderParseSection(name string) []byte { 39 | var s *elf.Section 40 | if s = r.ExecReader.Section(name); s == nil { 41 | return nil 42 | } 43 | 44 | sectionSize := int64(s.Offset) 45 | 46 | _, err := r.File.Seek(0, 0) 47 | if err != nil { 48 | return nil 49 | } 50 | 51 | ret, err := r.File.Seek(sectionSize, 0) 52 | if ret != sectionSize || err != nil { 53 | return nil 54 | } 55 | 56 | buf := make([]byte, s.Size) 57 | if buf == nil { 58 | return nil 59 | } 60 | 61 | _, err = r.File.Read(buf) 62 | if err != nil { 63 | return nil 64 | } 65 | 66 | return buf 67 | } 68 | 69 | // ReaderParseStrings will parse the strings by a null terminator 70 | // and then place them into an [offset => string] type map 71 | // alignment does not matter here, as when \x00 exists more than once 72 | // it will simply be skipped. 73 | func (r *ElfReader) ReaderParseStrings(buf []byte) map[uint64][]byte { 74 | var slice [][]byte 75 | if slice = bytes.Split(buf, []byte("\x00")); slice == nil { 76 | return nil 77 | } 78 | 79 | strings := make(map[uint64][]byte, len(slice)) 80 | length := uint64(len(slice)) 81 | 82 | var offset uint64 83 | 84 | for i := uint64(0); i < length; i++ { 85 | if len(slice[i]) == 0 { 86 | continue 87 | } 88 | 89 | strings[offset] = slice[i] 90 | 91 | offset += (uint64(len(slice[i])) + 1) 92 | } 93 | 94 | return strings 95 | } 96 | 97 | // Close softly close all of the instances associated 98 | // with the ElfReader 99 | func (r *ElfReader) Close() { 100 | r.ExecReader.Close() 101 | r.File.Close() 102 | } 103 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/comma.go: -------------------------------------------------------------------------------- 1 | package humanize 2 | 3 | import ( 4 | "bytes" 5 | "math" 6 | "math/big" 7 | "strconv" 8 | "strings" 9 | ) 10 | 11 | // Comma produces a string form of the given number in base 10 with 12 | // commas after every three orders of magnitude. 13 | // 14 | // e.g. Comma(834142) -> 834,142 15 | func Comma(v int64) string { 16 | sign := "" 17 | 18 | // Min int64 can't be negated to a usable value, so it has to be special cased. 19 | if v == math.MinInt64 { 20 | return "-9,223,372,036,854,775,808" 21 | } 22 | 23 | if v < 0 { 24 | sign = "-" 25 | v = 0 - v 26 | } 27 | 28 | parts := []string{"", "", "", "", "", "", ""} 29 | j := len(parts) - 1 30 | 31 | for v > 999 { 32 | parts[j] = strconv.FormatInt(v%1000, 10) 33 | switch len(parts[j]) { 34 | case 2: 35 | parts[j] = "0" + parts[j] 36 | case 1: 37 | parts[j] = "00" + parts[j] 38 | } 39 | v = v / 1000 40 | j-- 41 | } 42 | parts[j] = strconv.Itoa(int(v)) 43 | return sign + strings.Join(parts[j:], ",") 44 | } 45 | 46 | // Commaf produces a string form of the given number in base 10 with 47 | // commas after every three orders of magnitude. 48 | // 49 | // e.g. Commaf(834142.32) -> 834,142.32 50 | func Commaf(v float64) string { 51 | buf := &bytes.Buffer{} 52 | if v < 0 { 53 | buf.Write([]byte{'-'}) 54 | v = 0 - v 55 | } 56 | 57 | comma := []byte{','} 58 | 59 | parts := strings.Split(strconv.FormatFloat(v, 'f', -1, 64), ".") 60 | pos := 0 61 | if len(parts[0])%3 != 0 { 62 | pos += len(parts[0]) % 3 63 | buf.WriteString(parts[0][:pos]) 64 | buf.Write(comma) 65 | } 66 | for ; pos < len(parts[0]); pos += 3 { 67 | buf.WriteString(parts[0][pos : pos+3]) 68 | buf.Write(comma) 69 | } 70 | buf.Truncate(buf.Len() - 1) 71 | 72 | if len(parts) > 1 { 73 | buf.Write([]byte{'.'}) 74 | buf.WriteString(parts[1]) 75 | } 76 | return buf.String() 77 | } 78 | 79 | // BigComma produces a string form of the given big.Int in base 10 80 | // with commas after every three orders of magnitude. 81 | func BigComma(b *big.Int) string { 82 | sign := "" 83 | if b.Sign() < 0 { 84 | sign = "-" 85 | b.Abs(b) 86 | } 87 | 88 | athousand := big.NewInt(1000) 89 | c := (&big.Int{}).Set(b) 90 | _, m := oom(c, athousand) 91 | parts := make([]string, m+1) 92 | j := len(parts) - 1 93 | 94 | mod := &big.Int{} 95 | for b.Cmp(athousand) >= 0 { 96 | b.DivMod(b, athousand, mod) 97 | parts[j] = strconv.FormatInt(mod.Int64(), 10) 98 | switch len(parts[j]) { 99 | case 2: 100 | parts[j] = "0" + parts[j] 101 | case 1: 102 | parts[j] = "00" + parts[j] 103 | } 104 | j-- 105 | } 106 | parts[j] = strconv.Itoa(int(b.Int64())) 107 | return sign + strings.Join(parts[j:], ",") 108 | } 109 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/timestruct.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | import "time" 10 | 11 | // TimespecToNsec converts a Timespec value into a number of 12 | // nanoseconds since the Unix epoch. 13 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 14 | 15 | // NsecToTimespec takes a number of nanoseconds since the Unix epoch 16 | // and returns the corresponding Timespec value. 17 | func NsecToTimespec(nsec int64) Timespec { 18 | sec := nsec / 1e9 19 | nsec = nsec % 1e9 20 | if nsec < 0 { 21 | nsec += 1e9 22 | sec-- 23 | } 24 | return setTimespec(sec, nsec) 25 | } 26 | 27 | // TimeToTimespec converts t into a Timespec. 28 | // On some 32-bit systems the range of valid Timespec values are smaller 29 | // than that of time.Time values. So if t is out of the valid range of 30 | // Timespec, it returns a zero Timespec and ERANGE. 31 | func TimeToTimespec(t time.Time) (Timespec, error) { 32 | sec := t.Unix() 33 | nsec := int64(t.Nanosecond()) 34 | ts := setTimespec(sec, nsec) 35 | 36 | // Currently all targets have either int32 or int64 for Timespec.Sec. 37 | // If there were a new target with floating point type for it, we have 38 | // to consider the rounding error. 39 | if int64(ts.Sec) != sec { 40 | return Timespec{}, ERANGE 41 | } 42 | return ts, nil 43 | } 44 | 45 | // TimevalToNsec converts a Timeval value into a number of nanoseconds 46 | // since the Unix epoch. 47 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 48 | 49 | // NsecToTimeval takes a number of nanoseconds since the Unix epoch 50 | // and returns the corresponding Timeval value. 51 | func NsecToTimeval(nsec int64) Timeval { 52 | nsec += 999 // round up to microsecond 53 | usec := nsec % 1e9 / 1e3 54 | sec := nsec / 1e9 55 | if usec < 0 { 56 | usec += 1e6 57 | sec-- 58 | } 59 | return setTimeval(sec, usec) 60 | } 61 | 62 | // Unix returns ts as the number of seconds and nanoseconds elapsed since the 63 | // Unix epoch. 64 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 65 | return int64(ts.Sec), int64(ts.Nsec) 66 | } 67 | 68 | // Unix returns tv as the number of seconds and nanoseconds elapsed since the 69 | // Unix epoch. 70 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 71 | return int64(tv.Sec), int64(tv.Usec) * 1000 72 | } 73 | 74 | // Nano returns ts as the number of nanoseconds elapsed since the Unix epoch. 75 | func (ts *Timespec) Nano() int64 { 76 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 77 | } 78 | 79 | // Nano returns tv as the number of nanoseconds elapsed since the Unix epoch. 80 | func (tv *Timeval) Nano() int64 { 81 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 82 | } 83 | -------------------------------------------------------------------------------- /vendor/github.com/shawnsmithdev/zermelo/zuint/zuint.go: -------------------------------------------------------------------------------- 1 | // Radix sort for []uint. 2 | package zuint 3 | 4 | import ( 5 | "sort" 6 | ) 7 | 8 | const ( 9 | // Calling Sort() on slices smaller than this will result is sorting with sort.Sort() instead. 10 | MinSize = 256 11 | radix uint = 8 12 | // Const bit size thanks to kostya-sh@github 13 | bitSize uint = 1 << (5 + (^uint(0))>>32&1) 14 | ) 15 | 16 | // Sorts x using a Radix sort (Small slices are sorted with sort.Sort() instead). 17 | func Sort(x []uint) { 18 | if len(x) < MinSize { 19 | sort.Sort(uintSortable(x)) 20 | } else { 21 | buffer := make([]uint, len(x)) 22 | SortBYOB(x, buffer) 23 | } 24 | } 25 | 26 | // Similar to Sort(), but returns a sorted copy of x, leaving x unmodified. 27 | func SortCopy(x []uint) []uint { 28 | y := make([]uint, len(x)) 29 | copy(y, x) 30 | Sort(y) 31 | return y 32 | } 33 | 34 | // Sorts x using a Radix sort, using supplied buffer space. Panics if 35 | // len(x) does not equal len(buffer). Uses radix sort even on small slices.. 36 | func SortBYOB(x, buffer []uint) { 37 | if len(x) > len(buffer) { 38 | panic("Buffer too small") 39 | } 40 | if len(x) < 2 { 41 | return 42 | } 43 | 44 | from := x 45 | to := buffer[:len(x)] 46 | var key uint8 // Current byte value 47 | var offset [256]int // Keep track of where room is made for byte groups in the buffer 48 | 49 | for keyOffset := uint(0); keyOffset < bitSize; keyOffset += radix { 50 | keyMask := uint(0xFF << keyOffset) 51 | var counts [256]int // Keep track of the number of elements for each kind of byte 52 | sorted := true 53 | prev := uint(0) 54 | 55 | for _, elem := range from { 56 | // For each elem to sort, fetch the byte at current radix 57 | key = uint8((elem & keyMask) >> keyOffset) 58 | // inc count of bytes of this type 59 | counts[key]++ 60 | if sorted { // Detect sorted 61 | sorted = elem >= prev 62 | prev = elem 63 | } 64 | } 65 | 66 | if sorted { // Short-circuit sorted 67 | if (keyOffset/radix)%2 == 1 { 68 | copy(to, from) 69 | } 70 | return 71 | } 72 | 73 | // Make room for each group of bytes by calculating offset of each 74 | offset[0] = 0 75 | for i := 1; i < len(offset); i++ { 76 | offset[i] = offset[i-1] + counts[i-1] 77 | } 78 | 79 | // Swap values between the buffers by radix 80 | for _, elem := range from { 81 | key = uint8((elem & keyMask) >> keyOffset) // Get the byte of each element at the radix 82 | to[offset[key]] = elem // Copy the element depending on byte offsets 83 | offset[key]++ // One less space, move the offset 84 | } 85 | to, from = from, to 86 | } 87 | } 88 | 89 | type uintSortable []uint 90 | 91 | func (r uintSortable) Len() int { return len(r) } 92 | func (r uintSortable) Less(i, j int) bool { return r[i] < r[j] } 93 | func (r uintSortable) Swap(i, j int) { r[i], r[j] = r[j], r[i] } 94 | -------------------------------------------------------------------------------- /vendor/github.com/shawnsmithdev/zermelo/zuint32/zuint32.go: -------------------------------------------------------------------------------- 1 | // Radix sort for []uint32. 2 | package zuint32 3 | 4 | import ( 5 | "sort" 6 | ) 7 | 8 | const ( 9 | // Calling Sort() on slices smaller than this will result is sorting with sort.Sort() instead. 10 | MinSize = 128 11 | radix uint = 8 12 | bitSize uint = 32 13 | ) 14 | 15 | // Sorts x using a Radix sort (Small slices are sorted with sort.Sort() instead). 16 | func Sort(x []uint32) { 17 | if len(x) < MinSize { 18 | sort.Sort(uint32Sortable(x)) 19 | } else { 20 | buffer := make([]uint32, len(x)) 21 | SortBYOB(x, buffer) 22 | } 23 | } 24 | 25 | // Similar to Sort(), but returns a sorted copy of x, leaving x unmodified. 26 | func SortCopy(x []uint32) []uint32 { 27 | y := make([]uint32, len(x)) 28 | copy(y, x) 29 | Sort(y) 30 | return y 31 | } 32 | 33 | // Sorts x using a Radix sort, using supplied buffer space. Panics if 34 | // len(x) does not equal len(buffer). Uses radix sort even on small slices.. 35 | func SortBYOB(x, buffer []uint32) { 36 | if len(x) > len(buffer) { 37 | panic("Buffer too small") 38 | } 39 | if len(x) < 2 { 40 | return 41 | } 42 | 43 | from := x 44 | to := buffer[:len(x)] 45 | var key uint8 // Current byte value 46 | var offset [256]int // Keep track of where room is made for byte groups in the buffer 47 | 48 | for keyOffset := uint(0); keyOffset < bitSize; keyOffset += radix { 49 | keyMask := uint32(0xFF << keyOffset) 50 | var counts [256]int // Keep track of the number of elements for each kind of byte 51 | sorted := false 52 | prev := uint32(0) 53 | 54 | for _, elem := range from { 55 | // For each elem to sort, fetch the byte at current radix 56 | key = uint8((elem & keyMask) >> keyOffset) 57 | // inc count of bytes of this type 58 | counts[key]++ 59 | if sorted { // Detect sorted 60 | sorted = elem >= prev 61 | prev = elem 62 | } 63 | } 64 | 65 | if sorted { // Short-circuit sorted 66 | if (keyOffset/radix)%2 == 1 { 67 | copy(to, from) 68 | } 69 | return 70 | } 71 | 72 | // Make room for each group of bytes by calculating offset of each 73 | offset[0] = 0 74 | for i := 1; i < len(offset); i++ { 75 | offset[i] = offset[i-1] + counts[i-1] 76 | } 77 | 78 | // Swap values between the buffers by radix 79 | for _, elem := range from { 80 | key = uint8((elem & keyMask) >> keyOffset) // Get the byte of each element at the radix 81 | to[offset[key]] = elem // Copy the element depending on byte offsets 82 | offset[key]++ // One less space, move the offset 83 | } 84 | // Each pass copy data the other way 85 | to, from = from, to 86 | } 87 | } 88 | 89 | type uint32Sortable []uint32 90 | 91 | func (r uint32Sortable) Len() int { return len(r) } 92 | func (r uint32Sortable) Less(i, j int) bool { return r[i] < r[j] } 93 | func (r uint32Sortable) Swap(i, j int) { r[i], r[j] = r[j], r[i] } 94 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/si.go: -------------------------------------------------------------------------------- 1 | package humanize 2 | 3 | import ( 4 | "errors" 5 | "math" 6 | "regexp" 7 | "strconv" 8 | ) 9 | 10 | var siPrefixTable = map[float64]string{ 11 | -24: "y", // yocto 12 | -21: "z", // zepto 13 | -18: "a", // atto 14 | -15: "f", // femto 15 | -12: "p", // pico 16 | -9: "n", // nano 17 | -6: "µ", // micro 18 | -3: "m", // milli 19 | 0: "", 20 | 3: "k", // kilo 21 | 6: "M", // mega 22 | 9: "G", // giga 23 | 12: "T", // tera 24 | 15: "P", // peta 25 | 18: "E", // exa 26 | 21: "Z", // zetta 27 | 24: "Y", // yotta 28 | } 29 | 30 | var revSIPrefixTable = revfmap(siPrefixTable) 31 | 32 | // revfmap reverses the map and precomputes the power multiplier 33 | func revfmap(in map[float64]string) map[string]float64 { 34 | rv := map[string]float64{} 35 | for k, v := range in { 36 | rv[v] = math.Pow(10, k) 37 | } 38 | return rv 39 | } 40 | 41 | var riParseRegex *regexp.Regexp 42 | 43 | func init() { 44 | ri := `^([\-0-9.]+)\s?([` 45 | for _, v := range siPrefixTable { 46 | ri += v 47 | } 48 | ri += `]?)(.*)` 49 | 50 | riParseRegex = regexp.MustCompile(ri) 51 | } 52 | 53 | // ComputeSI finds the most appropriate SI prefix for the given number 54 | // and returns the prefix along with the value adjusted to be within 55 | // that prefix. 56 | // 57 | // See also: SI, ParseSI. 58 | // 59 | // e.g. ComputeSI(2.2345e-12) -> (2.2345, "p") 60 | func ComputeSI(input float64) (float64, string) { 61 | if input == 0 { 62 | return 0, "" 63 | } 64 | mag := math.Abs(input) 65 | exponent := math.Floor(logn(mag, 10)) 66 | exponent = math.Floor(exponent/3) * 3 67 | 68 | value := mag / math.Pow(10, exponent) 69 | 70 | // Handle special case where value is exactly 1000.0 71 | // Should return 1 M instead of 1000 k 72 | if value == 1000.0 { 73 | exponent += 3 74 | value = mag / math.Pow(10, exponent) 75 | } 76 | 77 | value = math.Copysign(value, input) 78 | 79 | prefix := siPrefixTable[exponent] 80 | return value, prefix 81 | } 82 | 83 | // SI returns a string with default formatting. 84 | // 85 | // SI uses Ftoa to format float value, removing trailing zeros. 86 | // 87 | // See also: ComputeSI, ParseSI. 88 | // 89 | // e.g. SI(1000000, "B") -> 1 MB 90 | // e.g. SI(2.2345e-12, "F") -> 2.2345 pF 91 | func SI(input float64, unit string) string { 92 | value, prefix := ComputeSI(input) 93 | return Ftoa(value) + " " + prefix + unit 94 | } 95 | 96 | var errInvalid = errors.New("invalid input") 97 | 98 | // ParseSI parses an SI string back into the number and unit. 99 | // 100 | // See also: SI, ComputeSI. 101 | // 102 | // e.g. ParseSI("2.2345 pF") -> (2.2345e-12, "F", nil) 103 | func ParseSI(input string) (float64, string, error) { 104 | found := riParseRegex.FindStringSubmatch(input) 105 | if len(found) != 4 { 106 | return 0, "", errInvalid 107 | } 108 | mag := revSIPrefixTable[found[2]] 109 | unit := found[3] 110 | 111 | base, err := strconv.ParseFloat(found[1], 64) 112 | return base * mag, unit, err 113 | } 114 | -------------------------------------------------------------------------------- /vendor/github.com/shawnsmithdev/zermelo/zuint64/zuint64.go: -------------------------------------------------------------------------------- 1 | // Radix sort for []uint64. 2 | package zuint64 3 | 4 | import ( 5 | "sort" 6 | ) 7 | 8 | const ( 9 | // Calling Sort() on slices smaller than this will result is sorting with sort.Sort() instead. 10 | MinSize = 256 11 | radix uint = 8 12 | bitSize uint = 64 13 | ) 14 | 15 | // Sorts x using a Radix sort (Small slices are sorted with sort.Sort() instead). 16 | func Sort(x []uint64) { 17 | if len(x) < MinSize { 18 | sort.Sort(uint64Sortable(x)) 19 | } else { 20 | buffer := make([]uint64, len(x)) 21 | SortBYOB(x, buffer) 22 | } 23 | } 24 | 25 | // Similar to Sort(), but returns a sorted copy of x, leaving x unmodified. 26 | func SortCopy(x []uint64) []uint64 { 27 | y := make([]uint64, len(x)) 28 | copy(y, x) 29 | Sort(y) 30 | return y 31 | } 32 | 33 | // Sorts x using a Radix sort, using supplied buffer space. Panics if 34 | // len(x) is greater than len(buffer). Uses radix sort even on small slices. 35 | func SortBYOB(x, buffer []uint64) { 36 | if len(x) > len(buffer) { 37 | panic("Buffer too small") 38 | } 39 | if len(x) < 2 { 40 | return 41 | } 42 | 43 | // Each pass processes a byte offset, copying back and forth between slices 44 | from := x 45 | to := buffer[:len(x)] 46 | var key uint8 47 | var offset [256]int // Keep track of where groups start 48 | 49 | for keyOffset := uint(0); keyOffset < bitSize; keyOffset += radix { 50 | keyMask := uint64(0xFF << keyOffset) // Current 'digit' to look at 51 | var counts [256]int // Keep track of the number of elements for each kind of byte 52 | sorted := true // Check for already sorted 53 | prev := uint64(0) // if elem is always >= prev it is already sorted 54 | for _, elem := range from { 55 | key = uint8((elem & keyMask) >> keyOffset) // fetch the byte at current 'digit' 56 | counts[key]++ // count of elems to put in this digit's bucket 57 | if sorted { // Detect sorted 58 | sorted = elem >= prev 59 | prev = elem 60 | } 61 | } 62 | 63 | if sorted { // Short-circuit sorted 64 | if (keyOffset/radix)%2 == 1 { 65 | copy(to, from) 66 | } 67 | return 68 | } 69 | 70 | // Find target bucket offsets 71 | offset[0] = 0 72 | for i := 1; i < len(offset); i++ { 73 | offset[i] = offset[i-1] + counts[i-1] 74 | } 75 | 76 | // Rebucket while copying to other buffer 77 | for _, elem := range from { 78 | key = uint8((elem & keyMask) >> keyOffset) // Get the digit 79 | to[offset[key]] = elem // Copy the element to the digit's bucket 80 | offset[key]++ // One less space, move the offset 81 | } 82 | // On next pass copy data the other way 83 | to, from = from, to 84 | } 85 | } 86 | 87 | // Implements sort.Interface for small slices 88 | type uint64Sortable []uint64 89 | 90 | func (r uint64Sortable) Len() int { return len(r) } 91 | func (r uint64Sortable) Less(i, j int) bool { return r[i] < r[j] } 92 | func (r uint64Sortable) Swap(i, j int) { r[i], r[j] = r[j], r[i] } 93 | -------------------------------------------------------------------------------- /vendor/github.com/shawnsmithdev/zermelo/zint64/zint64.go: -------------------------------------------------------------------------------- 1 | // Radix sort for []int64. 2 | package zint64 3 | 4 | import ( 5 | "sort" 6 | ) 7 | 8 | const ( 9 | // Calling Sort() on slices smaller than this will result is sorting with sort.Sort() instead. 10 | MinSize = 256 11 | radix uint = 8 12 | bitSize uint = 64 13 | minInt64 int64 = -1 << 63 14 | ) 15 | 16 | // Sorts x using a Radix sort (Small slices are sorted with sort.Sort() instead). 17 | func Sort(x []int64) { 18 | if len(x) < MinSize { 19 | sort.Sort(int64Sortable(x)) 20 | } else { 21 | buffer := make([]int64, len(x)) 22 | SortBYOB(x, buffer) 23 | } 24 | } 25 | 26 | // Similar to Sort(), but returns a sorted copy of x, leaving x unmodified. 27 | func SortCopy(x []int64) []int64 { 28 | y := make([]int64, len(x)) 29 | copy(y, x) 30 | Sort(y) 31 | return y 32 | } 33 | 34 | // Sorts a []int64 using a Radix sort, using supplied buffer space. Panics if 35 | // len(x) does not equal len(buffer). Uses radix sort even on small slices. 36 | func SortBYOB(x, buffer []int64) { 37 | if len(x) > len(buffer) { 38 | panic("Buffer too small") 39 | } 40 | if len(x) < 2 { 41 | return 42 | } 43 | 44 | from := x 45 | to := buffer[:len(x)] 46 | var key uint8 47 | var offset [256]int // Keep track of where groups start 48 | 49 | for keyOffset := uint(0); keyOffset < bitSize; keyOffset += radix { 50 | keyMask := int64(0xFF << keyOffset) 51 | var counts [256]int // Keep track of the number of elements for each kind of byte 52 | sorted := true 53 | prev := minInt64 54 | 55 | for _, elem := range from { 56 | // For each elem to sort, fetch the byte at current radix 57 | key = uint8((elem & keyMask) >> keyOffset) 58 | // inc count of bytes of this type 59 | counts[key]++ 60 | if sorted { // Detect sorted 61 | sorted = elem >= prev 62 | prev = elem 63 | } 64 | } 65 | 66 | if sorted { // Short-circuit sorted 67 | if (keyOffset/radix)%2 == 1 { 68 | copy(to, from) 69 | } 70 | return 71 | } 72 | 73 | if keyOffset == bitSize-radix { 74 | // Handle signed values 75 | // Count negative elements (last 128 counts) 76 | negCnt := 0 77 | for i := 128; i < 256; i++ { 78 | negCnt += counts[i] 79 | } 80 | 81 | offset[0] = negCnt // Start of positives 82 | offset[128] = 0 // Start of negatives 83 | for i := 1; i < 128; i++ { 84 | // Positive values 85 | offset[i] = offset[i-1] + counts[i-1] 86 | // Negative values 87 | offset[i+128] = offset[i+127] + counts[i+127] 88 | } 89 | } else { 90 | offset[0] = 0 91 | for i := 1; i < len(offset); i++ { 92 | offset[i] = offset[i-1] + counts[i-1] 93 | } 94 | } 95 | 96 | // Swap values between the buffers by radix 97 | for _, elem := range from { 98 | key = uint8((elem & keyMask) >> keyOffset) // Get the byte of each element at the radix 99 | to[offset[key]] = elem // Copy the element depending on byte offsets 100 | offset[key]++ 101 | } 102 | from, to = to, from 103 | } 104 | } 105 | 106 | type int64Sortable []int64 107 | 108 | func (r int64Sortable) Len() int { return len(r) } 109 | func (r int64Sortable) Less(i, j int) bool { return r[i] < r[j] } 110 | func (r int64Sortable) Swap(i, j int) { r[i], r[j] = r[j], r[i] } 111 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/bytes.go: -------------------------------------------------------------------------------- 1 | package humanize 2 | 3 | import ( 4 | "fmt" 5 | "math" 6 | "strconv" 7 | "strings" 8 | "unicode" 9 | ) 10 | 11 | // IEC Sizes. 12 | // kibis of bits 13 | const ( 14 | Byte = 1 << (iota * 10) 15 | KiByte 16 | MiByte 17 | GiByte 18 | TiByte 19 | PiByte 20 | EiByte 21 | ) 22 | 23 | // SI Sizes. 24 | const ( 25 | IByte = 1 26 | KByte = IByte * 1000 27 | MByte = KByte * 1000 28 | GByte = MByte * 1000 29 | TByte = GByte * 1000 30 | PByte = TByte * 1000 31 | EByte = PByte * 1000 32 | ) 33 | 34 | var bytesSizeTable = map[string]uint64{ 35 | "b": Byte, 36 | "kib": KiByte, 37 | "kb": KByte, 38 | "mib": MiByte, 39 | "mb": MByte, 40 | "gib": GiByte, 41 | "gb": GByte, 42 | "tib": TiByte, 43 | "tb": TByte, 44 | "pib": PiByte, 45 | "pb": PByte, 46 | "eib": EiByte, 47 | "eb": EByte, 48 | // Without suffix 49 | "": Byte, 50 | "ki": KiByte, 51 | "k": KByte, 52 | "mi": MiByte, 53 | "m": MByte, 54 | "gi": GiByte, 55 | "g": GByte, 56 | "ti": TiByte, 57 | "t": TByte, 58 | "pi": PiByte, 59 | "p": PByte, 60 | "ei": EiByte, 61 | "e": EByte, 62 | } 63 | 64 | func logn(n, b float64) float64 { 65 | return math.Log(n) / math.Log(b) 66 | } 67 | 68 | func humanateBytes(s uint64, base float64, sizes []string) string { 69 | if s < 10 { 70 | return fmt.Sprintf("%d B", s) 71 | } 72 | e := math.Floor(logn(float64(s), base)) 73 | suffix := sizes[int(e)] 74 | val := math.Floor(float64(s)/math.Pow(base, e)*10+0.5) / 10 75 | f := "%.0f %s" 76 | if val < 10 { 77 | f = "%.1f %s" 78 | } 79 | 80 | return fmt.Sprintf(f, val, suffix) 81 | } 82 | 83 | // Bytes produces a human readable representation of an SI size. 84 | // 85 | // See also: ParseBytes. 86 | // 87 | // Bytes(82854982) -> 83 MB 88 | func Bytes(s uint64) string { 89 | sizes := []string{"B", "kB", "MB", "GB", "TB", "PB", "EB"} 90 | return humanateBytes(s, 1000, sizes) 91 | } 92 | 93 | // IBytes produces a human readable representation of an IEC size. 94 | // 95 | // See also: ParseBytes. 96 | // 97 | // IBytes(82854982) -> 79 MiB 98 | func IBytes(s uint64) string { 99 | sizes := []string{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB"} 100 | return humanateBytes(s, 1024, sizes) 101 | } 102 | 103 | // ParseBytes parses a string representation of bytes into the number 104 | // of bytes it represents. 105 | // 106 | // See Also: Bytes, IBytes. 107 | // 108 | // ParseBytes("42 MB") -> 42000000, nil 109 | // ParseBytes("42 mib") -> 44040192, nil 110 | func ParseBytes(s string) (uint64, error) { 111 | lastDigit := 0 112 | hasComma := false 113 | for _, r := range s { 114 | if !(unicode.IsDigit(r) || r == '.' || r == ',') { 115 | break 116 | } 117 | if r == ',' { 118 | hasComma = true 119 | } 120 | lastDigit++ 121 | } 122 | 123 | num := s[:lastDigit] 124 | if hasComma { 125 | num = strings.Replace(num, ",", "", -1) 126 | } 127 | 128 | f, err := strconv.ParseFloat(num, 64) 129 | if err != nil { 130 | return 0, err 131 | } 132 | 133 | extra := strings.ToLower(strings.TrimSpace(s[lastDigit:])) 134 | if m, ok := bytesSizeTable[extra]; ok { 135 | f *= float64(m) 136 | if f >= math.MaxUint64 { 137 | return 0, fmt.Errorf("too large: %v", s) 138 | } 139 | return uint64(f), nil 140 | } 141 | 142 | return 0, fmt.Errorf("unhandled size name: %v", extra) 143 | } 144 | -------------------------------------------------------------------------------- /vendor/github.com/shawnsmithdev/zermelo/zint32/zint32.go: -------------------------------------------------------------------------------- 1 | // Radix sort for []int32. 2 | package zint32 3 | 4 | import ( 5 | "sort" 6 | ) 7 | 8 | const ( 9 | // Calling Sort() on slices smaller than this will result is sorting with sort.Sort() instead. 10 | MinSize = 128 11 | radix uint = 8 12 | bitSize uint = 32 13 | minInt32 int32 = -1 << 31 14 | ) 15 | 16 | // Sorts x using a Radix sort (Small slices are sorted with sort.Sort() instead). 17 | func Sort(x []int32) { 18 | if len(x) < MinSize { 19 | sort.Sort(int32Sortable(x)) 20 | } else { 21 | buffer := make([]int32, len(x)) 22 | SortBYOB(x, buffer) 23 | } 24 | } 25 | 26 | // Similar to Sort(), but returns a sorted copy of x, leaving x unmodified. 27 | func SortCopy(x []int32) []int32 { 28 | y := make([]int32, len(x)) 29 | copy(y, x) 30 | Sort(y) 31 | return y 32 | } 33 | 34 | // Sorts a []int32 using a Radix sort, using supplied buffer space. Panics if 35 | // len(x) does not equal len(buffer). Uses radix sort even on small slices. 36 | func SortBYOB(x, buffer []int32) { 37 | if len(x) > len(buffer) { 38 | panic("Buffer too small") 39 | } 40 | if len(x) < 2 { 41 | return 42 | } 43 | 44 | from := x 45 | to := buffer[:len(x)] 46 | var key uint8 47 | var offset [256]int // Keep track of where groups start 48 | 49 | for keyOffset := uint(0); keyOffset < bitSize; keyOffset += radix { 50 | keyMask := int32(0xFF << keyOffset) 51 | sorted := true 52 | prev := minInt32 53 | var counts [256]int // Keep track of the number of elements for each kind of byte 54 | for _, elem := range from { 55 | // For each elem to sort, fetch the byte at current radix 56 | key = uint8((elem & keyMask) >> keyOffset) 57 | // inc count of bytes of this type 58 | counts[key]++ 59 | if sorted { // Detect sorted 60 | sorted = elem >= prev 61 | prev = elem 62 | } 63 | } 64 | 65 | if sorted { // Short-circuit sorted 66 | if (keyOffset/radix)%2 == 1 { 67 | copy(to, from) 68 | } 69 | return 70 | } 71 | 72 | if keyOffset == bitSize-radix { 73 | // Last pass. Handle signed values 74 | // Count negative elements (last 128 counts) 75 | negCnt := 0 76 | for i := 128; i < 256; i++ { 77 | negCnt += counts[i] 78 | } 79 | 80 | offset[0] = negCnt // Start of positives 81 | offset[128] = 0 // Start of negatives 82 | for i := 1; i < 128; i++ { 83 | // Positive values 84 | offset[i] = offset[i-1] + counts[i-1] 85 | // Negative values 86 | offset[i+128] = offset[i+127] + counts[i+127] 87 | } 88 | } else { 89 | offset[0] = 0 90 | for i := 1; i < 256; i++ { 91 | offset[i] = offset[i-1] + counts[i-1] 92 | } 93 | } 94 | 95 | // Swap values between the buffers by radix 96 | for _, elem := range from { 97 | key = uint8((elem & keyMask) >> keyOffset) // Get the byte of each element at the radix 98 | to[offset[key]] = elem // Copy the element depending on byte offsets 99 | offset[key]++ 100 | } 101 | // Reverse buffers on each pass 102 | to, from = from, to 103 | } 104 | } 105 | 106 | type int32Sortable []int32 107 | 108 | func (r int32Sortable) Len() int { return len(r) } 109 | func (r int32Sortable) Less(i, j int) bool { return r[i] < r[j] } 110 | func (r int32Sortable) Swap(i, j int) { r[i], r[j] = r[j], r[i] } 111 | -------------------------------------------------------------------------------- /vendor/github.com/shawnsmithdev/zermelo/zint/zint.go: -------------------------------------------------------------------------------- 1 | // Radix sort for []int. 2 | package zint 3 | 4 | import ( 5 | "sort" 6 | ) 7 | 8 | const ( 9 | // Calling Sort() on slices smaller than this will result is sorting with sort.Sort() instead. 10 | MinSize = 256 11 | radix uint = 8 12 | // Const bit size thanks to kostya-sh@github 13 | bitSize uint = 1 << (5 + (^uint(0))>>32&1) 14 | minInt int = -1 >> (bitSize - 1) 15 | ) 16 | 17 | // Sorts x using a Radix sort (Small slices are sorted with sort.Sort() instead). 18 | func Sort(x []int) { 19 | if len(x) < MinSize { 20 | sort.Sort(intSortable(x)) 21 | } else { 22 | buffer := make([]int, len(x)) 23 | SortBYOB(x, buffer) 24 | } 25 | } 26 | 27 | // Similar to Sort(), but returns a sorted copy of x, leaving x unmodified. 28 | func SortCopy(x []int) []int { 29 | y := make([]int, len(x)) 30 | copy(y, x) 31 | Sort(y) 32 | return y 33 | } 34 | 35 | // Sorts a []int using a Radix sort, using supplied buffer space. Panics if 36 | // len(x) does not equal len(buffer). Uses radix sort even on small slices. 37 | func SortBYOB(x, buffer []int) { 38 | if len(x) > len(buffer) { 39 | panic("Buffer too small") 40 | } 41 | if len(x) < 2 { 42 | return 43 | } 44 | 45 | from := x 46 | to := buffer[:len(x)] 47 | var key uint8 // Current byte value 48 | var offset [256]int // Keep track of where room is made for byte groups in the buffer 49 | 50 | for keyOffset := uint(0); keyOffset < bitSize; keyOffset += radix { 51 | keyMask := int(0xFF << keyOffset) 52 | var counts [256]int // Keep track of the number of elements for each kind of byte 53 | sorted := true 54 | prev := minInt 55 | for _, elem := range from { 56 | // For each elem to sort, fetch the byte at current radix 57 | key = uint8((elem & keyMask) >> keyOffset) 58 | // inc count of bytes of this type 59 | counts[key]++ 60 | if sorted { // Detect sorted 61 | sorted = elem >= prev 62 | prev = elem 63 | } 64 | } 65 | 66 | if sorted { // Short-circuit sorted 67 | if (keyOffset/radix)%2 == 1 { 68 | copy(to, from) 69 | } 70 | return 71 | } 72 | 73 | if keyOffset == bitSize-radix { 74 | // Last pass. Handle signed values 75 | // Count negative elements (last 128 counts) 76 | negCnt := 0 77 | for i := 128; i < 256; i++ { 78 | negCnt += counts[i] 79 | } 80 | 81 | offset[0] = negCnt // Start of positives 82 | offset[128] = 0 // Start of negatives 83 | for i := 1; i < 128; i++ { 84 | // Positive values 85 | offset[i] = offset[i-1] + counts[i-1] 86 | // Negative values 87 | offset[i+128] = offset[i+127] + counts[i+127] 88 | } 89 | } else { 90 | offset[0] = 0 91 | for i := 1; i < len(offset); i++ { 92 | offset[i] = offset[i-1] + counts[i-1] 93 | } 94 | } 95 | 96 | // Swap values between the buffers by radix 97 | for _, elem := range from { 98 | key = uint8((elem & keyMask) >> keyOffset) // Get the byte of each element at the radix 99 | to[offset[key]] = elem // Copy the element depending on byte offsets 100 | offset[key]++ 101 | } 102 | // Each pass reverse buffers 103 | to, from = from, to 104 | } 105 | } 106 | 107 | type intSortable []int 108 | 109 | func (r intSortable) Len() int { return len(r) } 110 | func (r intSortable) Less(i, j int) bool { return r[i] < r[j] } 111 | func (r intSortable) Swap(i, j int) { r[i], r[j] = r[j], r[i] } 112 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sockcmsg_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Socket control messages 8 | 9 | package unix 10 | 11 | import "unsafe" 12 | 13 | // Round the length of a raw sockaddr up to align it properly. 14 | func cmsgAlignOf(salen int) int { 15 | salign := sizeofPtr 16 | // NOTE: It seems like 64-bit Darwin, DragonFly BSD and 17 | // Solaris kernels still require 32-bit aligned access to 18 | // network subsystem. 19 | if darwin64Bit || dragonfly64Bit || solaris64Bit { 20 | salign = 4 21 | } 22 | return (salen + salign - 1) & ^(salign - 1) 23 | } 24 | 25 | // CmsgLen returns the value to store in the Len field of the Cmsghdr 26 | // structure, taking into account any necessary alignment. 27 | func CmsgLen(datalen int) int { 28 | return cmsgAlignOf(SizeofCmsghdr) + datalen 29 | } 30 | 31 | // CmsgSpace returns the number of bytes an ancillary element with 32 | // payload of the passed data length occupies. 33 | func CmsgSpace(datalen int) int { 34 | return cmsgAlignOf(SizeofCmsghdr) + cmsgAlignOf(datalen) 35 | } 36 | 37 | func cmsgData(h *Cmsghdr) unsafe.Pointer { 38 | return unsafe.Pointer(uintptr(unsafe.Pointer(h)) + uintptr(cmsgAlignOf(SizeofCmsghdr))) 39 | } 40 | 41 | // SocketControlMessage represents a socket control message. 42 | type SocketControlMessage struct { 43 | Header Cmsghdr 44 | Data []byte 45 | } 46 | 47 | // ParseSocketControlMessage parses b as an array of socket control 48 | // messages. 49 | func ParseSocketControlMessage(b []byte) ([]SocketControlMessage, error) { 50 | var msgs []SocketControlMessage 51 | i := 0 52 | for i+CmsgLen(0) <= len(b) { 53 | h, dbuf, err := socketControlMessageHeaderAndData(b[i:]) 54 | if err != nil { 55 | return nil, err 56 | } 57 | m := SocketControlMessage{Header: *h, Data: dbuf} 58 | msgs = append(msgs, m) 59 | i += cmsgAlignOf(int(h.Len)) 60 | } 61 | return msgs, nil 62 | } 63 | 64 | func socketControlMessageHeaderAndData(b []byte) (*Cmsghdr, []byte, error) { 65 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 66 | if h.Len < SizeofCmsghdr || uint64(h.Len) > uint64(len(b)) { 67 | return nil, nil, EINVAL 68 | } 69 | return h, b[cmsgAlignOf(SizeofCmsghdr):h.Len], nil 70 | } 71 | 72 | // UnixRights encodes a set of open file descriptors into a socket 73 | // control message for sending to another process. 74 | func UnixRights(fds ...int) []byte { 75 | datalen := len(fds) * 4 76 | b := make([]byte, CmsgSpace(datalen)) 77 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 78 | h.Level = SOL_SOCKET 79 | h.Type = SCM_RIGHTS 80 | h.SetLen(CmsgLen(datalen)) 81 | data := cmsgData(h) 82 | for _, fd := range fds { 83 | *(*int32)(data) = int32(fd) 84 | data = unsafe.Pointer(uintptr(data) + 4) 85 | } 86 | return b 87 | } 88 | 89 | // ParseUnixRights decodes a socket control message that contains an 90 | // integer array of open file descriptors from another process. 91 | func ParseUnixRights(m *SocketControlMessage) ([]int, error) { 92 | if m.Header.Level != SOL_SOCKET { 93 | return nil, EINVAL 94 | } 95 | if m.Header.Type != SCM_RIGHTS { 96 | return nil, EINVAL 97 | } 98 | fds := make([]int, len(m.Data)>>2) 99 | for i, j := 0, 0; i < len(m.Data); i += 4 { 100 | fds[j] = int(*(*int32)(unsafe.Pointer(&m.Data[i]))) 101 | j++ 102 | } 103 | return fds, nil 104 | } 105 | -------------------------------------------------------------------------------- /vendor/github.com/shawnsmithdev/zermelo/zfloat64/zfloat64.go: -------------------------------------------------------------------------------- 1 | // Radix sort for []float64. 2 | package zfloat64 3 | 4 | import ( 5 | "math" 6 | "sort" 7 | ) 8 | 9 | const ( 10 | // Calling Sort() on slices smaller than this will result is sorting with sort.Sort() instead. 11 | MinSize = 256 12 | radix uint = 8 13 | radixShift uint = 3 14 | bitSize uint = 64 15 | ) 16 | 17 | // Sorts x using a Radix sort (Small slices are sorted with sort.Sort() instead). 18 | func Sort(x []float64) { 19 | if len(x) < MinSize { 20 | sort.Float64s(x) 21 | } else { 22 | SortBYOB(x, make([]float64, len(x))) 23 | } 24 | } 25 | 26 | // Similar to Sort(), but returns a sorted copy of x, leaving x unmodified. 27 | func SortCopy(x []float64) []float64 { 28 | y := make([]float64, len(x)) 29 | copy(y, x) 30 | Sort(y) 31 | return y 32 | } 33 | 34 | // Sorts x using a Radix sort, using supplied buffer space. Panics if 35 | // len(x) is greater than len(buffer). Uses radix sort even on small slices. 36 | func SortBYOB(x, buffer []float64) { 37 | if len(x) > len(buffer) { 38 | panic("Buffer too small") 39 | } 40 | if len(x) < 2 { 41 | return 42 | } 43 | 44 | // Don't sort NaNs, just put them up front and skip them 45 | nans := 0 46 | for idx, val := range x { 47 | if math.IsNaN(val) { 48 | x[idx] = x[nans] 49 | x[nans] = val 50 | nans++ 51 | } 52 | } 53 | 54 | // Each pass processes a byte offset, copying back and forth between slices 55 | from := x[nans:] 56 | to := buffer[:len(from)] 57 | var key uint8 58 | var uintVal uint64 59 | var offset [256]int // Keep track of where room is made for byte groups in the buffer 60 | 61 | for keyOffset := uint(0); keyOffset < bitSize; keyOffset += radix { 62 | keyMask := uint64(0xFF << keyOffset) // Current 'digit' to look at 63 | var counts [256]int // Keep track of the number of elements for each kind of byte 64 | sorted := true // Check for already sorted 65 | prev := float64(0) // if elem is always >= prev it is already sorted 66 | 67 | for _, val := range from { 68 | uintVal = floatFlip(math.Float64bits(val)) 69 | key = uint8((uintVal & keyMask) >> keyOffset) // fetch the byte at current 'digit' 70 | counts[key]++ // count of values to put in this digit's bucket 71 | if sorted { // Detect sorted 72 | sorted = val >= prev 73 | prev = val 74 | } 75 | } 76 | 77 | if sorted { // Short-circuit sorted 78 | if (keyOffset/radix)%2 == 1 { 79 | copy(to, from) 80 | } 81 | return 82 | } 83 | 84 | // Find target bucket offsets 85 | offset[0] = 0 86 | for i := 1; i < len(offset); i++ { 87 | offset[i] = offset[i-1] + counts[i-1] 88 | } 89 | 90 | // Rebucket while copying to other buffer 91 | for _, val := range from { 92 | uintVal = floatFlip(math.Float64bits(val)) 93 | key = uint8((uintVal & keyMask) >> keyOffset) // Get the digit 94 | to[offset[key]] = val // Copy the element to the digit's bucket 95 | offset[key]++ // One less space, move the offset 96 | } 97 | // On next pass copy data the other way 98 | to, from = from, to 99 | } 100 | } 101 | 102 | // Converts a uint64 that represents a true float to one sorts properly 103 | func floatFlip(x uint64) uint64 { 104 | if (x & 0x8000000000000000) == 0x8000000000000000 { 105 | return x ^ 0xFFFFFFFFFFFFFFFF 106 | } 107 | return x ^ 0x8000000000000000 108 | } 109 | -------------------------------------------------------------------------------- /vendor/vendor.json: -------------------------------------------------------------------------------- 1 | { 2 | "comment": "", 3 | "ignore": "test", 4 | "package": [ 5 | { 6 | "checksumSHA1": "tJd2T/eyW6ejAev7WzGxTeUVOPQ=", 7 | "path": "github.com/dustin/go-humanize", 8 | "revision": "bb3d318650d48840a39aa21a027c6630e198e626", 9 | "revisionTime": "2017-11-10T20:55:13Z" 10 | }, 11 | { 12 | "checksumSHA1": "p5z5hdUt68Z3tK7Is+yLGrCNzoA=", 13 | "path": "github.com/fatih/color", 14 | "revision": "5df930a27be2502f99b292b7cc09ebad4d0891f4", 15 | "revisionTime": "2017-09-26T11:14:11Z" 16 | }, 17 | { 18 | "checksumSHA1": "Pbj2LwBw5wZRiWOk2hG1AxAfTAw=", 19 | "path": "github.com/ianlancetaylor/demangle", 20 | "revision": "4883227f66371e02c4948937d3e2be1664d9be38", 21 | "revisionTime": "2016-09-27T19:13:59Z" 22 | }, 23 | { 24 | "checksumSHA1": "SEnjvwVyfuU2xBaOfXfwPD5MZqk=", 25 | "path": "github.com/mattn/go-colorable", 26 | "revision": "7dc3415be66d7cc68bf0182f35c8d31f8d2ad8a7", 27 | "revisionTime": "2018-02-05T07:01:58Z" 28 | }, 29 | { 30 | "checksumSHA1": "w5RcOnfv5YDr3j2bd1YydkPiZx4=", 31 | "path": "github.com/mattn/go-isatty", 32 | "revision": "6ca4dbf54d38eea1a992b3c722a76a5d1c4cb25c", 33 | "revisionTime": "2017-11-07T05:05:31Z" 34 | }, 35 | { 36 | "checksumSHA1": "dOtGHq3CHVndmJHolm8pGAt9iB4=", 37 | "path": "github.com/shawnsmithdev/zermelo", 38 | "revision": "2fd486927496084c394918a3c6215f17345f2ffa", 39 | "revisionTime": "2017-08-25T04:02:16Z" 40 | }, 41 | { 42 | "checksumSHA1": "T2PR4Bi8j0i7tfIZoUzzCLL4DwA=", 43 | "path": "github.com/shawnsmithdev/zermelo/zfloat32", 44 | "revision": "2fd486927496084c394918a3c6215f17345f2ffa", 45 | "revisionTime": "2017-08-25T04:02:16Z" 46 | }, 47 | { 48 | "checksumSHA1": "d2Yakyjtk0jI6AS1f673fa5JI0A=", 49 | "path": "github.com/shawnsmithdev/zermelo/zfloat64", 50 | "revision": "2fd486927496084c394918a3c6215f17345f2ffa", 51 | "revisionTime": "2017-08-25T04:02:16Z" 52 | }, 53 | { 54 | "checksumSHA1": "ZssRnz4O0dv26Hm7HqjEziR/4r4=", 55 | "path": "github.com/shawnsmithdev/zermelo/zint", 56 | "revision": "2fd486927496084c394918a3c6215f17345f2ffa", 57 | "revisionTime": "2017-08-25T04:02:16Z" 58 | }, 59 | { 60 | "checksumSHA1": "2n86ycFpQF5b3ED+mh99EjgHFaM=", 61 | "path": "github.com/shawnsmithdev/zermelo/zint32", 62 | "revision": "2fd486927496084c394918a3c6215f17345f2ffa", 63 | "revisionTime": "2017-08-25T04:02:16Z" 64 | }, 65 | { 66 | "checksumSHA1": "lLuKnEW/7csbTPr8I/FVOMrGBrw=", 67 | "path": "github.com/shawnsmithdev/zermelo/zint64", 68 | "revision": "2fd486927496084c394918a3c6215f17345f2ffa", 69 | "revisionTime": "2017-08-25T04:02:16Z" 70 | }, 71 | { 72 | "checksumSHA1": "0/kZ0wJw/4ZnZW1Sa7fXFKsMC88=", 73 | "path": "github.com/shawnsmithdev/zermelo/zuint", 74 | "revision": "2fd486927496084c394918a3c6215f17345f2ffa", 75 | "revisionTime": "2017-08-25T04:02:16Z" 76 | }, 77 | { 78 | "checksumSHA1": "Nl1yyam1ifS2NgOdrwB7OGk9pRU=", 79 | "path": "github.com/shawnsmithdev/zermelo/zuint32", 80 | "revision": "2fd486927496084c394918a3c6215f17345f2ffa", 81 | "revisionTime": "2017-08-25T04:02:16Z" 82 | }, 83 | { 84 | "checksumSHA1": "1aQhx7CVMbHhd1FeSxdJJvB+/dI=", 85 | "path": "github.com/shawnsmithdev/zermelo/zuint64", 86 | "revision": "2fd486927496084c394918a3c6215f17345f2ffa", 87 | "revisionTime": "2017-08-25T04:02:16Z" 88 | }, 89 | { 90 | "checksumSHA1": "CNHEeGnucEUlTHJrLS2kHtfNbws=", 91 | "path": "golang.org/x/sys/unix", 92 | "revision": "37707fdb30a5b38865cfb95e5aab41707daec7fd", 93 | "revisionTime": "2018-02-02T13:35:31Z" 94 | } 95 | ], 96 | "rootPath": "elf-strings" 97 | } 98 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/README.markdown: -------------------------------------------------------------------------------- 1 | # Humane Units [![Build Status](https://travis-ci.org/dustin/go-humanize.svg?branch=master)](https://travis-ci.org/dustin/go-humanize) [![GoDoc](https://godoc.org/github.com/dustin/go-humanize?status.svg)](https://godoc.org/github.com/dustin/go-humanize) 2 | 3 | Just a few functions for helping humanize times and sizes. 4 | 5 | `go get` it as `github.com/dustin/go-humanize`, import it as 6 | `"github.com/dustin/go-humanize"`, use it as `humanize`. 7 | 8 | See [godoc](https://godoc.org/github.com/dustin/go-humanize) for 9 | complete documentation. 10 | 11 | ## Sizes 12 | 13 | This lets you take numbers like `82854982` and convert them to useful 14 | strings like, `83 MB` or `79 MiB` (whichever you prefer). 15 | 16 | Example: 17 | 18 | ```go 19 | fmt.Printf("That file is %s.", humanize.Bytes(82854982)) // That file is 83 MB. 20 | ``` 21 | 22 | ## Times 23 | 24 | This lets you take a `time.Time` and spit it out in relative terms. 25 | For example, `12 seconds ago` or `3 days from now`. 26 | 27 | Example: 28 | 29 | ```go 30 | fmt.Printf("This was touched %s.", humanize.Time(someTimeInstance)) // This was touched 7 hours ago. 31 | ``` 32 | 33 | Thanks to Kyle Lemons for the time implementation from an IRC 34 | conversation one day. It's pretty neat. 35 | 36 | ## Ordinals 37 | 38 | From a [mailing list discussion][odisc] where a user wanted to be able 39 | to label ordinals. 40 | 41 | 0 -> 0th 42 | 1 -> 1st 43 | 2 -> 2nd 44 | 3 -> 3rd 45 | 4 -> 4th 46 | [...] 47 | 48 | Example: 49 | 50 | ```go 51 | fmt.Printf("You're my %s best friend.", humanize.Ordinal(193)) // You are my 193rd best friend. 52 | ``` 53 | 54 | ## Commas 55 | 56 | Want to shove commas into numbers? Be my guest. 57 | 58 | 0 -> 0 59 | 100 -> 100 60 | 1000 -> 1,000 61 | 1000000000 -> 1,000,000,000 62 | -100000 -> -100,000 63 | 64 | Example: 65 | 66 | ```go 67 | fmt.Printf("You owe $%s.\n", humanize.Comma(6582491)) // You owe $6,582,491. 68 | ``` 69 | 70 | ## Ftoa 71 | 72 | Nicer float64 formatter that removes trailing zeros. 73 | 74 | ```go 75 | fmt.Printf("%f", 2.24) // 2.240000 76 | fmt.Printf("%s", humanize.Ftoa(2.24)) // 2.24 77 | fmt.Printf("%f", 2.0) // 2.000000 78 | fmt.Printf("%s", humanize.Ftoa(2.0)) // 2 79 | ``` 80 | 81 | ## SI notation 82 | 83 | Format numbers with [SI notation][sinotation]. 84 | 85 | Example: 86 | 87 | ```go 88 | humanize.SI(0.00000000223, "M") // 2.23 nM 89 | ``` 90 | 91 | ## English-specific functions 92 | 93 | The following functions are in the `humanize/english` subpackage. 94 | 95 | ### Plurals 96 | 97 | Simple English pluralization 98 | 99 | ```go 100 | english.PluralWord(1, "object", "") // object 101 | english.PluralWord(42, "object", "") // objects 102 | english.PluralWord(2, "bus", "") // buses 103 | english.PluralWord(99, "locus", "loci") // loci 104 | 105 | english.Plural(1, "object", "") // 1 object 106 | english.Plural(42, "object", "") // 42 objects 107 | english.Plural(2, "bus", "") // 2 buses 108 | english.Plural(99, "locus", "loci") // 99 loci 109 | ``` 110 | 111 | ### Word series 112 | 113 | Format comma-separated words lists with conjuctions: 114 | 115 | ```go 116 | english.WordSeries([]string{"foo"}, "and") // foo 117 | english.WordSeries([]string{"foo", "bar"}, "and") // foo and bar 118 | english.WordSeries([]string{"foo", "bar", "baz"}, "and") // foo, bar and baz 119 | 120 | english.OxfordWordSeries([]string{"foo", "bar", "baz"}, "and") // foo, bar, and baz 121 | ``` 122 | 123 | [odisc]: https://groups.google.com/d/topic/golang-nuts/l8NhI74jl-4/discussion 124 | [sinotation]: http://en.wikipedia.org/wiki/Metric_prefix 125 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/times.go: -------------------------------------------------------------------------------- 1 | package humanize 2 | 3 | import ( 4 | "fmt" 5 | "math" 6 | "sort" 7 | "time" 8 | ) 9 | 10 | // Seconds-based time units 11 | const ( 12 | Day = 24 * time.Hour 13 | Week = 7 * Day 14 | Month = 30 * Day 15 | Year = 12 * Month 16 | LongTime = 37 * Year 17 | ) 18 | 19 | // Time formats a time into a relative string. 20 | // 21 | // Time(someT) -> "3 weeks ago" 22 | func Time(then time.Time) string { 23 | return RelTime(then, time.Now(), "ago", "from now") 24 | } 25 | 26 | // A RelTimeMagnitude struct contains a relative time point at which 27 | // the relative format of time will switch to a new format string. A 28 | // slice of these in ascending order by their "D" field is passed to 29 | // CustomRelTime to format durations. 30 | // 31 | // The Format field is a string that may contain a "%s" which will be 32 | // replaced with the appropriate signed label (e.g. "ago" or "from 33 | // now") and a "%d" that will be replaced by the quantity. 34 | // 35 | // The DivBy field is the amount of time the time difference must be 36 | // divided by in order to display correctly. 37 | // 38 | // e.g. if D is 2*time.Minute and you want to display "%d minutes %s" 39 | // DivBy should be time.Minute so whatever the duration is will be 40 | // expressed in minutes. 41 | type RelTimeMagnitude struct { 42 | D time.Duration 43 | Format string 44 | DivBy time.Duration 45 | } 46 | 47 | var defaultMagnitudes = []RelTimeMagnitude{ 48 | {time.Second, "now", time.Second}, 49 | {2 * time.Second, "1 second %s", 1}, 50 | {time.Minute, "%d seconds %s", time.Second}, 51 | {2 * time.Minute, "1 minute %s", 1}, 52 | {time.Hour, "%d minutes %s", time.Minute}, 53 | {2 * time.Hour, "1 hour %s", 1}, 54 | {Day, "%d hours %s", time.Hour}, 55 | {2 * Day, "1 day %s", 1}, 56 | {Week, "%d days %s", Day}, 57 | {2 * Week, "1 week %s", 1}, 58 | {Month, "%d weeks %s", Week}, 59 | {2 * Month, "1 month %s", 1}, 60 | {Year, "%d months %s", Month}, 61 | {18 * Month, "1 year %s", 1}, 62 | {2 * Year, "2 years %s", 1}, 63 | {LongTime, "%d years %s", Year}, 64 | {math.MaxInt64, "a long while %s", 1}, 65 | } 66 | 67 | // RelTime formats a time into a relative string. 68 | // 69 | // It takes two times and two labels. In addition to the generic time 70 | // delta string (e.g. 5 minutes), the labels are used applied so that 71 | // the label corresponding to the smaller time is applied. 72 | // 73 | // RelTime(timeInPast, timeInFuture, "earlier", "later") -> "3 weeks earlier" 74 | func RelTime(a, b time.Time, albl, blbl string) string { 75 | return CustomRelTime(a, b, albl, blbl, defaultMagnitudes) 76 | } 77 | 78 | // CustomRelTime formats a time into a relative string. 79 | // 80 | // It takes two times two labels and a table of relative time formats. 81 | // In addition to the generic time delta string (e.g. 5 minutes), the 82 | // labels are used applied so that the label corresponding to the 83 | // smaller time is applied. 84 | func CustomRelTime(a, b time.Time, albl, blbl string, magnitudes []RelTimeMagnitude) string { 85 | lbl := albl 86 | diff := b.Sub(a) 87 | 88 | if a.After(b) { 89 | lbl = blbl 90 | diff = a.Sub(b) 91 | } 92 | 93 | n := sort.Search(len(magnitudes), func(i int) bool { 94 | return magnitudes[i].D > diff 95 | }) 96 | 97 | if n >= len(magnitudes) { 98 | n = len(magnitudes) - 1 99 | } 100 | mag := magnitudes[n] 101 | args := []interface{}{} 102 | escaped := false 103 | for _, ch := range mag.Format { 104 | if escaped { 105 | switch ch { 106 | case 's': 107 | args = append(args, lbl) 108 | case 'd': 109 | args = append(args, diff/mag.DivBy) 110 | } 111 | escaped = false 112 | } else { 113 | escaped = ch == '%' 114 | } 115 | } 116 | return fmt.Sprintf(mag.Format, args...) 117 | } 118 | -------------------------------------------------------------------------------- /vendor/github.com/shawnsmithdev/zermelo/zfloat32/zfloat32.go: -------------------------------------------------------------------------------- 1 | // Radix sort for []float32. 2 | package zfloat32 3 | 4 | import ( 5 | "math" 6 | "sort" 7 | ) 8 | 9 | const ( 10 | // Calling Sort() on slices smaller than this will result is sorting with sort.Sort() instead. 11 | MinSize = 256 12 | radix uint = 8 13 | radixShift uint = 3 14 | bitSize uint = 32 15 | ) 16 | 17 | // Sorts x using a Radix sort (Small slices are sorted with sort.Sort() instead). 18 | func Sort(x []float32) { 19 | if len(x) < MinSize { 20 | sort.Sort(float32Sortable(x)) 21 | } else { 22 | SortBYOB(x, make([]float32, len(x))) 23 | } 24 | } 25 | 26 | // Similar to Sort(), but returns a sorted copy of x, leaving x unmodified. 27 | func SortCopy(x []float32) []float32 { 28 | y := make([]float32, len(x)) 29 | copy(y, x) 30 | Sort(y) 31 | return y 32 | } 33 | 34 | // Sorts x using a Radix sort, using supplied buffer space. Panics if 35 | // len(x) is greater than len(buffer). Uses radix sort even on small slices. 36 | func SortBYOB(x, buffer []float32) { 37 | if len(x) > len(buffer) { 38 | panic("Buffer too small") 39 | } 40 | if len(x) < 2 { 41 | return 42 | } 43 | 44 | // Don't sort NaNs, just put them up front and skip them 45 | nans := 0 46 | for idx, val := range x { 47 | if math.IsNaN(float64(val)) { 48 | x[idx] = x[nans] 49 | x[nans] = val 50 | nans++ 51 | } 52 | } 53 | 54 | // Each pass processes a byte offset, copying back and forth between slices 55 | from := x[nans:] 56 | to := buffer[:len(from)] 57 | var key uint8 58 | var uintVal uint32 59 | var offset [256]int // Keep track of where room is made for byte groups in the buffer 60 | 61 | for keyOffset := uint(0); keyOffset < bitSize; keyOffset += radix { 62 | keyMask := uint32(0xFF << keyOffset) // Current 'digit' to look at 63 | var counts [256]int // Keep track of the number of elements for each kind of byte 64 | sorted := true // Check for already sorted 65 | prev := float32(0) // if elem is always >= prev it is already sorted 66 | 67 | for _, val := range from { 68 | uintVal = floatFlip(math.Float32bits(val)) 69 | key = uint8((uintVal & keyMask) >> keyOffset) // fetch the byte at current 'digit' 70 | counts[key]++ // count of values to put in this digit's bucket 71 | if sorted { // Detect sorted 72 | sorted = val >= prev 73 | prev = val 74 | } 75 | } 76 | 77 | if sorted { // Short-circuit sorted 78 | if (keyOffset/radix)%2 == 1 { 79 | copy(to, from) 80 | } 81 | return 82 | } 83 | 84 | // Find target bucket offsets 85 | offset[0] = 0 86 | for i := 1; i < len(offset); i++ { 87 | offset[i] = offset[i-1] + counts[i-1] 88 | } 89 | 90 | // Rebucket while copying to other buffer 91 | for _, val := range from { 92 | uintVal = floatFlip(math.Float32bits(val)) 93 | key = uint8((uintVal & keyMask) >> keyOffset) // Get the digit 94 | to[offset[key]] = val // Copy the element to the digit's bucket 95 | offset[key]++ // One less space, move the offset 96 | } 97 | // On next pass copy data the other way 98 | to, from = from, to 99 | } 100 | } 101 | 102 | // Converts a uint32 that represents a true float to one sorts properly 103 | func floatFlip(x uint32) uint32 { 104 | if (x & 0x80000000) == 0x80000000 { 105 | return x ^ 0xFFFFFFFF 106 | } 107 | return x ^ 0x80000000 108 | } 109 | 110 | type float32Sortable []float32 111 | 112 | func (r float32Sortable) Len() int { return len(r) } 113 | func (r float32Sortable) Less(i, j int) bool { return r[i] < r[j] } 114 | func (r float32Sortable) Swap(i, j int) { r[i], r[j] = r[j], r[i] } 115 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/affinity_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // CPU affinity functions 6 | 7 | package unix 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | const cpuSetSize = _CPU_SETSIZE / _NCPUBITS 14 | 15 | // CPUSet represents a CPU affinity mask. 16 | type CPUSet [cpuSetSize]cpuMask 17 | 18 | func schedAffinity(trap uintptr, pid int, set *CPUSet) error { 19 | _, _, e := RawSyscall(trap, uintptr(pid), uintptr(unsafe.Sizeof(*set)), uintptr(unsafe.Pointer(set))) 20 | if e != 0 { 21 | return errnoErr(e) 22 | } 23 | return nil 24 | } 25 | 26 | // SchedGetaffinity gets the CPU affinity mask of the thread specified by pid. 27 | // If pid is 0 the calling thread is used. 28 | func SchedGetaffinity(pid int, set *CPUSet) error { 29 | return schedAffinity(SYS_SCHED_GETAFFINITY, pid, set) 30 | } 31 | 32 | // SchedSetaffinity sets the CPU affinity mask of the thread specified by pid. 33 | // If pid is 0 the calling thread is used. 34 | func SchedSetaffinity(pid int, set *CPUSet) error { 35 | return schedAffinity(SYS_SCHED_SETAFFINITY, pid, set) 36 | } 37 | 38 | // Zero clears the set s, so that it contains no CPUs. 39 | func (s *CPUSet) Zero() { 40 | for i := range s { 41 | s[i] = 0 42 | } 43 | } 44 | 45 | func cpuBitsIndex(cpu int) int { 46 | return cpu / _NCPUBITS 47 | } 48 | 49 | func cpuBitsMask(cpu int) cpuMask { 50 | return cpuMask(1 << (uint(cpu) % _NCPUBITS)) 51 | } 52 | 53 | // Set adds cpu to the set s. 54 | func (s *CPUSet) Set(cpu int) { 55 | i := cpuBitsIndex(cpu) 56 | if i < len(s) { 57 | s[i] |= cpuBitsMask(cpu) 58 | } 59 | } 60 | 61 | // Clear removes cpu from the set s. 62 | func (s *CPUSet) Clear(cpu int) { 63 | i := cpuBitsIndex(cpu) 64 | if i < len(s) { 65 | s[i] &^= cpuBitsMask(cpu) 66 | } 67 | } 68 | 69 | // IsSet reports whether cpu is in the set s. 70 | func (s *CPUSet) IsSet(cpu int) bool { 71 | i := cpuBitsIndex(cpu) 72 | if i < len(s) { 73 | return s[i]&cpuBitsMask(cpu) != 0 74 | } 75 | return false 76 | } 77 | 78 | // Count returns the number of CPUs in the set s. 79 | func (s *CPUSet) Count() int { 80 | c := 0 81 | for _, b := range s { 82 | c += onesCount64(uint64(b)) 83 | } 84 | return c 85 | } 86 | 87 | // onesCount64 is a copy of Go 1.9's math/bits.OnesCount64. 88 | // Once this package can require Go 1.9, we can delete this 89 | // and update the caller to use bits.OnesCount64. 90 | func onesCount64(x uint64) int { 91 | const m0 = 0x5555555555555555 // 01010101 ... 92 | const m1 = 0x3333333333333333 // 00110011 ... 93 | const m2 = 0x0f0f0f0f0f0f0f0f // 00001111 ... 94 | const m3 = 0x00ff00ff00ff00ff // etc. 95 | const m4 = 0x0000ffff0000ffff 96 | 97 | // Implementation: Parallel summing of adjacent bits. 98 | // See "Hacker's Delight", Chap. 5: Counting Bits. 99 | // The following pattern shows the general approach: 100 | // 101 | // x = x>>1&(m0&m) + x&(m0&m) 102 | // x = x>>2&(m1&m) + x&(m1&m) 103 | // x = x>>4&(m2&m) + x&(m2&m) 104 | // x = x>>8&(m3&m) + x&(m3&m) 105 | // x = x>>16&(m4&m) + x&(m4&m) 106 | // x = x>>32&(m5&m) + x&(m5&m) 107 | // return int(x) 108 | // 109 | // Masking (& operations) can be left away when there's no 110 | // danger that a field's sum will carry over into the next 111 | // field: Since the result cannot be > 64, 8 bits is enough 112 | // and we can ignore the masks for the shifts by 8 and up. 113 | // Per "Hacker's Delight", the first line can be simplified 114 | // more, but it saves at best one instruction, so we leave 115 | // it alone for clarity. 116 | const m = 1<<64 - 1 117 | x = x>>1&(m0&m) + x&(m0&m) 118 | x = x>>2&(m1&m) + x&(m1&m) 119 | x = (x>>4 + x) & (m2 & m) 120 | x += x >> 8 121 | x += x >> 16 122 | x += x >> 32 123 | return int(x) & (1<<7 - 1) 124 | } 125 | -------------------------------------------------------------------------------- /util.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "debug/elf" 5 | "fmt" 6 | 7 | "github.com/ianlancetaylor/demangle" 8 | ) 9 | 10 | // UtilConvHex converts a string to a C-like hexadecimal string literal 11 | func UtilConvHex(buf string) string { 12 | var hexBuf string 13 | 14 | for i := 0; i < len(buf); i++ { 15 | hexBuf += fmt.Sprintf("\\x%X", buf[i]) 16 | } 17 | 18 | return hexBuf 19 | } 20 | 21 | // UtilDemangle will demangle a symbol by string, this is 22 | // simply just a friendly wrapped around the demangle package 23 | func UtilDemangle(symbol *string) (string, error) { 24 | x, err := demangle.ToString(*symbol) 25 | if err != nil { 26 | return "", err 27 | } 28 | 29 | return x, nil 30 | } 31 | 32 | // UtilUniqueSlice will remove all duplicate instances 33 | // from the offset slice. 34 | func UtilUniqueSlice(s []uint64) []uint64 { 35 | seen := make(map[uint64]struct{}, len(s)) 36 | j := 0 37 | 38 | for _, v := range s { 39 | if _, ok := seen[v]; ok { 40 | continue 41 | } 42 | 43 | seen[v] = struct{}{} 44 | s[j] = v 45 | 46 | j++ 47 | } 48 | 49 | return s[:j] 50 | } 51 | 52 | // UtilIsNice will validate to make sure that the string in question 53 | // is of 'human readable' format 54 | func UtilIsNice(str string) bool { 55 | length := len(str) 56 | 57 | spaces := 0 58 | for i := 0; i < length; i++ { 59 | if str[i] == ' ' { 60 | spaces++ 61 | } 62 | 63 | if str[i] < ' ' && !(str[i] == '\r' || str[i] == '\n') { 64 | return false 65 | } 66 | } 67 | 68 | if spaces == length { 69 | return false 70 | } 71 | 72 | return true 73 | } 74 | 75 | // UtilConvertMachine will convert from elf.Machine type to a string. 76 | func UtilConvertMachine(mach elf.Machine) string { 77 | conv := map[elf.Machine]string{ 78 | elf.EM_386: "Intel 80386", 79 | elf.EM_68HC12: "Motorola M68HC12", 80 | elf.EM_68K: "Motorola 68000", 81 | elf.EM_860: "Intel 80860", 82 | elf.EM_88K: "Motorola 88000", 83 | elf.EM_960: "Intel 80960", 84 | elf.EM_ALPHA: "Digital Alpha", 85 | elf.EM_ARC: "Argonaut RISC Core, Argonaut Technologies Inc.", 86 | elf.EM_ARM: "Advanced RISC Machines ARM", 87 | elf.EM_COLDFIRE: "Motorola ColdFire", 88 | elf.EM_FR20: "Fujitsu FR20", 89 | elf.EM_H8_300: "Hitachi H8/300", 90 | elf.EM_H8_300H: "Hitachi H8/300H", 91 | elf.EM_H8S: "Hitachi H8S", 92 | elf.EM_IA_64: "Intel IA-64 processor architecture", 93 | elf.EM_M32: "AT&T WE 32100", 94 | elf.EM_ME16: "Toyota ME16 processor", 95 | elf.EM_MIPS: "MIPS I Architecture", 96 | elf.EM_MIPS_RS3_LE: "MIPS RS3000 Little-endian", 97 | elf.EM_MIPS_X: "Stanford MIPS-X", 98 | elf.EM_MMA: "Fujitsu MMA Multimedia Accelerator", 99 | elf.EM_NCPU: "Sony nCPU embedded RISC processor", 100 | elf.EM_NDR1: "Denso NDR1 microprocessor", 101 | elf.EM_NONE: "No machine", 102 | elf.EM_PARISC: "Hewlett-Packard PA-RISC", 103 | elf.EM_PCP: "Siemens PCP", 104 | elf.EM_PPC: "PowerPC", 105 | elf.EM_PPC64: "64-bit PowerPC", 106 | elf.EM_RCE: "Motorola RCE", 107 | elf.EM_RH32: "TRW RH-32", 108 | elf.EM_S370: "IBM System/370 Processor", 109 | elf.EM_SH: "Hitachi SH", 110 | elf.EM_SPARC: "SPARC", 111 | elf.EM_SPARC32PLUS: "Enhanced instruction set SPARC", 112 | elf.EM_SPARCV9: "SPARC Version 9", 113 | elf.EM_ST100: "STMicroelectronics ST100 processor", 114 | elf.EM_STARCORE: "Motorola Star*Core processor", 115 | elf.EM_TINYJ: "Advanced Logic Corp. TinyJ embedded processor family", 116 | elf.EM_TRICORE: "Siemens Tricore embedded processor", 117 | elf.EM_V800: "NEC V800", 118 | elf.EM_VPP500: "Fujitsu VPP500", 119 | elf.EM_X86_64: "x86_64"} 120 | 121 | if arch, ok := conv[mach]; ok { 122 | return arch 123 | } 124 | 125 | return conv[elf.EM_NONE] 126 | } 127 | -------------------------------------------------------------------------------- /vendor/github.com/shawnsmithdev/zermelo/README.md: -------------------------------------------------------------------------------- 1 | zermelo [![Build Status](https://travis-ci.org/shawnsmithdev/zermelo.svg)](https://travis-ci.org/shawnsmithdev/zermelo) [![GoDoc](https://godoc.org/github.com/shawnsmithdev/zermelo?status.png)](https://godoc.org/github.com/shawnsmithdev/zermelo) [![license](http://img.shields.io/badge/license-MIT-red.svg?style=flat)](https://raw.githubusercontent.com/shawnsmithdev/zermelo/master/LICENSE) 2 | ========= 3 | 4 | A radix sorting library for Go. Trade memory for speed! 5 | 6 | ```go 7 | import "github.com/shawnsmithdev/zermelo" 8 | 9 | func foo(large []uint64) 10 | zermelo.Sort(large) 11 | } 12 | ``` 13 | 14 | About 15 | ===== 16 | 17 | Zermelo is a sorting library featuring implementations of [radix sort](https://en.wikipedia.org/wiki/Radix_sort "Radix Sort"). I am especially influenced here by [these](http://codercorner.com/RadixSortRevisited.htm "Radix Sort Revisited") [two](http://stereopsis.com/radix.html "Radix Tricks") articles that describe various optimizations and how to work around the typical limitations of radix sort. 18 | 19 | You will generally only want to use zermelo if you won't mind the extra memory used for buffers and your application frequently sorts slices of supported types with at least 256 elements (128 for 32-bit types). The larger the slices you are sorting, the more benefit you will gain by using zermelo instead of the standard library's in-place comparison sort. 20 | 21 | Etymology 22 | --------- 23 | Zermelo is named after [Ernst Zermelo](http://en.wikipedia.org/wiki/Ernst_Zermelo), who developed the proof for the [well-ordering theorem](https://en.wikipedia.org/wiki/Well-ordering_theorem). 24 | 25 | Supported Types 26 | =============== 27 | * []float32 28 | * []float64 29 | * []int 30 | * []int32 31 | * []int64 32 | * []uint 33 | * []uint32 34 | * []uint64 35 | 36 | Subpackages 37 | =========== 38 | Zermelo provides individual subpackages for each of the supported types. Subpackages have a `SortBYOB()` method where you can Bring Your Own Buffer (BYOB), for minimizing allocations. Providing a buffer that is smaller than the slice you are sorting will cause a runtime panic. 39 | 40 | ```go 41 | import "github.com/shawnsmithdev/zermelo/zuint64" 42 | 43 | func foo(bar SomeRemoteData) 44 | data := make([]uint64, REALLY_BIG) 45 | buffer := make([]uint64, REALLY_BIG) 46 | 47 | while bar.hasMore() { 48 | bar.Read(data) 49 | zuint64.SortBYOB(data, buffer) 50 | doSomething(data) 51 | } 52 | } 53 | ``` 54 | 55 | Sorter 56 | ====== 57 | 58 | A Sorter will reuse buffers created during `Sort()` calls. This is not thread safe. Buffers are grown as needed at a 25% exponential growth rate. This means if you sort a slice of size `n`, subsequent calls with slices up to `n * 1.25` in length will not cause another buffer allocation. This does not apply to the first allocation, which will make a buffer of the same size as the requested slice. This way, if the slices being sorted do not grow in size, there is no unused buffer space. 59 | 60 | ```go 61 | import "github.com/shawnsmithdev/zermelo" 62 | 63 | func foo(bar [][]uint64) { 64 | sorter := zermelo.New() 65 | for _, x := range(bar) { 66 | sorter.Sort(x) 67 | } 68 | } 69 | 70 | ``` 71 | 72 | Benchmarks 73 | ========== 74 | 75 | Benchmarks are not a promise of anything. You'll always want to profile for your use case. 76 | 77 | You can run these on your own hardware 78 | 79 | ```Shell 80 | go test -v -bench . -benchmem 81 | ``` 82 | 83 | Run with go 1.4.1 on a 2013 Macbook Air w/ i7-4650U and 8GB ram. For ns/op, lower is better. 84 | 85 | []uint64 86 | -------- 87 | 88 | | slice len | golang ns/op | zermelo ns/op |Improvement|zermelo memory| 89 | |-----------|--------------|---------------|-----------|--------------| 90 | |64 |3783 |3617 | 4.39% | 32 B | 91 | |256 |25839 |20707 |19.86% | 2 KB | 92 | |65536 |14931449 |2593829 |82.63% | 512 KB | 93 | |1048576 |298591046 |53842130 |81.97% | 8 MB | 94 | 95 | []float64 96 | --------- 97 | 98 | | slice len | golang ns/op | zermelo ns/op |Improvement|zermelo memory| 99 | |-----------|--------------|---------------|-----------|--------------| 100 | |64 |6555 |6563 |-0.12% | 32 B | 101 | |256 |41307 |24639 |49.87% | 4 KB | 102 | |65536 |22999127 |3152232 |86.29% | 1 MB | 103 | |1048576 |464524162 |58010014 |87.51% | 16 MB | 104 | -------------------------------------------------------------------------------- /vendor/github.com/fatih/color/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package color is an ANSI color package to output colorized or SGR defined 3 | output to the standard output. The API can be used in several way, pick one 4 | that suits you. 5 | 6 | Use simple and default helper functions with predefined foreground colors: 7 | 8 | color.Cyan("Prints text in cyan.") 9 | 10 | // a newline will be appended automatically 11 | color.Blue("Prints %s in blue.", "text") 12 | 13 | // More default foreground colors.. 14 | color.Red("We have red") 15 | color.Yellow("Yellow color too!") 16 | color.Magenta("And many others ..") 17 | 18 | // Hi-intensity colors 19 | color.HiGreen("Bright green color.") 20 | color.HiBlack("Bright black means gray..") 21 | color.HiWhite("Shiny white color!") 22 | 23 | However there are times where custom color mixes are required. Below are some 24 | examples to create custom color objects and use the print functions of each 25 | separate color object. 26 | 27 | // Create a new color object 28 | c := color.New(color.FgCyan).Add(color.Underline) 29 | c.Println("Prints cyan text with an underline.") 30 | 31 | // Or just add them to New() 32 | d := color.New(color.FgCyan, color.Bold) 33 | d.Printf("This prints bold cyan %s\n", "too!.") 34 | 35 | 36 | // Mix up foreground and background colors, create new mixes! 37 | red := color.New(color.FgRed) 38 | 39 | boldRed := red.Add(color.Bold) 40 | boldRed.Println("This will print text in bold red.") 41 | 42 | whiteBackground := red.Add(color.BgWhite) 43 | whiteBackground.Println("Red text with White background.") 44 | 45 | // Use your own io.Writer output 46 | color.New(color.FgBlue).Fprintln(myWriter, "blue color!") 47 | 48 | blue := color.New(color.FgBlue) 49 | blue.Fprint(myWriter, "This will print text in blue.") 50 | 51 | You can create PrintXxx functions to simplify even more: 52 | 53 | // Create a custom print function for convenient 54 | red := color.New(color.FgRed).PrintfFunc() 55 | red("warning") 56 | red("error: %s", err) 57 | 58 | // Mix up multiple attributes 59 | notice := color.New(color.Bold, color.FgGreen).PrintlnFunc() 60 | notice("don't forget this...") 61 | 62 | You can also FprintXxx functions to pass your own io.Writer: 63 | 64 | blue := color.New(FgBlue).FprintfFunc() 65 | blue(myWriter, "important notice: %s", stars) 66 | 67 | // Mix up with multiple attributes 68 | success := color.New(color.Bold, color.FgGreen).FprintlnFunc() 69 | success(myWriter, don't forget this...") 70 | 71 | 72 | Or create SprintXxx functions to mix strings with other non-colorized strings: 73 | 74 | yellow := New(FgYellow).SprintFunc() 75 | red := New(FgRed).SprintFunc() 76 | 77 | fmt.Printf("this is a %s and this is %s.\n", yellow("warning"), red("error")) 78 | 79 | info := New(FgWhite, BgGreen).SprintFunc() 80 | fmt.Printf("this %s rocks!\n", info("package")) 81 | 82 | Windows support is enabled by default. All Print functions work as intended. 83 | However only for color.SprintXXX functions, user should use fmt.FprintXXX and 84 | set the output to color.Output: 85 | 86 | fmt.Fprintf(color.Output, "Windows support: %s", color.GreenString("PASS")) 87 | 88 | info := New(FgWhite, BgGreen).SprintFunc() 89 | fmt.Fprintf(color.Output, "this %s rocks!\n", info("package")) 90 | 91 | Using with existing code is possible. Just use the Set() method to set the 92 | standard output to the given parameters. That way a rewrite of an existing 93 | code is not required. 94 | 95 | // Use handy standard colors. 96 | color.Set(color.FgYellow) 97 | 98 | fmt.Println("Existing text will be now in Yellow") 99 | fmt.Printf("This one %s\n", "too") 100 | 101 | color.Unset() // don't forget to unset 102 | 103 | // You can mix up parameters 104 | color.Set(color.FgMagenta, color.Bold) 105 | defer color.Unset() // use it in your function 106 | 107 | fmt.Println("All text will be now bold magenta.") 108 | 109 | There might be a case where you want to disable color output (for example to 110 | pipe the standard output of your app to somewhere else). `Color` has support to 111 | disable colors both globally and for single color definition. For example 112 | suppose you have a CLI app and a `--no-color` bool flag. You can easily disable 113 | the color output with: 114 | 115 | var flagNoColor = flag.Bool("no-color", false, "Disable color output") 116 | 117 | if *flagNoColor { 118 | color.NoColor = true // disables colorized output 119 | } 120 | 121 | It also has support for single color definitions (local). You can 122 | disable/enable color output on the fly: 123 | 124 | c := color.New(color.FgCyan) 125 | c.Println("Prints cyan text") 126 | 127 | c.DisableColor() 128 | c.Println("This is printed without any color") 129 | 130 | c.EnableColor() 131 | c.Println("This prints again cyan...") 132 | */ 133 | package color 134 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/bigbytes.go: -------------------------------------------------------------------------------- 1 | package humanize 2 | 3 | import ( 4 | "fmt" 5 | "math/big" 6 | "strings" 7 | "unicode" 8 | ) 9 | 10 | var ( 11 | bigIECExp = big.NewInt(1024) 12 | 13 | // BigByte is one byte in bit.Ints 14 | BigByte = big.NewInt(1) 15 | // BigKiByte is 1,024 bytes in bit.Ints 16 | BigKiByte = (&big.Int{}).Mul(BigByte, bigIECExp) 17 | // BigMiByte is 1,024 k bytes in bit.Ints 18 | BigMiByte = (&big.Int{}).Mul(BigKiByte, bigIECExp) 19 | // BigGiByte is 1,024 m bytes in bit.Ints 20 | BigGiByte = (&big.Int{}).Mul(BigMiByte, bigIECExp) 21 | // BigTiByte is 1,024 g bytes in bit.Ints 22 | BigTiByte = (&big.Int{}).Mul(BigGiByte, bigIECExp) 23 | // BigPiByte is 1,024 t bytes in bit.Ints 24 | BigPiByte = (&big.Int{}).Mul(BigTiByte, bigIECExp) 25 | // BigEiByte is 1,024 p bytes in bit.Ints 26 | BigEiByte = (&big.Int{}).Mul(BigPiByte, bigIECExp) 27 | // BigZiByte is 1,024 e bytes in bit.Ints 28 | BigZiByte = (&big.Int{}).Mul(BigEiByte, bigIECExp) 29 | // BigYiByte is 1,024 z bytes in bit.Ints 30 | BigYiByte = (&big.Int{}).Mul(BigZiByte, bigIECExp) 31 | ) 32 | 33 | var ( 34 | bigSIExp = big.NewInt(1000) 35 | 36 | // BigSIByte is one SI byte in big.Ints 37 | BigSIByte = big.NewInt(1) 38 | // BigKByte is 1,000 SI bytes in big.Ints 39 | BigKByte = (&big.Int{}).Mul(BigSIByte, bigSIExp) 40 | // BigMByte is 1,000 SI k bytes in big.Ints 41 | BigMByte = (&big.Int{}).Mul(BigKByte, bigSIExp) 42 | // BigGByte is 1,000 SI m bytes in big.Ints 43 | BigGByte = (&big.Int{}).Mul(BigMByte, bigSIExp) 44 | // BigTByte is 1,000 SI g bytes in big.Ints 45 | BigTByte = (&big.Int{}).Mul(BigGByte, bigSIExp) 46 | // BigPByte is 1,000 SI t bytes in big.Ints 47 | BigPByte = (&big.Int{}).Mul(BigTByte, bigSIExp) 48 | // BigEByte is 1,000 SI p bytes in big.Ints 49 | BigEByte = (&big.Int{}).Mul(BigPByte, bigSIExp) 50 | // BigZByte is 1,000 SI e bytes in big.Ints 51 | BigZByte = (&big.Int{}).Mul(BigEByte, bigSIExp) 52 | // BigYByte is 1,000 SI z bytes in big.Ints 53 | BigYByte = (&big.Int{}).Mul(BigZByte, bigSIExp) 54 | ) 55 | 56 | var bigBytesSizeTable = map[string]*big.Int{ 57 | "b": BigByte, 58 | "kib": BigKiByte, 59 | "kb": BigKByte, 60 | "mib": BigMiByte, 61 | "mb": BigMByte, 62 | "gib": BigGiByte, 63 | "gb": BigGByte, 64 | "tib": BigTiByte, 65 | "tb": BigTByte, 66 | "pib": BigPiByte, 67 | "pb": BigPByte, 68 | "eib": BigEiByte, 69 | "eb": BigEByte, 70 | "zib": BigZiByte, 71 | "zb": BigZByte, 72 | "yib": BigYiByte, 73 | "yb": BigYByte, 74 | // Without suffix 75 | "": BigByte, 76 | "ki": BigKiByte, 77 | "k": BigKByte, 78 | "mi": BigMiByte, 79 | "m": BigMByte, 80 | "gi": BigGiByte, 81 | "g": BigGByte, 82 | "ti": BigTiByte, 83 | "t": BigTByte, 84 | "pi": BigPiByte, 85 | "p": BigPByte, 86 | "ei": BigEiByte, 87 | "e": BigEByte, 88 | "z": BigZByte, 89 | "zi": BigZiByte, 90 | "y": BigYByte, 91 | "yi": BigYiByte, 92 | } 93 | 94 | var ten = big.NewInt(10) 95 | 96 | func humanateBigBytes(s, base *big.Int, sizes []string) string { 97 | if s.Cmp(ten) < 0 { 98 | return fmt.Sprintf("%d B", s) 99 | } 100 | c := (&big.Int{}).Set(s) 101 | val, mag := oomm(c, base, len(sizes)-1) 102 | suffix := sizes[mag] 103 | f := "%.0f %s" 104 | if val < 10 { 105 | f = "%.1f %s" 106 | } 107 | 108 | return fmt.Sprintf(f, val, suffix) 109 | 110 | } 111 | 112 | // BigBytes produces a human readable representation of an SI size. 113 | // 114 | // See also: ParseBigBytes. 115 | // 116 | // BigBytes(82854982) -> 83 MB 117 | func BigBytes(s *big.Int) string { 118 | sizes := []string{"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"} 119 | return humanateBigBytes(s, bigSIExp, sizes) 120 | } 121 | 122 | // BigIBytes produces a human readable representation of an IEC size. 123 | // 124 | // See also: ParseBigBytes. 125 | // 126 | // BigIBytes(82854982) -> 79 MiB 127 | func BigIBytes(s *big.Int) string { 128 | sizes := []string{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"} 129 | return humanateBigBytes(s, bigIECExp, sizes) 130 | } 131 | 132 | // ParseBigBytes parses a string representation of bytes into the number 133 | // of bytes it represents. 134 | // 135 | // See also: BigBytes, BigIBytes. 136 | // 137 | // ParseBigBytes("42 MB") -> 42000000, nil 138 | // ParseBigBytes("42 mib") -> 44040192, nil 139 | func ParseBigBytes(s string) (*big.Int, error) { 140 | lastDigit := 0 141 | hasComma := false 142 | for _, r := range s { 143 | if !(unicode.IsDigit(r) || r == '.' || r == ',') { 144 | break 145 | } 146 | if r == ',' { 147 | hasComma = true 148 | } 149 | lastDigit++ 150 | } 151 | 152 | num := s[:lastDigit] 153 | if hasComma { 154 | num = strings.Replace(num, ",", "", -1) 155 | } 156 | 157 | val := &big.Rat{} 158 | _, err := fmt.Sscanf(num, "%f", val) 159 | if err != nil { 160 | return nil, err 161 | } 162 | 163 | extra := strings.ToLower(strings.TrimSpace(s[lastDigit:])) 164 | if m, ok := bigBytesSizeTable[extra]; ok { 165 | mv := (&big.Rat{}).SetInt(m) 166 | val.Mul(val, mv) 167 | rv := &big.Int{} 168 | rv.Div(val.Num(), val.Denom()) 169 | return rv, nil 170 | } 171 | 172 | return nil, fmt.Errorf("unhandled size name: %v", extra) 173 | } 174 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/number.go: -------------------------------------------------------------------------------- 1 | package humanize 2 | 3 | /* 4 | Slightly adapted from the source to fit go-humanize. 5 | 6 | Author: https://github.com/gorhill 7 | Source: https://gist.github.com/gorhill/5285193 8 | 9 | */ 10 | 11 | import ( 12 | "math" 13 | "strconv" 14 | ) 15 | 16 | var ( 17 | renderFloatPrecisionMultipliers = [...]float64{ 18 | 1, 19 | 10, 20 | 100, 21 | 1000, 22 | 10000, 23 | 100000, 24 | 1000000, 25 | 10000000, 26 | 100000000, 27 | 1000000000, 28 | } 29 | 30 | renderFloatPrecisionRounders = [...]float64{ 31 | 0.5, 32 | 0.05, 33 | 0.005, 34 | 0.0005, 35 | 0.00005, 36 | 0.000005, 37 | 0.0000005, 38 | 0.00000005, 39 | 0.000000005, 40 | 0.0000000005, 41 | } 42 | ) 43 | 44 | // FormatFloat produces a formatted number as string based on the following user-specified criteria: 45 | // * thousands separator 46 | // * decimal separator 47 | // * decimal precision 48 | // 49 | // Usage: s := RenderFloat(format, n) 50 | // The format parameter tells how to render the number n. 51 | // 52 | // See examples: http://play.golang.org/p/LXc1Ddm1lJ 53 | // 54 | // Examples of format strings, given n = 12345.6789: 55 | // "#,###.##" => "12,345.67" 56 | // "#,###." => "12,345" 57 | // "#,###" => "12345,678" 58 | // "#\u202F###,##" => "12 345,68" 59 | // "#.###,###### => 12.345,678900 60 | // "" (aka default format) => 12,345.67 61 | // 62 | // The highest precision allowed is 9 digits after the decimal symbol. 63 | // There is also a version for integer number, FormatInteger(), 64 | // which is convenient for calls within template. 65 | func FormatFloat(format string, n float64) string { 66 | // Special cases: 67 | // NaN = "NaN" 68 | // +Inf = "+Infinity" 69 | // -Inf = "-Infinity" 70 | if math.IsNaN(n) { 71 | return "NaN" 72 | } 73 | if n > math.MaxFloat64 { 74 | return "Infinity" 75 | } 76 | if n < -math.MaxFloat64 { 77 | return "-Infinity" 78 | } 79 | 80 | // default format 81 | precision := 2 82 | decimalStr := "." 83 | thousandStr := "," 84 | positiveStr := "" 85 | negativeStr := "-" 86 | 87 | if len(format) > 0 { 88 | format := []rune(format) 89 | 90 | // If there is an explicit format directive, 91 | // then default values are these: 92 | precision = 9 93 | thousandStr = "" 94 | 95 | // collect indices of meaningful formatting directives 96 | formatIndx := []int{} 97 | for i, char := range format { 98 | if char != '#' && char != '0' { 99 | formatIndx = append(formatIndx, i) 100 | } 101 | } 102 | 103 | if len(formatIndx) > 0 { 104 | // Directive at index 0: 105 | // Must be a '+' 106 | // Raise an error if not the case 107 | // index: 0123456789 108 | // +0.000,000 109 | // +000,000.0 110 | // +0000.00 111 | // +0000 112 | if formatIndx[0] == 0 { 113 | if format[formatIndx[0]] != '+' { 114 | panic("RenderFloat(): invalid positive sign directive") 115 | } 116 | positiveStr = "+" 117 | formatIndx = formatIndx[1:] 118 | } 119 | 120 | // Two directives: 121 | // First is thousands separator 122 | // Raise an error if not followed by 3-digit 123 | // 0123456789 124 | // 0.000,000 125 | // 000,000.00 126 | if len(formatIndx) == 2 { 127 | if (formatIndx[1] - formatIndx[0]) != 4 { 128 | panic("RenderFloat(): thousands separator directive must be followed by 3 digit-specifiers") 129 | } 130 | thousandStr = string(format[formatIndx[0]]) 131 | formatIndx = formatIndx[1:] 132 | } 133 | 134 | // One directive: 135 | // Directive is decimal separator 136 | // The number of digit-specifier following the separator indicates wanted precision 137 | // 0123456789 138 | // 0.00 139 | // 000,0000 140 | if len(formatIndx) == 1 { 141 | decimalStr = string(format[formatIndx[0]]) 142 | precision = len(format) - formatIndx[0] - 1 143 | } 144 | } 145 | } 146 | 147 | // generate sign part 148 | var signStr string 149 | if n >= 0.000000001 { 150 | signStr = positiveStr 151 | } else if n <= -0.000000001 { 152 | signStr = negativeStr 153 | n = -n 154 | } else { 155 | signStr = "" 156 | n = 0.0 157 | } 158 | 159 | // split number into integer and fractional parts 160 | intf, fracf := math.Modf(n + renderFloatPrecisionRounders[precision]) 161 | 162 | // generate integer part string 163 | intStr := strconv.FormatInt(int64(intf), 10) 164 | 165 | // add thousand separator if required 166 | if len(thousandStr) > 0 { 167 | for i := len(intStr); i > 3; { 168 | i -= 3 169 | intStr = intStr[:i] + thousandStr + intStr[i:] 170 | } 171 | } 172 | 173 | // no fractional part, we can leave now 174 | if precision == 0 { 175 | return signStr + intStr 176 | } 177 | 178 | // generate fractional part 179 | fracStr := strconv.Itoa(int(fracf * renderFloatPrecisionMultipliers[precision])) 180 | // may need padding 181 | if len(fracStr) < precision { 182 | fracStr = "000000000000000"[:precision-len(fracStr)] + fracStr 183 | } 184 | 185 | return signStr + intStr + decimalStr + fracStr 186 | } 187 | 188 | // FormatInteger produces a formatted number as string. 189 | // See FormatFloat. 190 | func FormatInteger(format string, n int) string { 191 | return FormatFloat(format, float64(n)) 192 | } 193 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build ppc64 ppc64le 7 | 8 | package unix 9 | 10 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) 11 | //sys Dup2(oldfd int, newfd int) (err error) 12 | //sys Fchown(fd int, uid int, gid int) (err error) 13 | //sys Fstat(fd int, stat *Stat_t) (err error) 14 | //sys Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_NEWFSTATAT 15 | //sys Fstatfs(fd int, buf *Statfs_t) (err error) 16 | //sys Ftruncate(fd int, length int64) (err error) 17 | //sysnb Getegid() (egid int) 18 | //sysnb Geteuid() (euid int) 19 | //sysnb Getgid() (gid int) 20 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = SYS_UGETRLIMIT 21 | //sysnb Getuid() (uid int) 22 | //sysnb InotifyInit() (fd int, err error) 23 | //sys Ioperm(from int, num int, on int) (err error) 24 | //sys Iopl(level int) (err error) 25 | //sys Lchown(path string, uid int, gid int) (err error) 26 | //sys Listen(s int, n int) (err error) 27 | //sys Lstat(path string, stat *Stat_t) (err error) 28 | //sys Pause() (err error) 29 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 30 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 31 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK 32 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS__NEWSELECT 33 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) 34 | //sys Setfsgid(gid int) (err error) 35 | //sys Setfsuid(uid int) (err error) 36 | //sysnb Setregid(rgid int, egid int) (err error) 37 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error) 38 | //sysnb Setresuid(ruid int, euid int, suid int) (err error) 39 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 40 | //sysnb Setreuid(ruid int, euid int) (err error) 41 | //sys Shutdown(fd int, how int) (err error) 42 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) 43 | //sys Stat(path string, stat *Stat_t) (err error) 44 | //sys Statfs(path string, buf *Statfs_t) (err error) 45 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) = SYS_SYNC_FILE_RANGE2 46 | //sys Truncate(path string, length int64) (err error) 47 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 48 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 49 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 50 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 51 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) 52 | //sysnb setgroups(n int, list *_Gid_t) (err error) 53 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 54 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 55 | //sysnb socket(domain int, typ int, proto int) (fd int, err error) 56 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) 57 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 58 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 59 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 60 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 61 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 62 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 63 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 64 | 65 | //sysnb Gettimeofday(tv *Timeval) (err error) 66 | //sysnb Time(t *Time_t) (tt Time_t, err error) 67 | 68 | //sys Utime(path string, buf *Utimbuf) (err error) 69 | 70 | func setTimespec(sec, nsec int64) Timespec { 71 | return Timespec{Sec: sec, Nsec: nsec} 72 | } 73 | 74 | func setTimeval(sec, usec int64) Timeval { 75 | return Timeval{Sec: sec, Usec: usec} 76 | } 77 | 78 | func (r *PtraceRegs) PC() uint64 { return r.Nip } 79 | 80 | func (r *PtraceRegs) SetPC(pc uint64) { r.Nip = pc } 81 | 82 | func (iov *Iovec) SetLen(length int) { 83 | iov.Len = uint64(length) 84 | } 85 | 86 | func (msghdr *Msghdr) SetControllen(length int) { 87 | msghdr.Controllen = uint64(length) 88 | } 89 | 90 | func (cmsg *Cmsghdr) SetLen(length int) { 91 | cmsg.Len = uint64(length) 92 | } 93 | 94 | //sysnb pipe(p *[2]_C_int) (err error) 95 | 96 | func Pipe(p []int) (err error) { 97 | if len(p) != 2 { 98 | return EINVAL 99 | } 100 | var pp [2]_C_int 101 | err = pipe(&pp) 102 | p[0] = int(pp[0]) 103 | p[1] = int(pp[1]) 104 | return 105 | } 106 | 107 | //sysnb pipe2(p *[2]_C_int, flags int) (err error) 108 | 109 | func Pipe2(p []int, flags int) (err error) { 110 | if len(p) != 2 { 111 | return EINVAL 112 | } 113 | var pp [2]_C_int 114 | err = pipe2(&pp, flags) 115 | p[0] = int(pp[0]) 116 | p[1] = int(pp[1]) 117 | return 118 | } 119 | 120 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) 121 | 122 | func Poll(fds []PollFd, timeout int) (n int, err error) { 123 | if len(fds) == 0 { 124 | return poll(nil, 0, timeout) 125 | } 126 | return poll(&fds[0], len(fds), timeout) 127 | } 128 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "log" 7 | "os" 8 | "strings" 9 | 10 | humanize "github.com/dustin/go-humanize" 11 | "github.com/fatih/color" 12 | "github.com/shawnsmithdev/zermelo" 13 | ) 14 | 15 | var ( 16 | demangleOpt = flag.Bool("demangle", false, "demangle C++ symbols into their original source identifiers, prettify found C++ symbols (optional)") 17 | hexOpt = flag.Bool("hex", false, "output the strings as a hexadecimal literal (optional)") 18 | offsetOpt = flag.Bool("offset", true, "show the offset of the string in the section (default, recommended)") 19 | binaryOpt = flag.String("binary", "", "the path to the ELF you wish to parse") 20 | formatOpt = flag.String("output-format", "plain", "the format you want to output as (optional, plain/json/xml)") 21 | outputOpt = flag.String("output-file", "", "the path of the output file that you want to output to (optional)") 22 | maxOpt = flag.Uint64("max-count", 0, "the maximum amount of strings that you wish to be output (optional)") 23 | libOpt = flag.Bool("libs", false, "show the linked libraries in the binary (optional)") 24 | infoOpt = flag.Bool("no-info", false, "don't show any information about the binary") 25 | minOpt = flag.Uint64("min", 0, "the minimum length of the string") 26 | colorOpt = flag.Bool("no-color", false, "disable color output in the results") 27 | trimOpt = flag.Bool("no-trim", false, "disable triming whitespace and trailing newlines") 28 | humanOpt = flag.Bool("no-human", false, "don't validate that its a human readable string, this could increase the amount of junk.") 29 | ) 30 | 31 | // ReadSection is the main logic here 32 | // it combines all of the modules, etc. 33 | func ReadSection(reader *ElfReader, section string) { 34 | var err error 35 | var writer *OutWriter 36 | var count uint64 37 | 38 | sect := reader.ReaderParseSection(section) 39 | 40 | if *outputOpt != "" { 41 | writer, err = NewOutWriter(*outputOpt, OutParseTypeStr(*formatOpt)) 42 | if err != nil { 43 | log.Fatal(err.Error()) 44 | } 45 | } 46 | 47 | if sect != nil { 48 | nodes := reader.ReaderParseStrings(sect) 49 | 50 | // Since maps in Go are unsorted, we're going to have to make 51 | // a slice of keys, then iterate over this and just use the index 52 | // from the map. 53 | keys := make([]uint64, len(nodes)) 54 | for k, _ := range nodes { 55 | keys = append(keys, k) 56 | } 57 | 58 | err = zermelo.Sort(keys) 59 | if err != nil { 60 | return 61 | } 62 | 63 | keys = UtilUniqueSlice(keys) 64 | 65 | for _, off := range keys { 66 | if *maxOpt != 0 { 67 | if count == *maxOpt { 68 | break 69 | } 70 | } 71 | 72 | str := string(nodes[off]) 73 | if uint64(len(str)) < *minOpt { 74 | continue 75 | } 76 | 77 | if !*humanOpt { 78 | if !UtilIsNice(str) { 79 | continue 80 | } 81 | } 82 | 83 | str = strings.TrimSpace(str) 84 | 85 | if !*trimOpt { 86 | bad := []string{"\n", "\r"} 87 | for _, char := range bad { 88 | str = strings.Replace(str, char, "", -1) 89 | } 90 | } 91 | 92 | if *demangleOpt { 93 | demangled, err := UtilDemangle(&str) 94 | if err == nil { 95 | str = demangled 96 | } 97 | } 98 | 99 | if *hexOpt { 100 | str = UtilConvHex(str) 101 | } 102 | 103 | if *offsetOpt { 104 | if os.Getenv("NO_COLOR") != "" || *colorOpt { 105 | fmt.Printf("[%s+%#x]: %s\n", 106 | section, 107 | off, 108 | str) 109 | } else { 110 | fmt.Printf("[%s%s]: %s\n", 111 | color.BlueString(section), 112 | color.GreenString("+%#x", off), 113 | str) 114 | } 115 | } else { 116 | fmt.Println(str) 117 | } 118 | 119 | if writer != nil { 120 | writer.WriteResult(str, off) 121 | } 122 | 123 | count++ 124 | } 125 | } 126 | } 127 | 128 | // ReadBasic will read the basic information 129 | // about the ELF 130 | func ReadBasic(reader *ElfReader) { 131 | stat, err := reader.File.Stat() 132 | if err != nil { 133 | return 134 | } 135 | 136 | size := humanize.Bytes(uint64(stat.Size())) 137 | 138 | fmt.Printf( 139 | "[+] Size: %s\n"+ 140 | "[+] Arch: %s\n"+ 141 | "[+] Entry point: %#x\n"+ 142 | "[+] Class: %s\n"+ 143 | "[+] Byte order: %s\n", 144 | size, 145 | UtilConvertMachine(reader.ExecReader.Machine), 146 | reader.ExecReader.Entry, 147 | reader.ExecReader.Class.String(), 148 | reader.ExecReader.ByteOrder.String(), 149 | ) 150 | 151 | if *libOpt { 152 | fmt.Println("[+] Libraries:") 153 | libs, err := reader.ExecReader.ImportedLibraries() 154 | if err == nil { 155 | for _, lib := range libs { 156 | fmt.Printf("\t [!] %s\n", lib) 157 | } 158 | } 159 | } 160 | 161 | fmt.Println(strings.Repeat("-", 16)) 162 | } 163 | 164 | // main is the entrypoint for this program 165 | func main() { 166 | flag.Parse() 167 | 168 | if *binaryOpt == "" { 169 | flag.PrintDefaults() 170 | return 171 | } 172 | 173 | r, err := NewELFReader(*binaryOpt) 174 | if err != nil { 175 | log.Fatal(err.Error()) 176 | } 177 | 178 | defer r.Close() 179 | 180 | ReadBasic(r) 181 | 182 | sections := []string{".dynstr", ".rodata", ".rdata", 183 | ".strtab", ".comment", ".note", 184 | ".stab", ".stabstr", ".note.ABI-tag", ".note.gnu.build-id"} 185 | 186 | for _, section := range sections { 187 | ReadSection(r, section) 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /vendor/github.com/fatih/color/README.md: -------------------------------------------------------------------------------- 1 | # Color [![GoDoc](https://godoc.org/github.com/fatih/color?status.svg)](https://godoc.org/github.com/fatih/color) [![Build Status](https://img.shields.io/travis/fatih/color.svg?style=flat-square)](https://travis-ci.org/fatih/color) 2 | 3 | 4 | 5 | Color lets you use colorized outputs in terms of [ANSI Escape 6 | Codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors) in Go (Golang). It 7 | has support for Windows too! The API can be used in several ways, pick one that 8 | suits you. 9 | 10 | 11 | ![Color](https://i.imgur.com/c1JI0lA.png) 12 | 13 | 14 | ## Install 15 | 16 | ```bash 17 | go get github.com/fatih/color 18 | ``` 19 | 20 | Note that the `vendor` folder is here for stability. Remove the folder if you 21 | already have the dependencies in your GOPATH. 22 | 23 | ## Examples 24 | 25 | ### Standard colors 26 | 27 | ```go 28 | // Print with default helper functions 29 | color.Cyan("Prints text in cyan.") 30 | 31 | // A newline will be appended automatically 32 | color.Blue("Prints %s in blue.", "text") 33 | 34 | // These are using the default foreground colors 35 | color.Red("We have red") 36 | color.Magenta("And many others ..") 37 | 38 | ``` 39 | 40 | ### Mix and reuse colors 41 | 42 | ```go 43 | // Create a new color object 44 | c := color.New(color.FgCyan).Add(color.Underline) 45 | c.Println("Prints cyan text with an underline.") 46 | 47 | // Or just add them to New() 48 | d := color.New(color.FgCyan, color.Bold) 49 | d.Printf("This prints bold cyan %s\n", "too!.") 50 | 51 | // Mix up foreground and background colors, create new mixes! 52 | red := color.New(color.FgRed) 53 | 54 | boldRed := red.Add(color.Bold) 55 | boldRed.Println("This will print text in bold red.") 56 | 57 | whiteBackground := red.Add(color.BgWhite) 58 | whiteBackground.Println("Red text with white background.") 59 | ``` 60 | 61 | ### Use your own output (io.Writer) 62 | 63 | ```go 64 | // Use your own io.Writer output 65 | color.New(color.FgBlue).Fprintln(myWriter, "blue color!") 66 | 67 | blue := color.New(color.FgBlue) 68 | blue.Fprint(writer, "This will print text in blue.") 69 | ``` 70 | 71 | ### Custom print functions (PrintFunc) 72 | 73 | ```go 74 | // Create a custom print function for convenience 75 | red := color.New(color.FgRed).PrintfFunc() 76 | red("Warning") 77 | red("Error: %s", err) 78 | 79 | // Mix up multiple attributes 80 | notice := color.New(color.Bold, color.FgGreen).PrintlnFunc() 81 | notice("Don't forget this...") 82 | ``` 83 | 84 | ### Custom fprint functions (FprintFunc) 85 | 86 | ```go 87 | blue := color.New(FgBlue).FprintfFunc() 88 | blue(myWriter, "important notice: %s", stars) 89 | 90 | // Mix up with multiple attributes 91 | success := color.New(color.Bold, color.FgGreen).FprintlnFunc() 92 | success(myWriter, "Don't forget this...") 93 | ``` 94 | 95 | ### Insert into noncolor strings (SprintFunc) 96 | 97 | ```go 98 | // Create SprintXxx functions to mix strings with other non-colorized strings: 99 | yellow := color.New(color.FgYellow).SprintFunc() 100 | red := color.New(color.FgRed).SprintFunc() 101 | fmt.Printf("This is a %s and this is %s.\n", yellow("warning"), red("error")) 102 | 103 | info := color.New(color.FgWhite, color.BgGreen).SprintFunc() 104 | fmt.Printf("This %s rocks!\n", info("package")) 105 | 106 | // Use helper functions 107 | fmt.Println("This", color.RedString("warning"), "should be not neglected.") 108 | fmt.Printf("%v %v\n", color.GreenString("Info:"), "an important message.") 109 | 110 | // Windows supported too! Just don't forget to change the output to color.Output 111 | fmt.Fprintf(color.Output, "Windows support: %s", color.GreenString("PASS")) 112 | ``` 113 | 114 | ### Plug into existing code 115 | 116 | ```go 117 | // Use handy standard colors 118 | color.Set(color.FgYellow) 119 | 120 | fmt.Println("Existing text will now be in yellow") 121 | fmt.Printf("This one %s\n", "too") 122 | 123 | color.Unset() // Don't forget to unset 124 | 125 | // You can mix up parameters 126 | color.Set(color.FgMagenta, color.Bold) 127 | defer color.Unset() // Use it in your function 128 | 129 | fmt.Println("All text will now be bold magenta.") 130 | ``` 131 | 132 | ### Disable/Enable color 133 | 134 | There might be a case where you want to explicitly disable/enable color output. the 135 | `go-isatty` package will automatically disable color output for non-tty output streams 136 | (for example if the output were piped directly to `less`) 137 | 138 | `Color` has support to disable/enable colors both globally and for single color 139 | definitions. For example suppose you have a CLI app and a `--no-color` bool flag. You 140 | can easily disable the color output with: 141 | 142 | ```go 143 | 144 | var flagNoColor = flag.Bool("no-color", false, "Disable color output") 145 | 146 | if *flagNoColor { 147 | color.NoColor = true // disables colorized output 148 | } 149 | ``` 150 | 151 | It also has support for single color definitions (local). You can 152 | disable/enable color output on the fly: 153 | 154 | ```go 155 | c := color.New(color.FgCyan) 156 | c.Println("Prints cyan text") 157 | 158 | c.DisableColor() 159 | c.Println("This is printed without any color") 160 | 161 | c.EnableColor() 162 | c.Println("This prints again cyan...") 163 | ``` 164 | 165 | ## Todo 166 | 167 | * Save/Return previous values 168 | * Evaluate fmt.Formatter interface 169 | 170 | 171 | ## Credits 172 | 173 | * [Fatih Arslan](https://github.com/fatih) 174 | * Windows support via @mattn: [colorable](https://github.com/mattn/go-colorable) 175 | 176 | ## License 177 | 178 | The MIT License (MIT) - see [`LICENSE.md`](https://github.com/fatih/color/blob/master/LICENSE.md) for more details 179 | 180 | --------------------------------------------------------------------------------