├── .gitattributes ├── .gitignore ├── _examples ├── cli-onreload │ ├── on_reload.bat │ └── main.go └── main.go ├── vendor ├── github.com │ ├── kataras │ │ ├── pio │ │ │ ├── AUTHORS │ │ │ ├── terminal │ │ │ │ ├── terminal_linux.go │ │ │ │ ├── terminal_appengine.go │ │ │ │ ├── terminal_bsd.go │ │ │ │ ├── terminal_solaris.go │ │ │ │ ├── terminal_notwindows.go │ │ │ │ ├── LICENSE │ │ │ │ └── terminal_windows.go │ │ │ ├── nop.go │ │ │ ├── LICENSE │ │ │ ├── terminal.go │ │ │ ├── pio.go │ │ │ ├── color.go │ │ │ ├── hijacker.go │ │ │ ├── marshaler.go │ │ │ ├── adapter.go │ │ │ └── registry.go │ │ └── golog │ │ │ ├── AUTHORS │ │ │ ├── log.go │ │ │ ├── LICENSE │ │ │ └── integration.go │ └── fsnotify │ │ └── fsnotify │ │ ├── open_mode_bsd.go │ │ ├── open_mode_darwin.go │ │ ├── fen.go │ │ ├── LICENSE │ │ ├── fsnotify.go │ │ ├── AUTHORS │ │ └── inotify_poller.go └── golang.org │ └── x │ └── sys │ ├── AUTHORS │ ├── CONTRIBUTORS │ ├── 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 │ ├── mkpost.go │ ├── sockcmsg_unix.go │ ├── affinity_linux.go │ ├── syscall_linux_ppc64x.go │ ├── syscall_linux_sparc64.go │ ├── syscall_linux_amd64.go │ ├── cap_freebsd.go │ ├── mksysctl_openbsd.pl │ └── types_netbsd.go │ ├── PATENTS │ └── LICENSE ├── .travis.yml ├── snapcraft.yaml ├── LICENSE ├── rizla ├── watcher.go ├── project_test.go ├── walk_watcher.go └── signal_watcher.go ├── THIRDPARTY-LICENSE ├── HISTORY.md ├── main.go └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | *.go linguist-language=Go 2 | vendor/* linguist-vendored 3 | * text=auto -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .project 2 | .settings 3 | .vscode/* 4 | .atom-build.json 5 | *.exe 6 | *.txt 7 | */rizla_test.go 8 | -------------------------------------------------------------------------------- /_examples/cli-onreload/on_reload.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | echo Hello, custom script can goes here before reload, i.e build https://github.comkataras/bindata things! -------------------------------------------------------------------------------- /vendor/github.com/kataras/pio/AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the official list of PIO authors for copyright 2 | # purposes. 3 | 4 | Gerasimos Maropoulos -------------------------------------------------------------------------------- /vendor/github.com/kataras/golog/AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the official list of golog authors for copyright 2 | # purposes. 3 | 4 | Gerasimos Maropoulos -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/github.com/kataras/pio/terminal/terminal_linux.go: -------------------------------------------------------------------------------- 1 | // +build !appengine 2 | 3 | package terminal 4 | 5 | import "syscall" 6 | 7 | const ioctlReadTermios = syscall.TCGETS 8 | 9 | type Termios syscall.Termios 10 | -------------------------------------------------------------------------------- /vendor/github.com/kataras/pio/terminal/terminal_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package terminal 4 | 5 | import "io" 6 | 7 | // IsTerminal returns true if stderr's file descriptor is a terminal. 8 | func IsTerminal(f io.Writer) bool { 9 | return true 10 | } 11 | -------------------------------------------------------------------------------- /vendor/github.com/kataras/pio/terminal/terminal_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd openbsd netbsd dragonfly 2 | // +build !appengine 3 | 4 | package terminal 5 | 6 | import "syscall" 7 | 8 | const ioctlReadTermios = syscall.TIOCGETA 9 | 10 | type Termios syscall.Termios 11 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /_examples/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | ) 7 | 8 | // rizla main.go -host myhost.com -port 1193 9 | func main() { 10 | host := flag.String("host", "", "the host") 11 | port := flag.Int("port", 0, "the port") 12 | flag.Parse() 13 | fmt.Printf("The 'host' argument is: %v\n", *host) 14 | fmt.Printf("The 'port' argument is: %v\n", *port) 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/fsnotify/fsnotify/open_mode_bsd.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 freebsd openbsd netbsd dragonfly 6 | 7 | package fsnotify 8 | 9 | import "golang.org/x/sys/unix" 10 | 11 | const openMode = unix.O_NONBLOCK | unix.O_RDONLY 12 | -------------------------------------------------------------------------------- /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/github.com/fsnotify/fsnotify/open_mode_darwin.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 darwin 6 | 7 | package fsnotify 8 | 9 | import "golang.org/x/sys/unix" 10 | 11 | // note: this constant is not defined on BSD 12 | const openMode = unix.O_EVTONLY 13 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | os: 3 | - linux 4 | - osx 5 | go: 6 | - "go1.9" 7 | - "go1.10" 8 | go_import_path: github.com/kataras/rizla 9 | install: 10 | - go get ./... 11 | script: 12 | - go test -v -cover ./... 13 | after_script: 14 | # examples 15 | - cd ./_examples 16 | - go get ./... 17 | - go test -v -cover ./... 18 | - cd ../ 19 | 20 | after_success: 21 | - bash <(curl -s https://codecov.io/bash) 22 | -------------------------------------------------------------------------------- /snapcraft.yaml: -------------------------------------------------------------------------------- 1 | name: rizla 2 | version: git 3 | summary: Go Source Reloader. 4 | description: | 5 | Rizla builds, runs and monitors your Go Applications with ease. 6 | 7 | confinement: devmode 8 | base: core18 9 | 10 | parts: 11 | rizla: 12 | plugin: go 13 | go-importpath: github.com/kataras/rizla 14 | source: . 15 | source-type: git 16 | build-packages: 17 | - gcc 18 | 19 | apps: 20 | rizla: 21 | command: bin/rizla 22 | -------------------------------------------------------------------------------- /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/kataras/pio/terminal/terminal_solaris.go: -------------------------------------------------------------------------------- 1 | // +build solaris,!appengine 2 | 3 | package terminal 4 | 5 | import ( 6 | "io" 7 | "os" 8 | 9 | "golang.org/x/sys/unix" 10 | ) 11 | 12 | // IsTerminal returns true if the given file descriptor is a terminal. 13 | func IsTerminal(f io.Writer) bool { 14 | switch v := f.(type) { 15 | case *os.File: 16 | _, err := unix.IoctlGetTermios(int(v.Fd()), unix.TCGETA) 17 | return err == nil 18 | default: 19 | return false 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /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/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/github.com/kataras/pio/terminal/terminal_notwindows.go: -------------------------------------------------------------------------------- 1 | // +build linux darwin freebsd openbsd netbsd dragonfly 2 | // +build !appengine 3 | 4 | package terminal 5 | 6 | import ( 7 | "io" 8 | "os" 9 | "syscall" 10 | "unsafe" 11 | ) 12 | 13 | // IsTerminal returns true if stderr's file descriptor is a terminal. 14 | func IsTerminal(f io.Writer) bool { 15 | var termios Termios 16 | switch v := f.(type) { 17 | case *os.File: 18 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(v.Fd()), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 19 | return err == 0 20 | default: 21 | return false 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /_examples/cli-onreload/main.go: -------------------------------------------------------------------------------- 1 | // Package main shows you how you can execute commands on reload 2 | // in this example we will execute a simple bat file on windows 3 | // but you can pass anything, it just runs the `exec.Command` based on -onreload= flag's value. 4 | package main 5 | 6 | import ( 7 | "flag" 8 | "fmt" 9 | ) 10 | 11 | // rizla -onreload="on_reload.bat" main.go -host myhost.com -port 1193 12 | func main() { 13 | host := flag.String("host", "", "the host") 14 | port := flag.Int("port", 0, "the port") 15 | flag.Parse() 16 | fmt.Printf("The 'host' argument is: %v\n", *host) 17 | fmt.Printf("The 'port' argument is: %v\n", *port) 18 | } 19 | -------------------------------------------------------------------------------- /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/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/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/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/fsnotify/fsnotify/fen.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 solaris 6 | 7 | package fsnotify 8 | 9 | import ( 10 | "errors" 11 | ) 12 | 13 | // Watcher watches a set of files, delivering events to a channel. 14 | type Watcher struct { 15 | Events chan Event 16 | Errors chan error 17 | } 18 | 19 | // NewWatcher establishes a new watcher with the underlying OS and begins waiting for events. 20 | func NewWatcher() (*Watcher, error) { 21 | return nil, errors.New("FEN based watcher not yet supported for fsnotify\n") 22 | } 23 | 24 | // Close removes all watches and closes the events channel. 25 | func (w *Watcher) Close() error { 26 | return nil 27 | } 28 | 29 | // Add starts watching the named file or directory (non-recursively). 30 | func (w *Watcher) Add(name string) error { 31 | return nil 32 | } 33 | 34 | // Remove stops watching the the named file or directory (non-recursively). 35 | func (w *Watcher) Remove(name string) error { 36 | return nil 37 | } 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015-2018 Gerasimos Maropoulos 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/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/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/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 <= 10586 71 | } 72 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_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 calls for 386, Linux 11 | // 12 | 13 | // See ../runtime/sys_linux_386.s for the reason why we always use int 0x80 14 | // instead of the glibc-specific "CALL 0x10(GS)". 15 | #define INVOKE_SYSCALL INT $0x80 16 | 17 | // Just jump to package syscall's implementation for all these functions. 18 | // The runtime may know about them. 19 | 20 | TEXT ·Syscall(SB),NOSPLIT,$0-28 21 | JMP syscall·Syscall(SB) 22 | 23 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 24 | JMP syscall·Syscall6(SB) 25 | 26 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 27 | CALL runtime·entersyscall(SB) 28 | MOVL trap+0(FP), AX // syscall entry 29 | MOVL a1+4(FP), BX 30 | MOVL a2+8(FP), CX 31 | MOVL a3+12(FP), DX 32 | MOVL $0, SI 33 | MOVL $0, DI 34 | INVOKE_SYSCALL 35 | MOVL AX, r1+16(FP) 36 | MOVL DX, r2+20(FP) 37 | CALL runtime·exitsyscall(SB) 38 | RET 39 | 40 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 41 | JMP syscall·RawSyscall(SB) 42 | 43 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 44 | JMP syscall·RawSyscall6(SB) 45 | 46 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 47 | MOVL trap+0(FP), AX // syscall entry 48 | MOVL a1+4(FP), BX 49 | MOVL a2+8(FP), CX 50 | MOVL a3+12(FP), DX 51 | MOVL $0, SI 52 | MOVL $0, DI 53 | INVOKE_SYSCALL 54 | MOVL AX, r1+16(FP) 55 | MOVL DX, r2+20(FP) 56 | RET 57 | 58 | TEXT ·socketcall(SB),NOSPLIT,$0-36 59 | JMP syscall·socketcall(SB) 60 | 61 | TEXT ·rawsocketcall(SB),NOSPLIT,$0-36 62 | JMP syscall·rawsocketcall(SB) 63 | 64 | TEXT ·seek(SB),NOSPLIT,$0-28 65 | JMP syscall·seek(SB) 66 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_linux.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 by the Linux kernel and glibc. 7 | // 8 | // The information below is extracted and adapted from bits/sysmacros.h in the 9 | // glibc sources: 10 | // 11 | // dev_t in glibc is 64-bit, with 32-bit major and minor numbers. glibc's 12 | // default encoding is MMMM Mmmm mmmM MMmm, where M is a hex digit of the major 13 | // number and m is a hex digit of the minor number. This is backward compatible 14 | // with legacy systems where dev_t is 16 bits wide, encoded as MMmm. It is also 15 | // backward compatible with the Linux kernel, which for some architectures uses 16 | // 32-bit dev_t, encoded as mmmM MMmm. 17 | 18 | package unix 19 | 20 | // Major returns the major component of a Linux device number. 21 | func Major(dev uint64) uint32 { 22 | major := uint32((dev & 0x00000000000fff00) >> 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/github.com/fsnotify/fsnotify/fsnotify.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 !plan9 6 | 7 | // Package fsnotify provides a platform-independent interface for file system notifications. 8 | package fsnotify 9 | 10 | import ( 11 | "bytes" 12 | "errors" 13 | "fmt" 14 | ) 15 | 16 | // Event represents a single file system notification. 17 | type Event struct { 18 | Name string // Relative path to the file or directory. 19 | Op Op // File operation that triggered the event. 20 | } 21 | 22 | // Op describes a set of file operations. 23 | type Op uint32 24 | 25 | // These are the generalized file operations that can trigger a notification. 26 | const ( 27 | Create Op = 1 << iota 28 | Write 29 | Remove 30 | Rename 31 | Chmod 32 | ) 33 | 34 | func (op Op) String() string { 35 | // Use a buffer for efficient string concatenation 36 | var buffer bytes.Buffer 37 | 38 | if op&Create == Create { 39 | buffer.WriteString("|CREATE") 40 | } 41 | if op&Remove == Remove { 42 | buffer.WriteString("|REMOVE") 43 | } 44 | if op&Write == Write { 45 | buffer.WriteString("|WRITE") 46 | } 47 | if op&Rename == Rename { 48 | buffer.WriteString("|RENAME") 49 | } 50 | if op&Chmod == Chmod { 51 | buffer.WriteString("|CHMOD") 52 | } 53 | if buffer.Len() == 0 { 54 | return "" 55 | } 56 | return buffer.String()[1:] // Strip leading pipe 57 | } 58 | 59 | // String returns a string representation of the event in the form 60 | // "file: REMOVE|WRITE|..." 61 | func (e Event) String() string { 62 | return fmt.Sprintf("%q: %s", e.Name, e.Op.String()) 63 | } 64 | 65 | // Common errors that can be reported by a watcher 66 | var ErrEventOverflow = errors.New("fsnotify queue overflow") 67 | -------------------------------------------------------------------------------- /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/github.com/fsnotify/fsnotify/AUTHORS: -------------------------------------------------------------------------------- 1 | # Names should be added to this file as 2 | # Name or Organization 3 | # The email address is not required for organizations. 4 | 5 | # You can update this list using the following command: 6 | # 7 | # $ git shortlog -se | awk '{print $2 " " $3 " " $4}' 8 | 9 | # Please keep the list sorted. 10 | 11 | Aaron L 12 | Adrien Bustany 13 | Amit Krishnan 14 | Anmol Sethi 15 | Bjørn Erik Pedersen 16 | Bruno Bigras 17 | Caleb Spare 18 | Case Nelson 19 | Chris Howey 20 | Christoffer Buchholz 21 | Daniel Wagner-Hall 22 | Dave Cheney 23 | Evan Phoenix 24 | Francisco Souza 25 | Hari haran 26 | John C Barstow 27 | Kelvin Fo 28 | Ken-ichirou MATSUZAWA 29 | Matt Layher 30 | Nathan Youngman 31 | Nickolai Zeldovich 32 | Patrick 33 | Paul Hammond 34 | Pawel Knap 35 | Pieter Droogendijk 36 | Pursuit92 37 | Riku Voipio 38 | Rob Figueiredo 39 | Rodrigo Chiossi 40 | Slawek Ligus 41 | Soge Zhang 42 | Tiffany Jernigan 43 | Tilak Sharma 44 | Tom Payne 45 | Travis Cline 46 | Tudor Golubenco 47 | Vahe Khachikyan 48 | Yukang 49 | bronze1man 50 | debrando 51 | henrikedwards 52 | 铁哥 53 | -------------------------------------------------------------------------------- /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/github.com/kataras/pio/terminal/terminal_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows,!appengine 2 | 3 | package terminal 4 | 5 | import ( 6 | "bytes" 7 | "errors" 8 | "io" 9 | "os" 10 | "os/exec" 11 | "strconv" 12 | "strings" 13 | "syscall" 14 | "unsafe" 15 | ) 16 | 17 | var kernel32 = syscall.NewLazyDLL("kernel32.dll") 18 | 19 | var ( 20 | procGetConsoleMode = kernel32.NewProc("GetConsoleMode") 21 | procSetConsoleMode = kernel32.NewProc("SetConsoleMode") 22 | ) 23 | 24 | const ( 25 | enableProcessedOutput = 0x0001 26 | enableWrapAtEolOutput = 0x0002 27 | enableVirtualTerminalProcessing = 0x0004 28 | ) 29 | 30 | func getVersion() (float64, error) { 31 | stdout, stderr := &bytes.Buffer{}, &bytes.Buffer{} 32 | cmd := exec.Command("cmd", "ver") 33 | cmd.Stdout = stdout 34 | cmd.Stderr = stderr 35 | err := cmd.Run() 36 | if err != nil { 37 | return -1, err 38 | } 39 | 40 | // The output should be like "Microsoft Windows [Version XX.X.XXXXXX]" 41 | version := strings.Replace(stdout.String(), "\n", "", -1) 42 | version = strings.Replace(version, "\r\n", "", -1) 43 | 44 | x1 := strings.Index(version, "[Version") 45 | 46 | if x1 == -1 || strings.Index(version, "]") == -1 { 47 | return -1, errors.New("can't determine Windows version") 48 | } 49 | 50 | return strconv.ParseFloat(version[x1+9:x1+13], 64) 51 | } 52 | 53 | func init() { 54 | ver, err := getVersion() 55 | if err != nil { 56 | return 57 | } 58 | 59 | // Activate Virtual Processing for Windows CMD 60 | // Info: https://msdn.microsoft.com/en-us/library/windows/desktop/ms686033(v=vs.85).aspx 61 | if ver >= 10 { 62 | handle := syscall.Handle(os.Stderr.Fd()) 63 | procSetConsoleMode.Call(uintptr(handle), enableProcessedOutput|enableWrapAtEolOutput|enableVirtualTerminalProcessing) 64 | } 65 | } 66 | 67 | // IsTerminal returns true if stderr's file descriptor is a terminal. 68 | func IsTerminal(f io.Writer) bool { 69 | switch v := f.(type) { 70 | case *os.File: 71 | var st uint32 72 | r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(v.Fd()), uintptr(unsafe.Pointer(&st)), 0) 73 | return r != 0 && e == 0 74 | default: 75 | return false 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /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/kataras/golog/integration.go: -------------------------------------------------------------------------------- 1 | package golog 2 | 3 | // ExternalLogger is a typical logger interface. 4 | // Any logger or printer that completes this interface 5 | // can be used to intercept and handle the golog's messages. 6 | // 7 | // See `Logger#Install` and `Logger#Handle` for more. 8 | type ExternalLogger interface { 9 | Print(...interface{}) 10 | Println(...interface{}) 11 | Error(...interface{}) 12 | Warn(...interface{}) 13 | Info(...interface{}) 14 | Debug(...interface{}) 15 | } 16 | 17 | // integrateExternalLogger is a Handler which 18 | // intercepts all messages from print functions, 19 | // between print action and actual write to the output, 20 | // and sends these (messages) to the external "logger". 21 | // 22 | // In short terms, when this handler is passed via `Handle` 23 | // then, instead of printing from the logger's Printer 24 | // it prints from the given "logger". 25 | func integrateExternalLogger(logger ExternalLogger) Handler { 26 | return func(log *Log) bool { 27 | printFunc := getExternalPrintFunc(logger, log) 28 | printFunc(log.Message) 29 | return true 30 | } 31 | } 32 | 33 | func getExternalPrintFunc(logger ExternalLogger, log *Log) func(...interface{}) { 34 | switch log.Level { 35 | case ErrorLevel: 36 | return logger.Error 37 | case WarnLevel: 38 | return logger.Warn 39 | case InfoLevel: 40 | return logger.Info 41 | case DebugLevel: 42 | return logger.Debug 43 | } 44 | 45 | // disable level or use of golog#Print/Println functions: 46 | 47 | // passed with Println 48 | if log.NewLine { 49 | return logger.Println 50 | } 51 | 52 | return logger.Print 53 | } 54 | 55 | // StdLogger is the standard log.Logger interface. 56 | // Any logger or printer that completes this interface 57 | // can be used to intercept and handle the golog's messages. 58 | // 59 | // See `Logger#Install` and `Logger#Handle` for more. 60 | type StdLogger interface { 61 | Printf(format string, v ...interface{}) 62 | Print(v ...interface{}) 63 | Println(v ...interface{}) 64 | } 65 | 66 | func integrateStdLogger(logger StdLogger) Handler { 67 | return func(log *Log) bool { 68 | printFunc := getStdPrintFunc(logger, log) 69 | printFunc(log.Message) 70 | return true 71 | } 72 | } 73 | 74 | func getStdPrintFunc(logger StdLogger, log *Log) func(...interface{}) { 75 | // no levels here 76 | 77 | // passed with Println 78 | if log.NewLine { 79 | return logger.Println 80 | } 81 | 82 | return logger.Print 83 | } 84 | -------------------------------------------------------------------------------- /vendor/github.com/kataras/pio/pio.go: -------------------------------------------------------------------------------- 1 | package pio 2 | 3 | import ( 4 | "io" 5 | ) 6 | 7 | // NewLine is a slice of bytes which controls the 8 | // how a new line should be presented. 9 | // 10 | // Defaults to \n. 11 | var NewLine = []byte("\n") 12 | 13 | // Default returns the default, package-level registry instance. 14 | var Default = NewRegistry() 15 | 16 | // RegisterPrinter registers an already-created printer to the 17 | // registry. 18 | // 19 | // If a printer with the same `Name` is already 20 | // registered then it will be overridden by 21 | // this new "printer". 22 | // 23 | // Returns the Registry, therefore it can be used as builder. 24 | func RegisterPrinter(p *Printer) *Registry { 25 | return Default.RegisterPrinter(p) 26 | } 27 | 28 | // Register creates and registers a new Printer 29 | // based on a name(string) and an "output"(io.Writer). 30 | // 31 | // If a printer with the same `Name` is already 32 | // registered then it will be overridden by 33 | // this new "printer". 34 | // 35 | // Look `OutputFrom` too. 36 | // 37 | // Returns the just created Printer. 38 | func Register(printerName string, output io.Writer) *Printer { 39 | return Default.Register(printerName, output) 40 | } 41 | 42 | // Get returns a Printer based on the "printerName". 43 | // If printer with this name can't be found then 44 | // this function will return nil, so a check for 45 | // nil is always a good practice. 46 | func Get(printerName string) *Printer { 47 | return Default.Get(printerName) 48 | } 49 | 50 | // Remove deletes a printer item from the printers collection 51 | // by its name. 52 | func Remove(printerName string) { 53 | Default.Remove(printerName) 54 | } 55 | 56 | // Print accepts a value of "v", 57 | // tries to marshal its contents and flushes the result 58 | // to all available printers. 59 | func Print(v interface{}) (int, error) { 60 | return Default.Print(v) 61 | } 62 | 63 | // Println accepts a value of "v", 64 | // tries to marshal its contents and flushes the result 65 | // to all available printers, it adds a new line at the ending, 66 | // the result doesn't contain this new line, therefore result's contnets kept as expected. 67 | func Println(v interface{}) (int, error) { 68 | return Default.Println(v) 69 | } 70 | 71 | // Scan scans everything from "r" and prints 72 | // its new contents to the printers, 73 | // forever or until the returning "cancel" is fired, once. 74 | func Scan(r io.Reader, addNewLine bool) (cancel func()) { 75 | return Default.Scan(r, addNewLine) 76 | } 77 | -------------------------------------------------------------------------------- /rizla/walk_watcher.go: -------------------------------------------------------------------------------- 1 | package rizla 2 | 3 | import ( 4 | "errors" 5 | "os" 6 | "path/filepath" 7 | "time" 8 | ) 9 | 10 | type walkWatcher struct { 11 | // to stop the for loop 12 | stopChan chan bool 13 | hasStoppedManually bool 14 | errListeners []WatcherErrorListener 15 | changeListeners []WatcherChangeListener 16 | } 17 | 18 | var _ Watcher = &walkWatcher{} 19 | 20 | // newWalkWatcher returns a new golang's stdlib filepath.Walker's wrapper 21 | // which watching with every x milleseconds the projects' directories. 22 | func newWalkWatcher() Watcher { 23 | return &walkWatcher{ 24 | stopChan: make(chan bool, 1), 25 | } 26 | } 27 | 28 | func (w *walkWatcher) OnError(evt WatcherErrorListener) { 29 | w.errListeners = append(w.errListeners, evt) 30 | } 31 | 32 | func (w *walkWatcher) OnChange(evt WatcherChangeListener) { 33 | w.changeListeners = append(w.changeListeners, evt) 34 | } 35 | 36 | func (w *walkWatcher) Stop() { 37 | w.stopChan <- true 38 | } 39 | 40 | var errDoneNot = errors.New("done") 41 | 42 | // DefaultWalkLoopSleep it's the sleep time of the loop when --walk flag is used(`filepath#Walk`). 43 | // Defaults to 1.3 second. 44 | var DefaultWalkLoopSleep = 1350 * time.Second 45 | 46 | func (w *walkWatcher) loop(p *Project, stopChan chan bool) { 47 | for { 48 | select { 49 | case stop := <-stopChan: 50 | if stop { 51 | return 52 | } 53 | default: 54 | filepath.Walk(p.dir, func(path string, info os.FileInfo, err error) error { 55 | 56 | if filepath.Ext(path) == goExt && info.ModTime().After(p.lastChange) { 57 | for i := range w.changeListeners { 58 | w.changeListeners[i](p, path) 59 | } 60 | return errDoneNot 61 | } 62 | 63 | return nil 64 | }) 65 | // loop every 1.3 second. 66 | time.Sleep(DefaultWalkLoopSleep) 67 | } 68 | } 69 | } 70 | 71 | func (w *walkWatcher) Loop() { 72 | w.stopChan <- false 73 | 74 | for _, p := range projects { 75 | go w.loop(p, w.stopChan) 76 | } 77 | 78 | defer func() { 79 | for _, p := range projects { 80 | killProcess(p.proc, p.AppName) 81 | } 82 | if !w.hasStoppedManually { 83 | for i := range w.errListeners { 84 | w.errListeners[i](errUnexpected) 85 | } 86 | } 87 | }() 88 | 89 | for { 90 | select { 91 | case stop := <-w.stopChan: 92 | if stop { 93 | w.hasStoppedManually = true 94 | return 95 | } 96 | 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /vendor/github.com/kataras/pio/color.go: -------------------------------------------------------------------------------- 1 | package pio 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | var colorFormat = "\x1b[%dm%s\x1b[0m" 8 | 9 | func colorize(colorCode int, s string) string { 10 | return fmt.Sprintf(colorFormat, colorCode, s) 11 | } 12 | 13 | // ColorBlue represents the blue color. 14 | var ColorBlue = 34 15 | 16 | // Blue returns the string contents of "s" wrapped by blue foreground color. 17 | func Blue(s string) string { 18 | return colorize(ColorBlue, s) 19 | } 20 | 21 | // ColorLightGreen represents a light green color. 22 | var ColorLightGreen = 36 23 | 24 | // LightGreen returns the string contents of "s" wrapped by a light green foreground color. 25 | func LightGreen(s string) string { 26 | return colorize(ColorLightGreen, s) 27 | } 28 | 29 | // ColorPurple represents the purple color. 30 | var ColorPurple = 35 31 | 32 | // Purple returns the string contents of "s" wrapped by purple foreground color. 33 | func Purple(s string) string { 34 | return colorize(ColorPurple, s) 35 | } 36 | 37 | // ColorWhite represents the white color. 38 | var ColorWhite = 0 39 | 40 | // White returns the string contents of "s" wrapped by white foreground color. 41 | func White(s string) string { 42 | return colorize(ColorWhite, s) 43 | } 44 | 45 | // ColorGray represents the gray color. 46 | var ColorGray = 37 47 | 48 | // Gray returns the string contents of "s" wrapped by gray foreground color. 49 | func Gray(s string) string { 50 | return colorize(ColorGray, s) 51 | } 52 | 53 | // ColorRed represents the red color. 54 | var ColorRed = 31 55 | 56 | // Red returns the string contents of "s" wrapped by red foreground color. 57 | func Red(s string) string { 58 | return colorize(ColorRed, s) 59 | } 60 | 61 | // ColorRedBackground represents a white foreground color and red background. 62 | var ColorRedBackground = 41 63 | 64 | // RedBackground returns the string contents of "s" wrapped by white foreground color and red background. 65 | func RedBackground(s string) string { 66 | return colorize(ColorRedBackground, s) 67 | } 68 | 69 | // ColorGreen represents the green color. 70 | var ColorGreen = 32 71 | 72 | // Green returns the string contents of "s" wrapped by green foreground color. 73 | func Green(s string) string { 74 | return colorize(ColorGreen, s) 75 | } 76 | 77 | // ColorYellow represents the yellow color. 78 | var ColorYellow = 33 79 | 80 | // Yellow returns the string contents of "s" wrapped by yellow foreground color. 81 | func Yellow(s string) string { 82 | return colorize(ColorYellow, s) 83 | } 84 | -------------------------------------------------------------------------------- /vendor/github.com/kataras/pio/hijacker.go: -------------------------------------------------------------------------------- 1 | package pio 2 | 3 | import ( 4 | "errors" 5 | "sync" 6 | ) 7 | 8 | // Hijacker is the signature implemented by callers 9 | // that want to hijack the Print method. 10 | // 11 | // Look `Printer#Hijack` for more. 12 | type Hijacker func(*Ctx) 13 | 14 | var ( 15 | // ErrCanceled is returned when a hijacker canceled a specific print action. 16 | ErrCanceled = errors.New("canceled") 17 | // ErrSkipped it returned from marshaler or hijacker 18 | // when the content should be skipped and printer should avoid printing it. 19 | ErrSkipped = errors.New("skipped") 20 | ) 21 | 22 | var cPool = sync.Pool{New: func() interface{} { return &Ctx{} }} 23 | 24 | func acquireCtx(v interface{}, printer *Printer) *Ctx { 25 | ctx := cPool.Get().(*Ctx) 26 | ctx.Printer = printer 27 | ctx.Value = v 28 | 29 | ctx.marshalResult.b = ctx.marshalResult.b[0:0] 30 | ctx.marshalResult.err = nil 31 | ctx.canceled = false 32 | ctx.continueToNext = false 33 | return ctx 34 | } 35 | 36 | func releaseCtx(ctx *Ctx) { 37 | cPool.Put(ctx) 38 | } 39 | 40 | // Ctx is the current context of the Printer's hijacker, 41 | // should not be used inside goroutines, 42 | // exiting this hijacker allows the Printer to continue its execution. 43 | type Ctx struct { 44 | // Printer is the current Printer which this ctx is owned by. 45 | Printer *Printer 46 | // Value is the argument passed to the `Printer#Print`. 47 | // 48 | // Value shoult not be changed. 49 | Value interface{} 50 | 51 | marshalResult struct { 52 | b []byte 53 | err error 54 | } 55 | continueToNext bool 56 | canceled bool 57 | } 58 | 59 | // MarshalValue marshals the `Value` 60 | // and skips the marshal operation on the `Printer#Print` state. 61 | // 62 | // Remember that if `MarshalValue` called after a `SetResult` 63 | // then it will not operate a marshaling and return the 64 | // stored result instead. 65 | func (ctx *Ctx) MarshalValue() ([]byte, error) { 66 | if len(ctx.marshalResult.b) > 0 { 67 | return ctx.marshalResult.b, ctx.marshalResult.err 68 | } 69 | 70 | if ctx.Printer.marshal == nil { 71 | return nil, ErrSkipped 72 | } 73 | 74 | b, err := ctx.Printer.marshal(ctx.Value) 75 | ctx.marshalResult.b = b 76 | ctx.marshalResult.err = err 77 | return b, err 78 | } 79 | 80 | // Store bypasses the marshaler and sets the result explicitly. 81 | // If any of the next hijackers try to call the `MarshalValue` then it will 82 | // return the results that had set here. 83 | func (ctx *Ctx) Store(result []byte, err error) { 84 | ctx.marshalResult.b = result 85 | ctx.marshalResult.err = err 86 | } 87 | 88 | // Cancel cancels the printing of this `Value`. 89 | func (ctx *Ctx) Cancel() { 90 | ctx.canceled = true 91 | } 92 | 93 | // Next allows to continue to the next hijacker,if available, when this hijacker finished. 94 | func (ctx *Ctx) Next() { 95 | ctx.continueToNext = true 96 | } 97 | -------------------------------------------------------------------------------- /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/kataras/pio/marshaler.go: -------------------------------------------------------------------------------- 1 | package pio 2 | 3 | import ( 4 | "encoding/json" 5 | "encoding/xml" 6 | "errors" 7 | ) 8 | 9 | // Marshaler is the interface implemented by types that 10 | // can marshal themselves into valid output. 11 | type Marshaler interface { 12 | Marshal(v interface{}) ([]byte, error) 13 | } 14 | 15 | // Marshaled or (especially British, marshalled) is an interface which 16 | // is implemented by values that can marshal theirselves. 17 | // 18 | // It's like Marshaler but it doesn't takes an argument. 19 | type Marshaled interface { 20 | Marshal() ([]byte, error) 21 | } 22 | 23 | func fromMarshaled(self Marshaled) Marshaler { 24 | return MarshalerFunc(func(v interface{}) ([]byte, error) { 25 | return self.Marshal() 26 | }) 27 | } 28 | 29 | // MarshalerFunc is the signature implemented by callers that 30 | // are responsible to marshal "v" into valid printable result. 31 | // 32 | // Look `Printer#Marshal` for more. 33 | type MarshalerFunc func(v interface{}) ([]byte, error) 34 | 35 | // Marshal makes the Marshaler compatible with the 36 | // standard golang's marshalers, so a marshaler 37 | // created for a Printer, can be used on std packages as well. 38 | func (m MarshalerFunc) Marshal(v interface{}) ([]byte, error) { 39 | return m(v) 40 | } 41 | 42 | // ErrMarshalNotResponsible retruns from a marshaler 43 | // when it's not responsible and should continue to the next marshaler. 44 | var ErrMarshalNotResponsible = errors.New("this marshaler is not responsible for this type of data") 45 | 46 | // ErrMarshalNotFound or ErrSkipped can be used to skip a specific 47 | // printer's output operation. 48 | var ErrMarshalNotFound = errors.New("no marshaler found for this type of dat") 49 | 50 | // Text is a Text marshaler, it converts 51 | // string to a compatible form of []byte. 52 | var Text = MarshalerFunc(func(v interface{}) ([]byte, error) { 53 | if b, ok := v.([]byte); ok { 54 | return b, nil 55 | } 56 | if s, ok := v.(string); ok { 57 | return []byte(s), nil // maybe 0101010 010110 here, but can be overridden by fmt.Sprintf("%s", v) 58 | } 59 | 60 | return nil, ErrMarshalNotResponsible 61 | }) 62 | 63 | var ( 64 | // JSON returns the JSON encoding of Printer#Print%v. 65 | // A shortcut for `encoding/json#Marshal` 66 | JSON = MarshalerFunc(json.Marshal) 67 | // JSONIndent returns the JSON encoding of Printer#Print%v. 68 | // A shortcut for `encoding/json#MarshalIndent(v, ""," ")` 69 | JSONIndent = MarshalerFunc(func(v interface{}) ([]byte, error) { 70 | return json.MarshalIndent(v, "", " ") 71 | }) 72 | 73 | // XML returns the XML encoding of Printer#Print%v. 74 | // A shortcut for `encoding/xml#Marshal` 75 | XML = MarshalerFunc(xml.Marshal) 76 | // XMLIndent returns the XML encoding of Printer#Print%v. 77 | // A shortcut for `encoding/xml#MarshalIndent(v, ""," ")` 78 | XMLIndent = MarshalerFunc(func(v interface{}) ([]byte, error) { 79 | return xml.MarshalIndent(v, "", " ") 80 | }) 81 | ) 82 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mkpost.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 ignore 6 | 7 | // mkpost processes the output of cgo -godefs to 8 | // modify the generated types. It is used to clean up 9 | // the sys API in an architecture specific manner. 10 | // 11 | // mkpost is run after cgo -godefs; see README.md. 12 | package main 13 | 14 | import ( 15 | "bytes" 16 | "fmt" 17 | "go/format" 18 | "io/ioutil" 19 | "log" 20 | "os" 21 | "regexp" 22 | ) 23 | 24 | func main() { 25 | // Get the OS and architecture (using GOARCH_TARGET if it exists) 26 | goos := os.Getenv("GOOS") 27 | goarch := os.Getenv("GOARCH_TARGET") 28 | if goarch == "" { 29 | goarch = os.Getenv("GOARCH") 30 | } 31 | // Check that we are using the new build system if we should be. 32 | if goos == "linux" && goarch != "sparc64" { 33 | if os.Getenv("GOLANG_SYS_BUILD") != "docker" { 34 | os.Stderr.WriteString("In the new build system, mkpost should not be called directly.\n") 35 | os.Stderr.WriteString("See README.md\n") 36 | os.Exit(1) 37 | } 38 | } 39 | 40 | b, err := ioutil.ReadAll(os.Stdin) 41 | if err != nil { 42 | log.Fatal(err) 43 | } 44 | 45 | // If we have empty Ptrace structs, we should delete them. Only s390x emits 46 | // nonempty Ptrace structs. 47 | ptraceRexexp := regexp.MustCompile(`type Ptrace((Psw|Fpregs|Per) struct {\s*})`) 48 | b = ptraceRexexp.ReplaceAll(b, nil) 49 | 50 | // Replace the control_regs union with a blank identifier for now. 51 | controlRegsRegex := regexp.MustCompile(`(Control_regs)\s+\[0\]uint64`) 52 | b = controlRegsRegex.ReplaceAll(b, []byte("_ [0]uint64")) 53 | 54 | // Remove fields that are added by glibc 55 | // Note that this is unstable as the identifers are private. 56 | removeFieldsRegex := regexp.MustCompile(`X__glibc\S*`) 57 | b = removeFieldsRegex.ReplaceAll(b, []byte("_")) 58 | 59 | // Convert [65]int8 to [65]byte in Utsname members to simplify 60 | // conversion to string; see golang.org/issue/20753 61 | convertUtsnameRegex := regexp.MustCompile(`((Sys|Node|Domain)name|Release|Version|Machine)(\s+)\[(\d+)\]u?int8`) 62 | b = convertUtsnameRegex.ReplaceAll(b, []byte("$1$3[$4]byte")) 63 | 64 | // Remove spare fields (e.g. in Statx_t) 65 | spareFieldsRegex := regexp.MustCompile(`X__spare\S*`) 66 | b = spareFieldsRegex.ReplaceAll(b, []byte("_")) 67 | 68 | // Remove cgo padding fields 69 | removePaddingFieldsRegex := regexp.MustCompile(`Pad_cgo_\d+`) 70 | b = removePaddingFieldsRegex.ReplaceAll(b, []byte("_")) 71 | 72 | // We refuse to export private fields on s390x 73 | if goarch == "s390x" && goos == "linux" { 74 | // Remove padding, hidden, or unused fields 75 | removeFieldsRegex = regexp.MustCompile(`\bX_\S+`) 76 | b = removeFieldsRegex.ReplaceAll(b, []byte("_")) 77 | } 78 | 79 | // Remove the first line of warning from cgo 80 | b = b[bytes.IndexByte(b, '\n')+1:] 81 | // Modify the command in the header to include: 82 | // mkpost, our own warning, and a build tag. 83 | replacement := fmt.Sprintf(`$1 | go run mkpost.go 84 | // Code generated by the command above; see README.md. DO NOT EDIT. 85 | 86 | // +build %s,%s`, goarch, goos) 87 | cgoCommandRegex := regexp.MustCompile(`(cgo -godefs .*)`) 88 | b = cgoCommandRegex.ReplaceAll(b, []byte(replacement)) 89 | 90 | // gofmt 91 | b, err = format.Source(b) 92 | if err != nil { 93 | log.Fatal(err) 94 | } 95 | 96 | os.Stdout.Write(b) 97 | } 98 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /rizla/signal_watcher.go: -------------------------------------------------------------------------------- 1 | package rizla 2 | 3 | import ( 4 | "os" 5 | "path/filepath" 6 | 7 | "github.com/fsnotify/fsnotify" 8 | ) 9 | 10 | type signalWatcher struct { 11 | underline *fsnotify.Watcher 12 | // to stop the for loop 13 | stopChan chan bool 14 | hasStoppedManually bool 15 | errListeners []WatcherErrorListener 16 | changeListeners []WatcherChangeListener 17 | } 18 | 19 | var _ Watcher = &signalWatcher{} 20 | 21 | // newSignalWatcher returns a new fsnotify wrapper 22 | // which watching the operating system's file system's signals. 23 | func newSignalWatcher() Watcher { 24 | watcher, werr := fsnotify.NewWatcher() 25 | if werr != nil { 26 | // yes we should panic on these things. 27 | panic(werr) 28 | } 29 | 30 | return &signalWatcher{ 31 | underline: watcher, 32 | stopChan: make(chan bool, 1), 33 | } 34 | } 35 | 36 | func (w *signalWatcher) OnError(evt WatcherErrorListener) { 37 | w.errListeners = append(w.errListeners, evt) 38 | } 39 | 40 | func (w *signalWatcher) OnChange(evt WatcherChangeListener) { 41 | w.changeListeners = append(w.changeListeners, evt) 42 | } 43 | 44 | func (w *signalWatcher) Stop() { 45 | w.stopChan <- true 46 | w.hasStoppedManually = true 47 | w.underline.Close() 48 | } 49 | 50 | func (w *signalWatcher) Loop() { 51 | // fsnotify needs to know the folder one by one, it doesn't cares about root's subdir yet. 52 | // so: 53 | for _, p := range projects { 54 | // add to the watcher first in order to watch changes and re-builds if the first build has fallen 55 | 56 | // add its root folder first 57 | if err := w.underline.Add(p.dir); err != nil { 58 | p.Err.Errorf("\n" + err.Error() + "\n") 59 | } 60 | 61 | visitFn := func(path string, f os.FileInfo, err error) error { 62 | if f.IsDir() { 63 | // check if this subdir is allowed 64 | if p.Watcher(path) { 65 | if err := w.underline.Add(path); err != nil { 66 | p.Err.Errorf("\n" + err.Error() + "\n") 67 | } 68 | } else { 69 | return filepath.SkipDir 70 | } 71 | 72 | } 73 | return nil 74 | } 75 | 76 | if err := filepath.Walk(p.dir, visitFn); err != nil { 77 | // actually it never panics here but keep it for note 78 | panic(err) 79 | } 80 | } 81 | 82 | defer func() { 83 | w.underline.Close() 84 | for _, p := range projects { 85 | killProcess(p.proc, p.AppName) 86 | } 87 | if !w.hasStoppedManually { 88 | for i := range w.errListeners { 89 | w.errListeners[i](errUnexpected) 90 | } 91 | } 92 | }() 93 | 94 | w.stopChan <- false 95 | 96 | // run the watcher 97 | for { 98 | select { 99 | case stop := <-w.stopChan: 100 | if stop { 101 | w.hasStoppedManually = true 102 | return 103 | } 104 | 105 | case event := <-w.underline.Events: 106 | // ignore CHMOD events 107 | if event.Op&fsnotify.Chmod == fsnotify.Chmod { 108 | continue 109 | } 110 | 111 | filename := event.Name 112 | for _, p := range projects { 113 | p.i++ 114 | // fix two-times reload on windows 115 | if isWindows && p.i%2 != 0 { 116 | continue 117 | } 118 | 119 | if !p.DisableRuntimeDir { // if add folders to watch at runtime is enabled 120 | // if a folder created after the first Adds, add them here at runtime. 121 | if isDirectory(filename) && p.Watcher(filename) { 122 | if err := w.underline.Add(filename); err != nil { 123 | p.Err.Errorf("\n" + err.Error() + "\n") 124 | } 125 | } 126 | } 127 | 128 | for i := range w.changeListeners { 129 | w.changeListeners[i](p, filename) 130 | } 131 | 132 | } 133 | case err := <-w.underline.Errors: 134 | if !w.hasStoppedManually { 135 | for i := range w.errListeners { 136 | w.errListeners[i](err) 137 | } 138 | } 139 | } 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /vendor/github.com/kataras/pio/adapter.go: -------------------------------------------------------------------------------- 1 | package pio 2 | 3 | import ( 4 | "io" 5 | ) 6 | 7 | // Available sources. 8 | type ( 9 | printFunc func(interface{}) 10 | printVariadicFunc func(...interface{}) 11 | printfFunc func(string, ...interface{}) 12 | printlnFunc func(string) 13 | ) 14 | 15 | type writerFunc func([]byte) (int, error) 16 | 17 | func (w writerFunc) Write(p []byte) (n int, err error) { 18 | return w(p) 19 | } 20 | 21 | // Wrap returns a new output based on the "printfFn" 22 | // if not a compatible output found then it will 23 | // return a writer which writes nothing. 24 | // 25 | // To check if the wrapping worked 26 | // you can check if the result `io.Writer` 27 | // `IsNop`, i.e: 28 | // std's log.Panicf is not a compatible interface 29 | // 30 | // output := Output(log.Panicf) 31 | // if IsNop(output) { 32 | // // conversation failed, do something or panic. 33 | //} 34 | func Wrap(printFn interface{}) io.Writer { 35 | switch printFn.(type) { 36 | case io.Writer: 37 | return printFn.(io.Writer) 38 | case writerFunc: 39 | return printFn.(io.Writer) 40 | case printFunc: 41 | return OutputFrom.Print(printFn.(printFunc)) 42 | case printVariadicFunc: 43 | return OutputFrom.PrintVardiadic(printFn.(printVariadicFunc)) 44 | case printfFunc: 45 | return OutputFrom.Printf(printFn.(printfFunc)) 46 | case printlnFunc: 47 | return OutputFrom.Println(printFn.(printlnFunc), false) 48 | 49 | } 50 | 51 | return NopOutput() 52 | } 53 | 54 | // OutputFrom is a variable 55 | // which contains some helpers that can 56 | // convert some forms of output to compatible `io.Writer` 57 | // in order to be passed to the `NewPrinter` or `Register` functions. 58 | var OutputFrom = OutputAdapters{} 59 | 60 | // OutputAdapters is a struct 61 | // which contains some forms of output 62 | // and convert them to a compatible `io.Writer` 63 | // in order to be passed to the `NewPrinter` or `Register` functions. 64 | type OutputAdapters struct{} 65 | 66 | // Print converts a func(v interface{}) to a compatible `io.Writer`. 67 | func (a *OutputAdapters) Print(print func(v interface{})) io.Writer { 68 | return &printAdapter{ 69 | print: print, 70 | } 71 | } 72 | 73 | // PrintVardiadic converts a func(v ...interface{}) to a compatible `io.Writer`. 74 | func (a *OutputAdapters) PrintVardiadic(print func(v ...interface{})) io.Writer { 75 | return &printVariadicAdapter{ 76 | printVariadic: print, 77 | } 78 | } 79 | 80 | // Printf converts a func(string, ...interface{}) to a compatible `io.Writer`. 81 | func (a *OutputAdapters) Printf(printf func(format string, args ...interface{})) io.Writer { 82 | return &printfAdapter{ 83 | printf: printf, 84 | } 85 | } 86 | 87 | // Println converts a func(string) to a compatible `io.Writer`. 88 | // if "newLine" is true then "\n" will be appended to the "s". 89 | func (a *OutputAdapters) Println(println func(s string), newLine bool) io.Writer { 90 | return &printlnAdapter{ 91 | println: println, 92 | newLine: newLine, 93 | } 94 | } 95 | 96 | type ( 97 | printAdapter struct { 98 | print printFunc 99 | } 100 | printVariadicAdapter struct { 101 | printVariadic printVariadicFunc 102 | } 103 | printfAdapter struct { 104 | printf printfFunc 105 | } 106 | printlnAdapter struct { 107 | println printlnFunc 108 | newLine bool 109 | } 110 | ) 111 | 112 | func (p *printAdapter) Write(b []byte) (int, error) { 113 | p.print(string(b)) 114 | return len(b), nil 115 | } 116 | 117 | func (p *printVariadicAdapter) Write(b []byte) (int, error) { 118 | p.printVariadic(string(b)) 119 | return len(b), nil 120 | } 121 | 122 | func (p *printfAdapter) Write(b []byte) (int, error) { 123 | p.printf(string(b)) 124 | return len(b), nil 125 | } 126 | 127 | func (p *printlnAdapter) Write(b []byte) (int, error) { 128 | if p.newLine { 129 | b = append(b, NewLine...) 130 | } 131 | p.println(string(b)) 132 | return len(b), nil 133 | } 134 | -------------------------------------------------------------------------------- /HISTORY.md: -------------------------------------------------------------------------------- 1 | ## 0.1.1 2 | 3 | Add `-onreload` to execute commands on reload through the `rizla` cli. 4 | 5 | Example: 6 | 7 | **on_reload.bat** 8 | 9 | ```sh 10 | @echo off 11 | echo Hello, custom script can goes here before reload, i.e build https://github.comkataras/bindata things! 12 | ``` 13 | 14 | **main.go** 15 | 16 | ```go 17 | // Package main shows you how you can execute commands on reload 18 | // in this example we will execute a simple bat file on windows 19 | // but you can pass anything, it just runs the `exec.Command` based on -onreload= flag's value. 20 | package main 21 | 22 | import ( 23 | "flag" 24 | "fmt" 25 | ) 26 | 27 | func main() { 28 | host := flag.String("host", "", "the host") 29 | port := flag.Int("port", 0, "the port") 30 | flag.Parse() 31 | fmt.Printf("The 'host' argument is: %v\n", *host) 32 | fmt.Printf("The 'port' argument is: %v\n", *port) 33 | } 34 | 35 | ``` 36 | 37 | ```sh 38 | $ rizla -onreload="on_reload.bat" main.go -host myhost.com -port 1193 39 | ``` 40 | 41 | ## 0.1.0 42 | 43 | Rizla drops support for multi `main.go:func main()` programs in the same directory. It still accepts a filename with `main.go` but it depends on the directory now (as all examples already shown) in order to be able to run and watch projects with multiple `.go` files in the project's root directory, this is very useful especially when the project depends on libraries like `go-bindata` with a result of `.go` file in the root directory. For most cases that will not change anything. If you used to have many go programs with `func main()` in the same root directory please consider that this is not idiomatic and you must change this habit, the sooner the better. 44 | 45 | > `main.go` can be any filename contains the `func main(){ ... }` of course. 46 | 47 | ## 0.0.9 48 | 49 | 1. `rizla.Run()` -> `rizla.Run(map[string][]string)`. Run now accepts a `sources map[string][]string`, can be nil if projects added manually previously, the `key string` is the program filepath with `.go` extension and the `values []string` are any optional arguments that the program excepts to be passed. Therefore use `Run(nil)` if you used `rizla.Run()` before. 50 | 51 | 2. `rizla.RunWith(watcher rizla.Watcher, programFile string)` -> `rizla.RunWith(watcher rizla.Watcher, sources map[string][]string, delayOnDetect time.Duration)`. 52 | 53 | 3. At `rizla#Project` the property `AllowRunAfter time.Duration` added. 54 | 55 | 4. New `-delay` cli flag added, as requested by @scorpnode at https://github.com/kataras/rizla/issues/14 56 | 57 | ## 0.0.8 58 | 59 | Support flags as requested at [#13](https://github.com/kataras/rizla/issues/13) by @Zeno-Code. 60 | 61 | ## 0.0.6 -> 0.0.7 62 | 63 | Rizla uses the operating system's signals to fire a change because it is the fastest way and it consumes the minimal CPU. 64 | But as the [feature request](https://github.com/kataras/rizla/issues/6) explains, some IDEs overrides the Operating System's signals, so I needed to change the things a bit in order to allow 65 | looping-every-while and compare the file(s) with its modtime for new changes while in the same time keep the default as it's. 66 | 67 | - **NEW**: Add a common interface for file system watchers in order to accoblish select between two methods of scanning for file changes. 68 | - file system's signals (default) 69 | - `filepath.Walk` (using the `-walk` flag) 70 | 71 | ### When to enable `-walk`? 72 | When the default method doesn't works for your IDE's save method. 73 | 74 | ### How to enable `-walk`? 75 | - If you're command line user: `rizla -walk main.go` , just append the `-walk` flag. 76 | - If you use rizla behind your source code then use the `rizla.RunWith(rizla.WatcherFromFlag("-flag"))` instead of `rizla.Run()`. 77 | 78 | 79 | ## 0.0.4 -> 0.0.5 and 0.0.6 80 | 81 | - **Fix**: Reload more than one time on Mac 82 | 83 | ## 0.0.3 -> 0.0.4 84 | 85 | - **Added**: global `DefaultDisableProgramRerunOutput` and per-project `DisableProgramRerunOutput` option, to disable the program's output when reloads. 86 | - **Fix** two-times reload on windows 87 | - **Fix** fail to re-run when previous build error, issue [here](https://github.com/kataras/rizla/issues/1) 88 | 89 | ## 0.0.2 -> 0.0.3 90 | - Change: `rizla.Out & rizla.Err` moved to the Project iteral (`project.Out` & `project.Err`), each project can have its own output now, and are type of *Printer 91 | - Change/NEW: `project.OnChange` removed, new `project.OnReload(func(string))` & `project.OnReloaded(func(string))` , with these you can change the output message when a file has changed and also when project reloaded, see the [project.go](https://github.com/kataras/rizla/blob/master/project.go) for more. 92 | 93 | ## 0.0.1 -> 0.0.2 94 | 95 | - A lot of underline code improvements & fixes 96 | - New: `project.Watcher(string) bool` 97 | - New: `project.OnChange(string)` 98 | - New: Allow watching new directories in runtime 99 | - New: Rizla accepts all fs os events as change events 100 | - Fix: Not watching third-level subdirectories, now watch everything except ` ".git", "node_modules", "vendor"` (you can change this behavior with the `project.Watcher`) 101 | - Maybe I'm missing something, just upgrade with `go get -u github.com/kataras/rizla` and have fun :) 102 | -------------------------------------------------------------------------------- /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 rizla builds, runs and monitors your Go Applications with ease. 2 | // 3 | // rizla main.go 4 | // rizla C:/myprojects/project1/main.go C:/myprojects/project2/main.go C:/myprojects/project3/main.go 5 | // rizla -walk main.go [if -walk then rizla uses the stdlib's filepath.Walk method instead of file system's signals] 6 | // 7 | package main 8 | 9 | import ( 10 | "fmt" 11 | "os" 12 | "path/filepath" 13 | "strings" 14 | "time" 15 | 16 | "github.com/kataras/golog" 17 | "github.com/kataras/rizla/rizla" 18 | ) 19 | 20 | const ( 21 | // Version of rizla command line tool 22 | Version = "0.1.1" 23 | // Name of rizla 24 | Name = "Rizla" 25 | // Description of rizla 26 | Description = "Rizla builds, runs and monitors your Go Applications with ease." 27 | ) 28 | 29 | const delayArgName = "-delay" 30 | 31 | func getDelayFromArg(arg string) (time.Duration, bool) { 32 | if strings.HasPrefix(arg, delayArgName) || strings.HasPrefix(arg, delayArgName[1:]) { 33 | // [-]delay=5s 34 | // [-]delay 5s 35 | 36 | if equalIdx := strings.IndexRune(arg, '='); equalIdx > 0 { 37 | delayStr := arg[equalIdx+1:] 38 | d, _ := time.ParseDuration(delayStr) 39 | return d, true 40 | } 41 | 42 | if spaceIdx := strings.IndexRune(arg, ' '); spaceIdx > 0 { 43 | delayStr := arg[spaceIdx+1:] 44 | d, _ := time.ParseDuration(delayStr) 45 | return d, true 46 | } 47 | 48 | } 49 | 50 | return 0, false 51 | } 52 | 53 | const onReloadArg = "-onreload" 54 | 55 | func getOnReloadArg(arg string) (string, bool) { 56 | if strings.HasPrefix(arg, onReloadArg) || strings.HasPrefix(arg, onReloadArg[1:]) { 57 | // first equality ofc... 58 | // [-]onreload=cmd1,cmd2,file.sh 59 | // [-]onreload cmd1,cmd2,file.sh 60 | 61 | if equalIdx := strings.IndexRune(arg, '='); equalIdx > 0 { 62 | src := arg[equalIdx+1:] 63 | return src, true 64 | } 65 | 66 | if spaceIdx := strings.IndexRune(arg, ' '); spaceIdx > 0 { 67 | src := arg[spaceIdx+1:] 68 | return src, true 69 | } 70 | 71 | } 72 | 73 | return "", false 74 | } 75 | 76 | var helpTmpl = fmt.Sprintf(`NAME: 77 | %s - %s 78 | 79 | USAGE: 80 | rizla main.go 81 | rizla C:/myprojects/project1/main.go C:/myprojects/project2/main.go C:/myprojects/project3/main.go 82 | rizla -walk main.go [if -walk then rizla uses the stdlib's filepath.Walk method instead of file system's signals] 83 | rizla -delay=5s main.go [if delay > 0 then it delays the reload, also note that it accepts the first change but the rest of changes every "delay"] 84 | rizla -onreload="service supervisor restart" main.go or rizla -onreload="cmd /C echo Hello World!" main.go 85 | VERSION: 86 | %s 87 | `, Name, Description, Version) 88 | 89 | func main() { 90 | argsLen := len(os.Args) 91 | 92 | errorf := golog.New().SetOutput(os.Stderr).Errorf 93 | 94 | if argsLen <= 1 { 95 | help(-1) 96 | } else if isArgHelp(os.Args[1]) { 97 | help(0) 98 | } 99 | 100 | args := os.Args[1:] 101 | programFiles := make(map[string][]string, 0) // key = main file, value = args. 102 | fsWatcher, _ := rizla.WatcherFromFlag("signal") 103 | 104 | var lastProgramFile string 105 | var delayOnDetect time.Duration 106 | 107 | for i, a := range args { 108 | // if main files with arguments aren't passed yet, 109 | // then the argument(s) should refer to the rizla tool and not the 110 | // external programs. 111 | if lastProgramFile == "" { 112 | // The first argument must be the method type of the file system's watcher. 113 | // if -w,-walk,walk then 114 | // asks to use the stdlib's filepath.walk method instead of the operating system's signal. 115 | // It's only usage is when the user's IDE overrides the os' signals. 116 | // otherwise 117 | // use the fsnotify's operating system's file system's signals. 118 | if watcher, ok := rizla.WatcherFromFlag(a); ok { 119 | fsWatcher = watcher 120 | continue 121 | } 122 | 123 | if delay, ok := getDelayFromArg(a); ok { 124 | delayOnDetect = delay 125 | continue 126 | } 127 | 128 | if onReloadSources, ok := getOnReloadArg(a); ok { 129 | rizla.OnReloadScripts = strings.Split(onReloadSources, ",") 130 | } 131 | } 132 | 133 | // it's main.go or any go main program 134 | if strings.HasSuffix(a, ".go") { 135 | programFiles[a] = []string{} 136 | lastProgramFile = a 137 | continue 138 | } 139 | 140 | if lastProgramFile != "" && len(args) > i+1 { 141 | programFiles[lastProgramFile] = append(programFiles[lastProgramFile], args[i:]...) // note that: the executable argument (1st arg) is set-ed by the exec.Command on `runProject`. 142 | continue 143 | } 144 | } 145 | 146 | // no program files given 147 | if len(programFiles) == 0 { 148 | errorf("please provide a *.go file.\n") 149 | help(-1) 150 | return 151 | } 152 | 153 | // check if given program files exist 154 | for programFile := range programFiles { 155 | // the argument is not the first given is *.go but doesn't exists on user's disk 156 | if p, _ := filepath.Abs(programFile); !fileExists(p) { 157 | errorf("file " + p + " does not exists.\n") 158 | help(-1) 159 | return 160 | } 161 | } 162 | 163 | rizla.RunWith(fsWatcher, programFiles, delayOnDetect) 164 | } 165 | 166 | func help(code int) { 167 | os.Stdout.WriteString(helpTmpl) 168 | os.Exit(code) 169 | } 170 | 171 | func isArgHelp(s string) bool { 172 | return s == "help" || s == "-h" || s == "-help" 173 | } 174 | 175 | func fileExists(f string) bool { 176 | if _, err := os.Stat(f); os.IsNotExist(err) { 177 | return false 178 | } 179 | return true 180 | } 181 | -------------------------------------------------------------------------------- /vendor/github.com/fsnotify/fsnotify/inotify_poller.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 linux 6 | 7 | package fsnotify 8 | 9 | import ( 10 | "errors" 11 | 12 | "golang.org/x/sys/unix" 13 | ) 14 | 15 | type fdPoller struct { 16 | fd int // File descriptor (as returned by the inotify_init() syscall) 17 | epfd int // Epoll file descriptor 18 | pipe [2]int // Pipe for waking up 19 | } 20 | 21 | func emptyPoller(fd int) *fdPoller { 22 | poller := new(fdPoller) 23 | poller.fd = fd 24 | poller.epfd = -1 25 | poller.pipe[0] = -1 26 | poller.pipe[1] = -1 27 | return poller 28 | } 29 | 30 | // Create a new inotify poller. 31 | // This creates an inotify handler, and an epoll handler. 32 | func newFdPoller(fd int) (*fdPoller, error) { 33 | var errno error 34 | poller := emptyPoller(fd) 35 | defer func() { 36 | if errno != nil { 37 | poller.close() 38 | } 39 | }() 40 | poller.fd = fd 41 | 42 | // Create epoll fd 43 | poller.epfd, errno = unix.EpollCreate1(0) 44 | if poller.epfd == -1 { 45 | return nil, errno 46 | } 47 | // Create pipe; pipe[0] is the read end, pipe[1] the write end. 48 | errno = unix.Pipe2(poller.pipe[:], unix.O_NONBLOCK) 49 | if errno != nil { 50 | return nil, errno 51 | } 52 | 53 | // Register inotify fd with epoll 54 | event := unix.EpollEvent{ 55 | Fd: int32(poller.fd), 56 | Events: unix.EPOLLIN, 57 | } 58 | errno = unix.EpollCtl(poller.epfd, unix.EPOLL_CTL_ADD, poller.fd, &event) 59 | if errno != nil { 60 | return nil, errno 61 | } 62 | 63 | // Register pipe fd with epoll 64 | event = unix.EpollEvent{ 65 | Fd: int32(poller.pipe[0]), 66 | Events: unix.EPOLLIN, 67 | } 68 | errno = unix.EpollCtl(poller.epfd, unix.EPOLL_CTL_ADD, poller.pipe[0], &event) 69 | if errno != nil { 70 | return nil, errno 71 | } 72 | 73 | return poller, nil 74 | } 75 | 76 | // Wait using epoll. 77 | // Returns true if something is ready to be read, 78 | // false if there is not. 79 | func (poller *fdPoller) wait() (bool, error) { 80 | // 3 possible events per fd, and 2 fds, makes a maximum of 6 events. 81 | // I don't know whether epoll_wait returns the number of events returned, 82 | // or the total number of events ready. 83 | // I decided to catch both by making the buffer one larger than the maximum. 84 | events := make([]unix.EpollEvent, 7) 85 | for { 86 | n, errno := unix.EpollWait(poller.epfd, events, -1) 87 | if n == -1 { 88 | if errno == unix.EINTR { 89 | continue 90 | } 91 | return false, errno 92 | } 93 | if n == 0 { 94 | // If there are no events, try again. 95 | continue 96 | } 97 | if n > 6 { 98 | // This should never happen. More events were returned than should be possible. 99 | return false, errors.New("epoll_wait returned more events than I know what to do with") 100 | } 101 | ready := events[:n] 102 | epollhup := false 103 | epollerr := false 104 | epollin := false 105 | for _, event := range ready { 106 | if event.Fd == int32(poller.fd) { 107 | if event.Events&unix.EPOLLHUP != 0 { 108 | // This should not happen, but if it does, treat it as a wakeup. 109 | epollhup = true 110 | } 111 | if event.Events&unix.EPOLLERR != 0 { 112 | // If an error is waiting on the file descriptor, we should pretend 113 | // something is ready to read, and let unix.Read pick up the error. 114 | epollerr = true 115 | } 116 | if event.Events&unix.EPOLLIN != 0 { 117 | // There is data to read. 118 | epollin = true 119 | } 120 | } 121 | if event.Fd == int32(poller.pipe[0]) { 122 | if event.Events&unix.EPOLLHUP != 0 { 123 | // Write pipe descriptor was closed, by us. This means we're closing down the 124 | // watcher, and we should wake up. 125 | } 126 | if event.Events&unix.EPOLLERR != 0 { 127 | // If an error is waiting on the pipe file descriptor. 128 | // This is an absolute mystery, and should never ever happen. 129 | return false, errors.New("Error on the pipe descriptor.") 130 | } 131 | if event.Events&unix.EPOLLIN != 0 { 132 | // This is a regular wakeup, so we have to clear the buffer. 133 | err := poller.clearWake() 134 | if err != nil { 135 | return false, err 136 | } 137 | } 138 | } 139 | } 140 | 141 | if epollhup || epollerr || epollin { 142 | return true, nil 143 | } 144 | return false, nil 145 | } 146 | } 147 | 148 | // Close the write end of the poller. 149 | func (poller *fdPoller) wake() error { 150 | buf := make([]byte, 1) 151 | n, errno := unix.Write(poller.pipe[1], buf) 152 | if n == -1 { 153 | if errno == unix.EAGAIN { 154 | // Buffer is full, poller will wake. 155 | return nil 156 | } 157 | return errno 158 | } 159 | return nil 160 | } 161 | 162 | func (poller *fdPoller) clearWake() error { 163 | // You have to be woken up a LOT in order to get to 100! 164 | buf := make([]byte, 100) 165 | n, errno := unix.Read(poller.pipe[0], buf) 166 | if n == -1 { 167 | if errno == unix.EAGAIN { 168 | // Buffer is empty, someone else cleared our wake. 169 | return nil 170 | } 171 | return errno 172 | } 173 | return nil 174 | } 175 | 176 | // Close all poller file descriptors, but not the one passed to it. 177 | func (poller *fdPoller) close() { 178 | if poller.pipe[1] != -1 { 179 | unix.Close(poller.pipe[1]) 180 | } 181 | if poller.pipe[0] != -1 { 182 | unix.Close(poller.pipe[0]) 183 | } 184 | if poller.epfd != -1 { 185 | unix.Close(poller.epfd) 186 | } 187 | } 188 | -------------------------------------------------------------------------------- /vendor/github.com/kataras/pio/registry.go: -------------------------------------------------------------------------------- 1 | package pio 2 | 3 | import ( 4 | "errors" 5 | "io" 6 | "sort" 7 | "sync" 8 | ) 9 | 10 | // Registry is the Printer(s) container. 11 | // 12 | // It can be used as follows: 13 | // reg := NewRegistry(). 14 | // RegisterPrinter(NewPrinter("err", os.Stderr)). 15 | // RegisterPrinter(NewPrinter("default", os.Stdout)). 16 | // Print("something") 17 | type Registry struct { 18 | // can change via `Register` or `RegisterPrinter` with mutex. 19 | // whenever a tool needs an `io.Writer` to do something 20 | // end-developers can pass this `Printer`. 21 | printers []*Printer 22 | mu sync.Mutex 23 | once sync.Once 24 | } 25 | 26 | // NewRegistry returns an empty printer Registry. 27 | // 28 | // Note that: 29 | // Registry have a zero value, so it can be 30 | // declared with a simple `var` keyword and without pointer. 31 | func NewRegistry() *Registry { 32 | return new(Registry) 33 | } 34 | 35 | // RegisterPrinter registers an already-created printer to the 36 | // registry. 37 | // 38 | // If `Printer#Name` is empty then it will be filled with 39 | // "printer_$printers.len". 40 | // 41 | // If a printer with the same `Printer#Name` is already 42 | // registered then it will be overridden by 43 | // this new "printer". 44 | // 45 | // Returns this Registry, therefore it can be used as builder. 46 | func (reg *Registry) RegisterPrinter(printer *Printer) *Registry { 47 | // if exists then remove first and then add the new one. 48 | if printerName := printer.Name; reg.Get(printerName) != nil { 49 | reg.Remove(printerName) 50 | } 51 | reg.mu.Lock() 52 | // no printer.Handle(s.handlers...) 53 | reg.printers = append(reg.printers, printer) 54 | reg.mu.Unlock() 55 | return reg 56 | } 57 | 58 | // Register creates and registers a new Printer 59 | // based on a name(string) and an "output"(io.Writer). 60 | // 61 | // If "printerName" is empty then it will be filled with 62 | // "printer_$printers.len". 63 | // 64 | // If a printer with the same `Printer#Name` is already 65 | // registered then it will be overridden by 66 | // this new "printer". 67 | // 68 | // Look `OutputFrom` too. 69 | // 70 | // Returns the just created Printer. 71 | func (reg *Registry) Register(printerName string, output io.Writer) *Printer { 72 | p := NewPrinter(printerName, output) 73 | reg.RegisterPrinter(p) 74 | return p 75 | } 76 | 77 | // Get returns a Printer based on the "printerName". 78 | // If printer with this name can't be found then 79 | // this function will return nil, so a check for 80 | // nil is always a good practice. 81 | func (reg *Registry) Get(printerName string) *Printer { 82 | reg.mu.Lock() 83 | defer reg.mu.Unlock() 84 | for _, p := range reg.printers { 85 | if p.Name == printerName { 86 | return p 87 | } 88 | } 89 | return nil 90 | } 91 | 92 | // Remove deletes a printer item from the printers collection 93 | // by its name. 94 | // 95 | // Returns this Registry, so it can be used as builder. 96 | func (reg *Registry) Remove(printerName string) *Registry { 97 | reg.mu.Lock() 98 | for i, p := range reg.printers { 99 | if p.Name == printerName { 100 | reg.printers = append(reg.printers[:i], reg.printers[i+1:]...) 101 | break 102 | } 103 | } 104 | reg.mu.Unlock() 105 | return reg 106 | } 107 | 108 | // Print accepts a value of "v", 109 | // tries to marshal its contents and flushes the result 110 | // to all available printers. 111 | func (reg *Registry) Print(v interface{}) (n int, err error) { 112 | return reg.printAll(v, false) 113 | } 114 | 115 | // Println accepts a value of "v", 116 | // tries to marshal its contents and flushes the result 117 | // to all available printers, it adds a new line at the ending, 118 | // the result doesn't contain this new line, therefore result's contents kept as expected. 119 | func (reg *Registry) Println(v interface{}) (n int, err error) { 120 | return reg.printAll(v, true) 121 | } 122 | 123 | func (reg *Registry) printAll(v interface{}, appendNewLine bool) (n int, err error) { 124 | // order once at first print. 125 | reg.once.Do(func() { 126 | reg.mu.Lock() 127 | sort.Slice(reg.printers, func(i, j int) bool { 128 | return reg.printers[i].priority > reg.printers[j].priority 129 | }) 130 | reg.mu.Unlock() 131 | }) 132 | 133 | for _, p := range reg.printers { 134 | prevErr := err 135 | 136 | printFunc := p.Print 137 | if appendNewLine { 138 | printFunc = p.Println 139 | } 140 | 141 | n, err = printFunc(v) 142 | 143 | if !p.Chained && n > 0 { 144 | break 145 | } 146 | n, err = combineOutputResult(n, err, prevErr) 147 | } 148 | return 149 | } 150 | 151 | func combineOutputResult(n int, err error, prevErr error) (totalN int, totalErr error) { 152 | if err != nil { 153 | if prevErr != nil { 154 | totalErr = errors.New(prevErr.Error() + string(NewLine) + err.Error()) 155 | } 156 | } 157 | 158 | totalN += n 159 | return 160 | } 161 | 162 | // Scan scans everything from "r" and prints 163 | // its new contents to the printers, 164 | // forever or until the returning "cancel" is fired, once. 165 | func (reg *Registry) Scan(r io.Reader, addNewLine bool) (cancel func()) { 166 | lp := len(reg.printers) 167 | if lp == 0 { 168 | return func() {} 169 | } 170 | 171 | cancelFuncs := make([]func(), lp, lp) 172 | cancel = func() { 173 | for _, c := range cancelFuncs { 174 | c() 175 | } 176 | } 177 | 178 | for i, p := range reg.printers { 179 | cancelFuncs[i] = p.Scan(r, addNewLine) 180 | } 181 | 182 | return cancel 183 | } 184 | 185 | func (reg *Registry) restore(b []byte) { 186 | for _, p := range reg.printers { 187 | p.restore(b) 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_sparc64.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 sparc64,linux 6 | 7 | package unix 8 | 9 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) 10 | //sys Dup2(oldfd int, newfd int) (err error) 11 | //sys Fchown(fd int, uid int, gid int) (err error) 12 | //sys Fstat(fd int, stat *Stat_t) (err error) 13 | //sys Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64 14 | //sys Fstatfs(fd int, buf *Statfs_t) (err error) 15 | //sys Ftruncate(fd int, length int64) (err error) 16 | //sysnb Getegid() (egid int) 17 | //sysnb Geteuid() (euid int) 18 | //sysnb Getgid() (gid int) 19 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) 20 | //sysnb Getuid() (uid int) 21 | //sysnb InotifyInit() (fd int, err error) 22 | //sys Lchown(path string, uid int, gid int) (err error) 23 | //sys Listen(s int, n int) (err error) 24 | //sys Lstat(path string, stat *Stat_t) (err error) 25 | //sys Pause() (err error) 26 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 27 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 28 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK 29 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) 30 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) 31 | //sys Setfsgid(gid int) (err error) 32 | //sys Setfsuid(uid int) (err error) 33 | //sysnb Setregid(rgid int, egid int) (err error) 34 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error) 35 | //sysnb Setresuid(ruid int, euid int, suid int) (err error) 36 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 37 | //sysnb Setreuid(ruid int, euid int) (err error) 38 | //sys Shutdown(fd int, how int) (err error) 39 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) 40 | //sys Stat(path string, stat *Stat_t) (err error) 41 | //sys Statfs(path string, buf *Statfs_t) (err error) 42 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) 43 | //sys Truncate(path string, length int64) (err error) 44 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 45 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 46 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 47 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 48 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) 49 | //sysnb setgroups(n int, list *_Gid_t) (err error) 50 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 51 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 52 | //sysnb socket(domain int, typ int, proto int) (fd int, err error) 53 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) 54 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 55 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 56 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 57 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 58 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 59 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 60 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 61 | 62 | func Ioperm(from int, num int, on int) (err error) { 63 | return ENOSYS 64 | } 65 | 66 | func Iopl(level int) (err error) { 67 | return ENOSYS 68 | } 69 | 70 | //sysnb Gettimeofday(tv *Timeval) (err error) 71 | 72 | func Time(t *Time_t) (tt Time_t, err error) { 73 | var tv Timeval 74 | err = Gettimeofday(&tv) 75 | if err != nil { 76 | return 0, err 77 | } 78 | if t != nil { 79 | *t = Time_t(tv.Sec) 80 | } 81 | return Time_t(tv.Sec), nil 82 | } 83 | 84 | //sys Utime(path string, buf *Utimbuf) (err error) 85 | 86 | func setTimespec(sec, nsec int64) Timespec { 87 | return Timespec{Sec: sec, Nsec: nsec} 88 | } 89 | 90 | func setTimeval(sec, usec int64) Timeval { 91 | return Timeval{Sec: sec, Usec: int32(usec)} 92 | } 93 | 94 | func (r *PtraceRegs) PC() uint64 { return r.Tpc } 95 | 96 | func (r *PtraceRegs) SetPC(pc uint64) { r.Tpc = pc } 97 | 98 | func (iov *Iovec) SetLen(length int) { 99 | iov.Len = uint64(length) 100 | } 101 | 102 | func (msghdr *Msghdr) SetControllen(length int) { 103 | msghdr.Controllen = uint64(length) 104 | } 105 | 106 | func (cmsg *Cmsghdr) SetLen(length int) { 107 | cmsg.Len = uint64(length) 108 | } 109 | 110 | //sysnb pipe(p *[2]_C_int) (err error) 111 | 112 | func Pipe(p []int) (err error) { 113 | if len(p) != 2 { 114 | return EINVAL 115 | } 116 | var pp [2]_C_int 117 | err = pipe(&pp) 118 | p[0] = int(pp[0]) 119 | p[1] = int(pp[1]) 120 | return 121 | } 122 | 123 | //sysnb pipe2(p *[2]_C_int, flags int) (err error) 124 | 125 | func Pipe2(p []int, flags int) (err error) { 126 | if len(p) != 2 { 127 | return EINVAL 128 | } 129 | var pp [2]_C_int 130 | err = pipe2(&pp, flags) 131 | p[0] = int(pp[0]) 132 | p[1] = int(pp[1]) 133 | return 134 | } 135 | 136 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) 137 | 138 | func Poll(fds []PollFd, timeout int) (n int, err error) { 139 | if len(fds) == 0 { 140 | return poll(nil, 0, timeout) 141 | } 142 | return poll(&fds[0], len(fds), timeout) 143 | } 144 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_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,linux 6 | 7 | package unix 8 | 9 | //sys Dup2(oldfd int, newfd int) (err error) 10 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) 11 | //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 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) 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) 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) 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 | func Gettimeofday(tv *Timeval) (err error) { 66 | errno := gettimeofday(tv) 67 | if errno != 0 { 68 | return errno 69 | } 70 | return nil 71 | } 72 | 73 | func Time(t *Time_t) (tt Time_t, err error) { 74 | var tv Timeval 75 | errno := gettimeofday(&tv) 76 | if errno != 0 { 77 | return 0, errno 78 | } 79 | if t != nil { 80 | *t = Time_t(tv.Sec) 81 | } 82 | return Time_t(tv.Sec), nil 83 | } 84 | 85 | //sys Utime(path string, buf *Utimbuf) (err error) 86 | 87 | func setTimespec(sec, nsec int64) Timespec { 88 | return Timespec{Sec: sec, Nsec: nsec} 89 | } 90 | 91 | func setTimeval(sec, usec int64) Timeval { 92 | return Timeval{Sec: sec, Usec: usec} 93 | } 94 | 95 | //sysnb pipe(p *[2]_C_int) (err error) 96 | 97 | func Pipe(p []int) (err error) { 98 | if len(p) != 2 { 99 | return EINVAL 100 | } 101 | var pp [2]_C_int 102 | err = pipe(&pp) 103 | p[0] = int(pp[0]) 104 | p[1] = int(pp[1]) 105 | return 106 | } 107 | 108 | //sysnb pipe2(p *[2]_C_int, flags int) (err error) 109 | 110 | func Pipe2(p []int, flags int) (err error) { 111 | if len(p) != 2 { 112 | return EINVAL 113 | } 114 | var pp [2]_C_int 115 | err = pipe2(&pp, flags) 116 | p[0] = int(pp[0]) 117 | p[1] = int(pp[1]) 118 | return 119 | } 120 | 121 | func (r *PtraceRegs) PC() uint64 { return r.Rip } 122 | 123 | func (r *PtraceRegs) SetPC(pc uint64) { r.Rip = pc } 124 | 125 | func (iov *Iovec) SetLen(length int) { 126 | iov.Len = uint64(length) 127 | } 128 | 129 | func (msghdr *Msghdr) SetControllen(length int) { 130 | msghdr.Controllen = uint64(length) 131 | } 132 | 133 | func (cmsg *Cmsghdr) SetLen(length int) { 134 | cmsg.Len = uint64(length) 135 | } 136 | 137 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) 138 | 139 | func Poll(fds []PollFd, timeout int) (n int, err error) { 140 | if len(fds) == 0 { 141 | return poll(nil, 0, timeout) 142 | } 143 | return poll(&fds[0], len(fds), timeout) 144 | } 145 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/cap_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 | // +build freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | errorspkg "errors" 11 | "fmt" 12 | ) 13 | 14 | // Go implementation of C mostly found in /usr/src/sys/kern/subr_capability.c 15 | 16 | const ( 17 | // This is the version of CapRights this package understands. See C implementation for parallels. 18 | capRightsGoVersion = CAP_RIGHTS_VERSION_00 19 | capArSizeMin = CAP_RIGHTS_VERSION_00 + 2 20 | capArSizeMax = capRightsGoVersion + 2 21 | ) 22 | 23 | var ( 24 | bit2idx = []int{ 25 | -1, 0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, 26 | 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 27 | } 28 | ) 29 | 30 | func capidxbit(right uint64) int { 31 | return int((right >> 57) & 0x1f) 32 | } 33 | 34 | func rightToIndex(right uint64) (int, error) { 35 | idx := capidxbit(right) 36 | if idx < 0 || idx >= len(bit2idx) { 37 | return -2, fmt.Errorf("index for right 0x%x out of range", right) 38 | } 39 | return bit2idx[idx], nil 40 | } 41 | 42 | func caprver(right uint64) int { 43 | return int(right >> 62) 44 | } 45 | 46 | func capver(rights *CapRights) int { 47 | return caprver(rights.Rights[0]) 48 | } 49 | 50 | func caparsize(rights *CapRights) int { 51 | return capver(rights) + 2 52 | } 53 | 54 | // CapRightsSet sets the permissions in setrights in rights. 55 | func CapRightsSet(rights *CapRights, setrights []uint64) error { 56 | // This is essentially a copy of cap_rights_vset() 57 | if capver(rights) != CAP_RIGHTS_VERSION_00 { 58 | return fmt.Errorf("bad rights version %d", capver(rights)) 59 | } 60 | 61 | n := caparsize(rights) 62 | if n < capArSizeMin || n > capArSizeMax { 63 | return errorspkg.New("bad rights size") 64 | } 65 | 66 | for _, right := range setrights { 67 | if caprver(right) != CAP_RIGHTS_VERSION_00 { 68 | return errorspkg.New("bad right version") 69 | } 70 | i, err := rightToIndex(right) 71 | if err != nil { 72 | return err 73 | } 74 | if i >= n { 75 | return errorspkg.New("index overflow") 76 | } 77 | if capidxbit(rights.Rights[i]) != capidxbit(right) { 78 | return errorspkg.New("index mismatch") 79 | } 80 | rights.Rights[i] |= right 81 | if capidxbit(rights.Rights[i]) != capidxbit(right) { 82 | return errorspkg.New("index mismatch (after assign)") 83 | } 84 | } 85 | 86 | return nil 87 | } 88 | 89 | // CapRightsClear clears the permissions in clearrights from rights. 90 | func CapRightsClear(rights *CapRights, clearrights []uint64) error { 91 | // This is essentially a copy of cap_rights_vclear() 92 | if capver(rights) != CAP_RIGHTS_VERSION_00 { 93 | return fmt.Errorf("bad rights version %d", capver(rights)) 94 | } 95 | 96 | n := caparsize(rights) 97 | if n < capArSizeMin || n > capArSizeMax { 98 | return errorspkg.New("bad rights size") 99 | } 100 | 101 | for _, right := range clearrights { 102 | if caprver(right) != CAP_RIGHTS_VERSION_00 { 103 | return errorspkg.New("bad right version") 104 | } 105 | i, err := rightToIndex(right) 106 | if err != nil { 107 | return err 108 | } 109 | if i >= n { 110 | return errorspkg.New("index overflow") 111 | } 112 | if capidxbit(rights.Rights[i]) != capidxbit(right) { 113 | return errorspkg.New("index mismatch") 114 | } 115 | rights.Rights[i] &= ^(right & 0x01FFFFFFFFFFFFFF) 116 | if capidxbit(rights.Rights[i]) != capidxbit(right) { 117 | return errorspkg.New("index mismatch (after assign)") 118 | } 119 | } 120 | 121 | return nil 122 | } 123 | 124 | // CapRightsIsSet checks whether all the permissions in setrights are present in rights. 125 | func CapRightsIsSet(rights *CapRights, setrights []uint64) (bool, error) { 126 | // This is essentially a copy of cap_rights_is_vset() 127 | if capver(rights) != CAP_RIGHTS_VERSION_00 { 128 | return false, fmt.Errorf("bad rights version %d", capver(rights)) 129 | } 130 | 131 | n := caparsize(rights) 132 | if n < capArSizeMin || n > capArSizeMax { 133 | return false, errorspkg.New("bad rights size") 134 | } 135 | 136 | for _, right := range setrights { 137 | if caprver(right) != CAP_RIGHTS_VERSION_00 { 138 | return false, errorspkg.New("bad right version") 139 | } 140 | i, err := rightToIndex(right) 141 | if err != nil { 142 | return false, err 143 | } 144 | if i >= n { 145 | return false, errorspkg.New("index overflow") 146 | } 147 | if capidxbit(rights.Rights[i]) != capidxbit(right) { 148 | return false, errorspkg.New("index mismatch") 149 | } 150 | if (rights.Rights[i] & right) != right { 151 | return false, nil 152 | } 153 | } 154 | 155 | return true, nil 156 | } 157 | 158 | func capright(idx uint64, bit uint64) uint64 { 159 | return ((1 << (57 + idx)) | bit) 160 | } 161 | 162 | // CapRightsInit returns a pointer to an initialised CapRights structure filled with rights. 163 | // See man cap_rights_init(3) and rights(4). 164 | func CapRightsInit(rights []uint64) (*CapRights, error) { 165 | var r CapRights 166 | r.Rights[0] = (capRightsGoVersion << 62) | capright(0, 0) 167 | r.Rights[1] = capright(1, 0) 168 | 169 | err := CapRightsSet(&r, rights) 170 | if err != nil { 171 | return nil, err 172 | } 173 | return &r, nil 174 | } 175 | 176 | // CapRightsLimit reduces the operations permitted on fd to at most those contained in rights. 177 | // The capability rights on fd can never be increased by CapRightsLimit. 178 | // See man cap_rights_limit(2) and rights(4). 179 | func CapRightsLimit(fd uintptr, rights *CapRights) error { 180 | return capRightsLimit(int(fd), rights) 181 | } 182 | 183 | // CapRightsGet returns a CapRights structure containing the operations permitted on fd. 184 | // See man cap_rights_get(3) and rights(4). 185 | func CapRightsGet(fd uintptr) (*CapRights, error) { 186 | r, err := CapRightsInit(nil) 187 | if err != nil { 188 | return nil, err 189 | } 190 | err = capRightsGet(capRightsGoVersion, int(fd), r) 191 | if err != nil { 192 | return nil, err 193 | } 194 | return r, nil 195 | } 196 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Rizla builds, runs and monitors your Go Applications with ease. 2 | 3 | [![Travis Widget]][Travis] [![Release Widget]][Release] [![Report Widget]][Report] [![License Widget]][License] [![Chat Widget]][Chat] 4 | 5 | Installation 6 | ------------ 7 | The only requirement is the [Go Programming Language](https://golang.org/dl), at least 1.7. 8 | 9 | ```sh 10 | $ go get -u github.com/kataras/rizla 11 | ``` 12 | 13 | 14 | # Getting Started 15 | 16 | ```bash 17 | $ rizla main.go #single project monitoring 18 | $ rizla C:/myprojects/project1/main.go C:/myprojects/project2/main.go #multi projects monitoring 19 | $ rizla -walk main.go #prepend '-walk' only when the default file changes scanning method doesn't works for you. 20 | $ rizla -delay=5s main.go # if delay > 0 then it delays the reload, also note that it accepts the first change but the rest of changes every "delay". 21 | ``` 22 | 23 | Want to use it from your project's source code? easy 24 | 25 | ```sh 26 | $ cat from_code_simple.go 27 | ``` 28 | 29 | ```go 30 | package main 31 | 32 | import ( 33 | "github.com/kataras/rizla/rizla" 34 | ) 35 | 36 | func main() { 37 | // Build, run & start monitoring the projects 38 | rizla.Run("C:/iris-project/main.go", "C:/otherproject/main.go") 39 | // watcher, _ := rizla.WatcherFromFlag("-walk") 40 | // rizla.RunWith(watcher, "./main.go", 0) 41 | } 42 | ``` 43 | 44 | ```sh 45 | $ cat from_code_pro.go 46 | ``` 47 | ```go 48 | package main 49 | 50 | import ( 51 | "path/filepath" 52 | "runtime" 53 | "time" 54 | "os" 55 | 56 | "github.com/kataras/rizla/rizla" 57 | ) 58 | 59 | func main() { 60 | // Create a new project by the main source file 61 | project := rizla.NewProject("C:/myproject/main.go") 62 | 63 | // The below are optional 64 | 65 | // Optionally, change the out for info logs and error messages. 66 | project.Out.SetOutput(os.Stdout) 67 | project.Err.SetOutput(os.Stderr) 68 | 69 | project.Name = "My super project" 70 | // Allow reload every 3 seconds or more no less 71 | project.AllowReloadAfter = time.Duration(3) * time.Second 72 | // Custom subdirectory matcher, for the watcher, return true to include this folder to the watcher 73 | // the default is: 74 | project.Watcher = func(absolutePath string) bool { 75 | base := filepath.Base(abs) 76 | return !(base == ".git" || base == "node_modules" || base == "vendor") 77 | } 78 | // Custom file matcher on runtime (file change), return true to reload when a file with this file name changed 79 | // the default is: 80 | project.Matcher = func(filename string) bool { 81 | isWindows = runtime.GOOS == "windows" 82 | goExt = ".go" 83 | return (filepath.Ext(fullname) == goExt) || 84 | (!isWindows && strings.Contains(fullname, goExt)) 85 | } 86 | // Add arguments, these will be used from the executable file 87 | project.Args = []string{"-myargument","the value","-otherargument","a value"} 88 | // Custom callback before reload, the default is: 89 | project.OnReload = func(string) { 90 | fromproject := "" 91 | if p.Name != "" { 92 | fromproject = "From project '" + project.Name + "': " 93 | } 94 | project.Out.Infof("%sA change has been detected, reloading now...", fromproject) 95 | } 96 | // Custom callback after reload, the default is: 97 | project.OnReloaded = func(string) { 98 | 99 | } 100 | 101 | // End of optional 102 | 103 | // Add the project to the rizla container 104 | rizla.Add(project) 105 | // Build, run & start monitoring the project(s) 106 | rizla.Run(nil) 107 | } 108 | ``` 109 | 110 | > That's all! 111 | 112 | FAQ 113 | ------------ 114 | Ask questions and get real-time answers from the [Chat][CHAT]. 115 | 116 | Features 117 | ------------ 118 | - Super easy - is created for everyone. 119 | - You can use it either as command line tool either as part of your project's source code! 120 | - Multi-Monitoring - Supports monitoring of unlimited projects. 121 | - Rizla, by-default, uses the operating system's signals to fire a change because it is the fastest way and it consumes the minimal CPU. 122 | - You 're still able to change the watcher to use the `filepath.Walk` too with `-walk` flag. 123 | - delay reload on detect change with `-delay` 124 | 125 | People 126 | 127 | ------------ 128 | If you'd like to discuss this package, or ask questions about it, feel free to [Chat][CHAT]. 129 | 130 | The author of rizla is [@kataras](https://github.com/kataras). 131 | 132 | Versioning 133 | ------------ 134 | 135 | Current: **v0.1.1** 136 | 137 | [HISTORY](https://github.com/kataras/rizla/blob/master/HISTORY.md) file is your best friend! 138 | 139 | Read more about Semantic Versioning 2.0.0 140 | 141 | - http://semver.org/ 142 | - https://en.wikipedia.org/wiki/Software_versioning 143 | - https://wiki.debian.org/UpstreamGuide#Releases_and_Versions 144 | 145 | Todo 146 | ------------ 147 | 148 | - [ ] Tests 149 | - [ ] Provide full examples. 150 | 151 | Third-Party Licenses 152 | ------------ 153 | 154 | Third-Party Licenses can be found [here](THIRDPARTY-LICENSE) 155 | 156 | License 157 | ------------ 158 | 159 | This project is licensed under the MIT License. 160 | 161 | License can be found [here](LICENSE). 162 | 163 | [Travis Widget]: https://img.shields.io/travis/kataras/rizla.svg?style=flat-square 164 | [Travis]: http://travis-ci.org/kataras/rizla 165 | [License Widget]: https://img.shields.io/badge/license-MIT%20%20License%20-E91E63.svg?style=flat-square 166 | [License]: https://github.com/kataras/rizla/blob/master/LICENSE 167 | [Release Widget]: https://img.shields.io/badge/release-v0.1.1-blue.svg?style=flat-square 168 | [Release]: https://github.com/kataras/rizla/releases 169 | [Chat Widget]: https://img.shields.io/badge/community-chat-00BCD4.svg?style=flat-square 170 | [Chat]: https://kataras.rocket.chat/channel/rizla 171 | [ChatMain]: https://kataras.rocket.chat/channel/rizla 172 | [ChatAlternative]: https://gitter.im/kataras/rizla 173 | [Report Widget]: https://img.shields.io/badge/report%20card-A%2B-F44336.svg?style=flat-square 174 | [Report]: http://goreportcard.com/report/kataras/rizla 175 | [Language Widget]: https://img.shields.io/badge/powered_by-Go-3362c2.svg?style=flat-square 176 | [Language]: http://golang.org 177 | [Platform Widget]: https://img.shields.io/badge/platform-Any--OS-gray.svg?style=flat-square 178 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | # Copyright 2011 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 | # 8 | # Parse the header files for OpenBSD and generate a Go usable sysctl MIB. 9 | # 10 | # Build a MIB with each entry being an array containing the level, type and 11 | # a hash that will contain additional entries if the current entry is a node. 12 | # We then walk this MIB and create a flattened sysctl name to OID hash. 13 | # 14 | 15 | use strict; 16 | 17 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") { 18 | print STDERR "GOARCH or GOOS not defined in environment\n"; 19 | exit 1; 20 | } 21 | 22 | my $debug = 0; 23 | my %ctls = (); 24 | 25 | my @headers = qw ( 26 | sys/sysctl.h 27 | sys/socket.h 28 | sys/tty.h 29 | sys/malloc.h 30 | sys/mount.h 31 | sys/namei.h 32 | sys/sem.h 33 | sys/shm.h 34 | sys/vmmeter.h 35 | uvm/uvm_param.h 36 | uvm/uvm_swap_encrypt.h 37 | ddb/db_var.h 38 | net/if.h 39 | net/if_pfsync.h 40 | net/pipex.h 41 | netinet/in.h 42 | netinet/icmp_var.h 43 | netinet/igmp_var.h 44 | netinet/ip_ah.h 45 | netinet/ip_carp.h 46 | netinet/ip_divert.h 47 | netinet/ip_esp.h 48 | netinet/ip_ether.h 49 | netinet/ip_gre.h 50 | netinet/ip_ipcomp.h 51 | netinet/ip_ipip.h 52 | netinet/pim_var.h 53 | netinet/tcp_var.h 54 | netinet/udp_var.h 55 | netinet6/in6.h 56 | netinet6/ip6_divert.h 57 | netinet6/pim6_var.h 58 | netinet/icmp6.h 59 | netmpls/mpls.h 60 | ); 61 | 62 | my @ctls = qw ( 63 | kern 64 | vm 65 | fs 66 | net 67 | #debug # Special handling required 68 | hw 69 | #machdep # Arch specific 70 | user 71 | ddb 72 | #vfs # Special handling required 73 | fs.posix 74 | kern.forkstat 75 | kern.intrcnt 76 | kern.malloc 77 | kern.nchstats 78 | kern.seminfo 79 | kern.shminfo 80 | kern.timecounter 81 | kern.tty 82 | kern.watchdog 83 | net.bpf 84 | net.ifq 85 | net.inet 86 | net.inet.ah 87 | net.inet.carp 88 | net.inet.divert 89 | net.inet.esp 90 | net.inet.etherip 91 | net.inet.gre 92 | net.inet.icmp 93 | net.inet.igmp 94 | net.inet.ip 95 | net.inet.ip.ifq 96 | net.inet.ipcomp 97 | net.inet.ipip 98 | net.inet.mobileip 99 | net.inet.pfsync 100 | net.inet.pim 101 | net.inet.tcp 102 | net.inet.udp 103 | net.inet6 104 | net.inet6.divert 105 | net.inet6.ip6 106 | net.inet6.icmp6 107 | net.inet6.pim6 108 | net.inet6.tcp6 109 | net.inet6.udp6 110 | net.mpls 111 | net.mpls.ifq 112 | net.key 113 | net.pflow 114 | net.pfsync 115 | net.pipex 116 | net.rt 117 | vm.swapencrypt 118 | #vfsgenctl # Special handling required 119 | ); 120 | 121 | # Node name "fixups" 122 | my %ctl_map = ( 123 | "ipproto" => "net.inet", 124 | "net.inet.ipproto" => "net.inet", 125 | "net.inet6.ipv6proto" => "net.inet6", 126 | "net.inet6.ipv6" => "net.inet6.ip6", 127 | "net.inet.icmpv6" => "net.inet6.icmp6", 128 | "net.inet6.divert6" => "net.inet6.divert", 129 | "net.inet6.tcp6" => "net.inet.tcp", 130 | "net.inet6.udp6" => "net.inet.udp", 131 | "mpls" => "net.mpls", 132 | "swpenc" => "vm.swapencrypt" 133 | ); 134 | 135 | # Node mappings 136 | my %node_map = ( 137 | "net.inet.ip.ifq" => "net.ifq", 138 | "net.inet.pfsync" => "net.pfsync", 139 | "net.mpls.ifq" => "net.ifq" 140 | ); 141 | 142 | my $ctlname; 143 | my %mib = (); 144 | my %sysctl = (); 145 | my $node; 146 | 147 | sub debug() { 148 | print STDERR "$_[0]\n" if $debug; 149 | } 150 | 151 | # Walk the MIB and build a sysctl name to OID mapping. 152 | sub build_sysctl() { 153 | my ($node, $name, $oid) = @_; 154 | my %node = %{$node}; 155 | my @oid = @{$oid}; 156 | 157 | foreach my $key (sort keys %node) { 158 | my @node = @{$node{$key}}; 159 | my $nodename = $name.($name ne '' ? '.' : '').$key; 160 | my @nodeoid = (@oid, $node[0]); 161 | if ($node[1] eq 'CTLTYPE_NODE') { 162 | if (exists $node_map{$nodename}) { 163 | $node = \%mib; 164 | $ctlname = $node_map{$nodename}; 165 | foreach my $part (split /\./, $ctlname) { 166 | $node = \%{@{$$node{$part}}[2]}; 167 | } 168 | } else { 169 | $node = $node[2]; 170 | } 171 | &build_sysctl($node, $nodename, \@nodeoid); 172 | } elsif ($node[1] ne '') { 173 | $sysctl{$nodename} = \@nodeoid; 174 | } 175 | } 176 | } 177 | 178 | foreach my $ctl (@ctls) { 179 | $ctls{$ctl} = $ctl; 180 | } 181 | 182 | # Build MIB 183 | foreach my $header (@headers) { 184 | &debug("Processing $header..."); 185 | open HEADER, "/usr/include/$header" || 186 | print STDERR "Failed to open $header\n"; 187 | while (
) { 188 | if ($_ =~ /^#define\s+(CTL_NAMES)\s+{/ || 189 | $_ =~ /^#define\s+(CTL_(.*)_NAMES)\s+{/ || 190 | $_ =~ /^#define\s+((.*)CTL_NAMES)\s+{/) { 191 | if ($1 eq 'CTL_NAMES') { 192 | # Top level. 193 | $node = \%mib; 194 | } else { 195 | # Node. 196 | my $nodename = lc($2); 197 | if ($header =~ /^netinet\//) { 198 | $ctlname = "net.inet.$nodename"; 199 | } elsif ($header =~ /^netinet6\//) { 200 | $ctlname = "net.inet6.$nodename"; 201 | } elsif ($header =~ /^net\//) { 202 | $ctlname = "net.$nodename"; 203 | } else { 204 | $ctlname = "$nodename"; 205 | $ctlname =~ s/^(fs|net|kern)_/$1\./; 206 | } 207 | if (exists $ctl_map{$ctlname}) { 208 | $ctlname = $ctl_map{$ctlname}; 209 | } 210 | if (not exists $ctls{$ctlname}) { 211 | &debug("Ignoring $ctlname..."); 212 | next; 213 | } 214 | 215 | # Walk down from the top of the MIB. 216 | $node = \%mib; 217 | foreach my $part (split /\./, $ctlname) { 218 | if (not exists $$node{$part}) { 219 | &debug("Missing node $part"); 220 | $$node{$part} = [ 0, '', {} ]; 221 | } 222 | $node = \%{@{$$node{$part}}[2]}; 223 | } 224 | } 225 | 226 | # Populate current node with entries. 227 | my $i = -1; 228 | while (defined($_) && $_ !~ /^}/) { 229 | $_ =
; 230 | $i++ if $_ =~ /{.*}/; 231 | next if $_ !~ /{\s+"(\w+)",\s+(CTLTYPE_[A-Z]+)\s+}/; 232 | $$node{$1} = [ $i, $2, {} ]; 233 | } 234 | } 235 | } 236 | close HEADER; 237 | } 238 | 239 | &build_sysctl(\%mib, "", []); 240 | 241 | print < 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | 50 | enum { 51 | sizeofPtr = sizeof(void*), 52 | }; 53 | 54 | union sockaddr_all { 55 | struct sockaddr s1; // this one gets used for fields 56 | struct sockaddr_in s2; // these pad it out 57 | struct sockaddr_in6 s3; 58 | struct sockaddr_un s4; 59 | struct sockaddr_dl s5; 60 | }; 61 | 62 | struct sockaddr_any { 63 | struct sockaddr addr; 64 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; 65 | }; 66 | 67 | */ 68 | import "C" 69 | 70 | // Machine characteristics; for internal use. 71 | 72 | const ( 73 | sizeofPtr = C.sizeofPtr 74 | sizeofShort = C.sizeof_short 75 | sizeofInt = C.sizeof_int 76 | sizeofLong = C.sizeof_long 77 | sizeofLongLong = C.sizeof_longlong 78 | ) 79 | 80 | // Basic types 81 | 82 | type ( 83 | _C_short C.short 84 | _C_int C.int 85 | _C_long C.long 86 | _C_long_long C.longlong 87 | ) 88 | 89 | // Time 90 | 91 | type Timespec C.struct_timespec 92 | 93 | type Timeval C.struct_timeval 94 | 95 | // Processes 96 | 97 | type Rusage C.struct_rusage 98 | 99 | type Rlimit C.struct_rlimit 100 | 101 | type _Gid_t C.gid_t 102 | 103 | // Files 104 | 105 | type Stat_t C.struct_stat 106 | 107 | type Statfs_t C.struct_statfs 108 | 109 | type Flock_t C.struct_flock 110 | 111 | type Dirent C.struct_dirent 112 | 113 | type Fsid C.fsid_t 114 | 115 | // File system limits 116 | 117 | const ( 118 | PathMax = C.PATH_MAX 119 | ) 120 | 121 | // Sockets 122 | 123 | type RawSockaddrInet4 C.struct_sockaddr_in 124 | 125 | type RawSockaddrInet6 C.struct_sockaddr_in6 126 | 127 | type RawSockaddrUnix C.struct_sockaddr_un 128 | 129 | type RawSockaddrDatalink C.struct_sockaddr_dl 130 | 131 | type RawSockaddr C.struct_sockaddr 132 | 133 | type RawSockaddrAny C.struct_sockaddr_any 134 | 135 | type _Socklen C.socklen_t 136 | 137 | type Linger C.struct_linger 138 | 139 | type Iovec C.struct_iovec 140 | 141 | type IPMreq C.struct_ip_mreq 142 | 143 | type IPv6Mreq C.struct_ipv6_mreq 144 | 145 | type Msghdr C.struct_msghdr 146 | 147 | type Cmsghdr C.struct_cmsghdr 148 | 149 | type Inet6Pktinfo C.struct_in6_pktinfo 150 | 151 | type IPv6MTUInfo C.struct_ip6_mtuinfo 152 | 153 | type ICMPv6Filter C.struct_icmp6_filter 154 | 155 | const ( 156 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in 157 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 158 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any 159 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un 160 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl 161 | SizeofLinger = C.sizeof_struct_linger 162 | SizeofIPMreq = C.sizeof_struct_ip_mreq 163 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq 164 | SizeofMsghdr = C.sizeof_struct_msghdr 165 | SizeofCmsghdr = C.sizeof_struct_cmsghdr 166 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo 167 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo 168 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter 169 | ) 170 | 171 | // Ptrace requests 172 | 173 | const ( 174 | PTRACE_TRACEME = C.PT_TRACE_ME 175 | PTRACE_CONT = C.PT_CONTINUE 176 | PTRACE_KILL = C.PT_KILL 177 | ) 178 | 179 | // Events (kqueue, kevent) 180 | 181 | type Kevent_t C.struct_kevent 182 | 183 | // Select 184 | 185 | type FdSet C.fd_set 186 | 187 | // Routing and interface messages 188 | 189 | const ( 190 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr 191 | SizeofIfData = C.sizeof_struct_if_data 192 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr 193 | SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr 194 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr 195 | SizeofRtMetrics = C.sizeof_struct_rt_metrics 196 | ) 197 | 198 | type IfMsghdr C.struct_if_msghdr 199 | 200 | type IfData C.struct_if_data 201 | 202 | type IfaMsghdr C.struct_ifa_msghdr 203 | 204 | type IfAnnounceMsghdr C.struct_if_announcemsghdr 205 | 206 | type RtMsghdr C.struct_rt_msghdr 207 | 208 | type RtMetrics C.struct_rt_metrics 209 | 210 | type Mclpool C.struct_mclpool 211 | 212 | // Berkeley packet filter 213 | 214 | const ( 215 | SizeofBpfVersion = C.sizeof_struct_bpf_version 216 | SizeofBpfStat = C.sizeof_struct_bpf_stat 217 | SizeofBpfProgram = C.sizeof_struct_bpf_program 218 | SizeofBpfInsn = C.sizeof_struct_bpf_insn 219 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr 220 | ) 221 | 222 | type BpfVersion C.struct_bpf_version 223 | 224 | type BpfStat C.struct_bpf_stat 225 | 226 | type BpfProgram C.struct_bpf_program 227 | 228 | type BpfInsn C.struct_bpf_insn 229 | 230 | type BpfHdr C.struct_bpf_hdr 231 | 232 | type BpfTimeval C.struct_bpf_timeval 233 | 234 | // Terminal handling 235 | 236 | type Termios C.struct_termios 237 | 238 | type Winsize C.struct_winsize 239 | 240 | // fchmodat-like syscalls. 241 | 242 | const ( 243 | AT_FDCWD = C.AT_FDCWD 244 | AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW 245 | ) 246 | 247 | // poll 248 | 249 | type PollFd C.struct_pollfd 250 | 251 | const ( 252 | POLLERR = C.POLLERR 253 | POLLHUP = C.POLLHUP 254 | POLLIN = C.POLLIN 255 | POLLNVAL = C.POLLNVAL 256 | POLLOUT = C.POLLOUT 257 | POLLPRI = C.POLLPRI 258 | POLLRDBAND = C.POLLRDBAND 259 | POLLRDNORM = C.POLLRDNORM 260 | POLLWRBAND = C.POLLWRBAND 261 | POLLWRNORM = C.POLLWRNORM 262 | ) 263 | 264 | // Sysctl 265 | 266 | type Sysctlnode C.struct_sysctlnode 267 | 268 | // Uname 269 | 270 | type Utsname C.struct_utsname 271 | --------------------------------------------------------------------------------