├── .editorconfig ├── .gitignore ├── Godeps ├── Godeps.json └── Readme ├── LICENSE ├── LICENSE.kubernetes ├── Makefile ├── README.md ├── cmd.go ├── kube ├── kubectl.go ├── kubectl_test.go ├── kubetool.go ├── kubetool_test.go ├── test_rc.yml ├── types.go ├── types_intstr.go ├── types_time.go └── types_unversioned.go └── vendor ├── github.com ├── alecthomas │ ├── kingpin │ │ ├── .travis.yml │ │ ├── COPYING │ │ ├── README.md │ │ ├── actions.go │ │ ├── app.go │ │ ├── args.go │ │ ├── cmd.go │ │ ├── completions.go │ │ ├── doc.go │ │ ├── envar.go │ │ ├── flags.go │ │ ├── global.go │ │ ├── guesswidth.go │ │ ├── guesswidth_unix.go │ │ ├── model.go │ │ ├── parser.go │ │ ├── parsers.go │ │ ├── templates.go │ │ ├── usage.go │ │ ├── values.go │ │ ├── values.json │ │ └── values_generated.go │ ├── template │ │ ├── README.md │ │ ├── doc.go │ │ ├── exec.go │ │ ├── funcs.go │ │ ├── helper.go │ │ ├── parse │ │ │ ├── lex.go │ │ │ ├── node.go │ │ │ └── parse.go │ │ └── template.go │ └── units │ │ ├── COPYING │ │ ├── README.md │ │ ├── bytes.go │ │ ├── doc.go │ │ ├── si.go │ │ └── util.go ├── buger │ └── goterm │ │ ├── README.md │ │ ├── box.go │ │ ├── plot.go │ │ ├── table.go │ │ ├── terminal.go │ │ ├── terminal_nosysioctl.go │ │ └── terminal_sysioctl.go ├── davecgh │ └── go-spew │ │ ├── LICENSE │ │ └── spew │ │ ├── bypass.go │ │ ├── bypasssafe.go │ │ ├── common.go │ │ ├── config.go │ │ ├── doc.go │ │ ├── dump.go │ │ ├── format.go │ │ └── spew.go ├── fatih │ └── color │ │ ├── .travis.yml │ │ ├── LICENSE.md │ │ ├── README.md │ │ ├── color.go │ │ └── doc.go ├── google │ └── gofuzz │ │ ├── .travis.yml │ │ ├── CONTRIBUTING.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── doc.go │ │ └── fuzz.go ├── mattn │ ├── go-colorable │ │ ├── README.md │ │ ├── colorable_others.go │ │ └── colorable_windows.go │ └── go-isatty │ │ ├── LICENSE │ │ ├── README.md │ │ ├── doc.go │ │ ├── isatty_appengine.go │ │ ├── isatty_bsd.go │ │ ├── isatty_linux.go │ │ ├── isatty_solaris.go │ │ └── isatty_windows.go ├── pmezard │ └── go-difflib │ │ ├── LICENSE │ │ └── difflib │ │ └── difflib.go └── stretchr │ └── testify │ ├── LICENCE.txt │ ├── LICENSE │ ├── assert │ ├── assertion_forward.go │ ├── assertion_forward.go.tmpl │ ├── assertions.go │ ├── doc.go │ ├── errors.go │ ├── forward_assertions.go │ └── http_assertions.go │ └── require │ ├── doc.go │ ├── forward_requirements.go │ ├── require.go │ ├── require.go.tmpl │ ├── require_forward.go │ ├── require_forward.go.tmpl │ └── requirements.go └── golang.org └── x └── sys ├── LICENSE ├── PATENTS └── unix ├── .gitignore ├── asm.s ├── asm_darwin_386.s ├── asm_darwin_amd64.s ├── asm_darwin_arm.s ├── asm_darwin_arm64.s ├── asm_dragonfly_386.s ├── asm_dragonfly_amd64.s ├── asm_freebsd_386.s ├── asm_freebsd_amd64.s ├── asm_freebsd_arm.s ├── asm_linux_386.s ├── asm_linux_amd64.s ├── asm_linux_arm.s ├── asm_linux_arm64.s ├── asm_linux_mips64x.s ├── asm_linux_ppc64x.s ├── asm_netbsd_386.s ├── asm_netbsd_amd64.s ├── asm_netbsd_arm.s ├── asm_openbsd_386.s ├── asm_openbsd_amd64.s ├── asm_solaris_amd64.s ├── constants.go ├── env_unix.go ├── env_unset.go ├── flock.go ├── flock_linux_32bit.go ├── gccgo.go ├── gccgo_c.c ├── gccgo_linux_amd64.go ├── mkall.sh ├── mkerrors.sh ├── mksyscall.pl ├── mksyscall_solaris.pl ├── mksysctl_openbsd.pl ├── mksysnum_darwin.pl ├── mksysnum_dragonfly.pl ├── mksysnum_freebsd.pl ├── mksysnum_linux.pl ├── mksysnum_netbsd.pl ├── mksysnum_openbsd.pl ├── race.go ├── race0.go ├── sockcmsg_linux.go ├── sockcmsg_unix.go ├── str.go ├── syscall.go ├── syscall_bsd.go ├── syscall_darwin.go ├── syscall_darwin_386.go ├── syscall_darwin_amd64.go ├── syscall_darwin_arm.go ├── syscall_darwin_arm64.go ├── syscall_dragonfly.go ├── syscall_dragonfly_386.go ├── syscall_dragonfly_amd64.go ├── syscall_freebsd.go ├── syscall_freebsd_386.go ├── syscall_freebsd_amd64.go ├── syscall_freebsd_arm.go ├── syscall_linux.go ├── syscall_linux_386.go ├── syscall_linux_amd64.go ├── syscall_linux_arm.go ├── syscall_linux_arm64.go ├── syscall_linux_mips64x.go ├── syscall_linux_ppc64x.go ├── syscall_netbsd.go ├── syscall_netbsd_386.go ├── syscall_netbsd_amd64.go ├── syscall_netbsd_arm.go ├── syscall_no_getwd.go ├── syscall_openbsd.go ├── syscall_openbsd_386.go ├── syscall_openbsd_amd64.go ├── syscall_solaris.go ├── syscall_solaris_amd64.go ├── syscall_unix.go ├── types_darwin.go ├── types_dragonfly.go ├── types_freebsd.go ├── types_linux.go ├── types_netbsd.go ├── types_openbsd.go ├── types_solaris.go ├── zerrors_darwin_386.go ├── zerrors_darwin_amd64.go ├── zerrors_darwin_arm.go ├── zerrors_darwin_arm64.go ├── zerrors_dragonfly_386.go ├── zerrors_dragonfly_amd64.go ├── zerrors_freebsd_386.go ├── zerrors_freebsd_amd64.go ├── zerrors_freebsd_arm.go ├── zerrors_linux_386.go ├── zerrors_linux_amd64.go ├── zerrors_linux_arm.go ├── zerrors_linux_arm64.go ├── zerrors_linux_mips64.go ├── zerrors_linux_mips64le.go ├── zerrors_linux_ppc64.go ├── zerrors_linux_ppc64le.go ├── zerrors_netbsd_386.go ├── zerrors_netbsd_amd64.go ├── zerrors_netbsd_arm.go ├── zerrors_openbsd_386.go ├── zerrors_openbsd_amd64.go ├── zerrors_solaris_amd64.go ├── zsyscall_darwin_386.go ├── zsyscall_darwin_amd64.go ├── zsyscall_darwin_arm.go ├── zsyscall_darwin_arm64.go ├── zsyscall_dragonfly_386.go ├── zsyscall_dragonfly_amd64.go ├── zsyscall_freebsd_386.go ├── zsyscall_freebsd_amd64.go ├── zsyscall_freebsd_arm.go ├── zsyscall_linux_386.go ├── zsyscall_linux_amd64.go ├── zsyscall_linux_arm.go ├── zsyscall_linux_arm64.go ├── zsyscall_linux_mips64.go ├── zsyscall_linux_mips64le.go ├── zsyscall_linux_ppc64.go ├── zsyscall_linux_ppc64le.go ├── zsyscall_netbsd_386.go ├── zsyscall_netbsd_amd64.go ├── zsyscall_netbsd_arm.go ├── zsyscall_openbsd_386.go ├── zsyscall_openbsd_amd64.go ├── zsyscall_solaris_amd64.go ├── zsysctl_openbsd.go ├── zsysnum_darwin_386.go ├── zsysnum_darwin_amd64.go ├── zsysnum_darwin_arm.go ├── zsysnum_darwin_arm64.go ├── zsysnum_dragonfly_386.go ├── zsysnum_dragonfly_amd64.go ├── zsysnum_freebsd_386.go ├── zsysnum_freebsd_amd64.go ├── zsysnum_freebsd_arm.go ├── zsysnum_linux_386.go ├── zsysnum_linux_amd64.go ├── zsysnum_linux_arm.go ├── zsysnum_linux_arm64.go ├── zsysnum_linux_mips64.go ├── zsysnum_linux_mips64le.go ├── zsysnum_linux_ppc64.go ├── zsysnum_linux_ppc64le.go ├── zsysnum_netbsd_386.go ├── zsysnum_netbsd_amd64.go ├── zsysnum_netbsd_arm.go ├── zsysnum_openbsd_386.go ├── zsysnum_openbsd_amd64.go ├── zsysnum_solaris_amd64.go ├── ztypes_darwin_386.go ├── ztypes_darwin_amd64.go ├── ztypes_darwin_arm.go ├── ztypes_darwin_arm64.go ├── ztypes_dragonfly_386.go ├── ztypes_dragonfly_amd64.go ├── ztypes_freebsd_386.go ├── ztypes_freebsd_amd64.go ├── ztypes_freebsd_arm.go ├── ztypes_linux_386.go ├── ztypes_linux_amd64.go ├── ztypes_linux_arm.go ├── ztypes_linux_arm64.go ├── ztypes_linux_mips64.go ├── ztypes_linux_mips64le.go ├── ztypes_linux_ppc64.go ├── ztypes_linux_ppc64le.go ├── ztypes_netbsd_386.go ├── ztypes_netbsd_amd64.go ├── ztypes_netbsd_arm.go ├── ztypes_openbsd_386.go ├── ztypes_openbsd_amd64.go └── ztypes_solaris_amd64.go /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.go] 12 | indent_style = tab 13 | 14 | [Makefile] 15 | indent_style = tab 16 | 17 | [*.md] 18 | trim_trailing_whitespace = false 19 | 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by http://gitignore.io 2 | bin/ 3 | 4 | ### OSX ### 5 | .DS_Store 6 | .AppleDouble 7 | .LSOverride 8 | Icon 9 | 10 | 11 | # Thumbnails 12 | ._* 13 | 14 | # Files that might appear on external disk 15 | .Spotlight-V100 16 | .Trashes 17 | 18 | ### Windows ### 19 | # Windows image file caches 20 | Thumbs.db 21 | ehthumbs.db 22 | 23 | ### Go ### 24 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 25 | #*.o 26 | #*.a 27 | #*.so 28 | 29 | # Folders 30 | #_obj 31 | #_test 32 | -------------------------------------------------------------------------------- /Godeps/Godeps.json: -------------------------------------------------------------------------------- 1 | { 2 | "ImportPath": "github.com/abema/kubetool", 3 | "GoVersion": "go1.6", 4 | "GodepVersion": "v60", 5 | "Packages": [ 6 | "./..." 7 | ], 8 | "Deps": [ 9 | { 10 | "ImportPath": "github.com/alecthomas/kingpin", 11 | "Comment": "v2.1.11-13-gb3e2dde", 12 | "Rev": "b3e2dde5034607a4446a4d5025baf43378e03203" 13 | }, 14 | { 15 | "ImportPath": "github.com/alecthomas/template", 16 | "Rev": "14fd436dd20c3cc65242a9f396b61bfc8a3926fc" 17 | }, 18 | { 19 | "ImportPath": "github.com/alecthomas/template/parse", 20 | "Rev": "14fd436dd20c3cc65242a9f396b61bfc8a3926fc" 21 | }, 22 | { 23 | "ImportPath": "github.com/alecthomas/units", 24 | "Rev": "2efee857e7cfd4f3d0138cc3cbb1b4966962b93a" 25 | }, 26 | { 27 | "ImportPath": "github.com/buger/goterm", 28 | "Rev": "45c1d39fe6b92d222144a46a24b526a452082f0f" 29 | }, 30 | { 31 | "ImportPath": "github.com/davecgh/go-spew/spew", 32 | "Rev": "5215b55f46b2b919f50a1df0eaa5886afe4e3b3d" 33 | }, 34 | { 35 | "ImportPath": "github.com/fatih/color", 36 | "Comment": "v0.1-17-g533cd7f", 37 | "Rev": "533cd7fd8a85905f67a1753afb4deddc85ea174f" 38 | }, 39 | { 40 | "ImportPath": "github.com/google/gofuzz", 41 | "Rev": "e4af62d086c303f2bed467b227fc0a034b218916" 42 | }, 43 | { 44 | "ImportPath": "github.com/mattn/go-colorable", 45 | "Rev": "3dac7b4f76f6e17fb39b768b89e3783d16e237fe" 46 | }, 47 | { 48 | "ImportPath": "github.com/mattn/go-isatty", 49 | "Rev": "56b76bdf51f7708750eac80fa38b952bb9f32639" 50 | }, 51 | { 52 | "ImportPath": "github.com/pmezard/go-difflib/difflib", 53 | "Rev": "792786c7400a136282c1664665ae0a8db921c6c2" 54 | }, 55 | { 56 | "ImportPath": "github.com/stretchr/testify/assert", 57 | "Comment": "v1.1.3-6-g6fe211e", 58 | "Rev": "6fe211e493929a8aac0469b93f28b1d0688a9a3a" 59 | }, 60 | { 61 | "ImportPath": "github.com/stretchr/testify/require", 62 | "Comment": "v1.1.3-6-g6fe211e", 63 | "Rev": "6fe211e493929a8aac0469b93f28b1d0688a9a3a" 64 | }, 65 | { 66 | "ImportPath": "golang.org/x/sys/unix", 67 | "Rev": "320cb01ddbbf0473674c2585f9b6e245721de355" 68 | } 69 | ] 70 | } 71 | -------------------------------------------------------------------------------- /Godeps/Readme: -------------------------------------------------------------------------------- 1 | This directory tree is generated automatically by godep. 2 | 3 | Please do not edit. 4 | 5 | See https://github.com/tools/godep for more information. 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright (c) 2016 AbemaTV 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Original https://github.com/aktau/github-release/blob/master/Makefile 2 | 3 | LAST_TAG := $(shell git describe --abbrev=0 --tags) 4 | 5 | EXECUTABLE := kubetool 6 | 7 | UPLOAD_CMD = github-release upload -u abema -r $(EXECUTABLE) -t $(LAST_TAG) -n $(subst /,-,$(FILE)) -f bin/$(FILE) 8 | 9 | UNIX_EXECUTABLES := \ 10 | darwin/amd64/$(EXECUTABLE) \ 11 | freebsd/amd64/$(EXECUTABLE) \ 12 | linux/amd64/$(EXECUTABLE) 13 | WIN_EXECUTABLES := \ 14 | windows/amd64/$(EXECUTABLE).exe 15 | 16 | COMPRESSED_EXECUTABLES=$(UNIX_EXECUTABLES:%=%.tar.gz) $(WIN_EXECUTABLES:%.exe=%.zip) 17 | COMPRESSED_EXECUTABLE_TARGETS=$(COMPRESSED_EXECUTABLES:%=bin/%) 18 | 19 | prepare: 20 | go get github.com/aktau/github-release 21 | 22 | all: $(EXECUTABLE) 23 | 24 | # the executable used to perform the upload, dogfooding and all... 25 | bin/tmp/$(EXECUTABLE): 26 | go build -o "$@" 27 | 28 | # arm 29 | bin/linux/arm/5/$(EXECUTABLE): 30 | GOARM=5 GOARCH=arm GOOS=linux go build -o "$@" 31 | bin/linux/arm/7/$(EXECUTABLE): 32 | GOARM=7 GOARCH=arm GOOS=linux go build -o "$@" 33 | 34 | # 386 35 | bin/darwin/386/$(EXECUTABLE): 36 | GOARCH=386 GOOS=darwin go build -o "$@" 37 | bin/linux/386/$(EXECUTABLE): 38 | GOARCH=386 GOOS=linux go build -o "$@" 39 | bin/windows/386/$(EXECUTABLE): 40 | GOARCH=386 GOOS=windows go build -o "$@" 41 | 42 | # amd64 43 | bin/freebsd/amd64/$(EXECUTABLE): 44 | GOARCH=amd64 GOOS=freebsd go build -o "$@" 45 | bin/darwin/amd64/$(EXECUTABLE): 46 | GOARCH=amd64 GOOS=darwin go build -o "$@" 47 | bin/linux/amd64/$(EXECUTABLE): 48 | GOARCH=amd64 GOOS=linux go build -o "$@" 49 | bin/windows/amd64/$(EXECUTABLE).exe: 50 | GOARCH=amd64 GOOS=windows go build -o "$@" 51 | 52 | %.tar.gz: % 53 | tar -zcvf "$<.tar.gz" "$<" 54 | %.zip: %.exe 55 | zip "$@" "$<" 56 | 57 | # git tag -a v$(RELEASE) -m 'release $(RELEASE)' 58 | release: bin/tmp/$(EXECUTABLE) $(COMPRESSED_EXECUTABLE_TARGETS) 59 | git push && git push --tags 60 | github-release release -u abema -r $(EXECUTABLE) \ 61 | -t $(LAST_TAG) -n $(LAST_TAG) || true 62 | $(foreach FILE,$(COMPRESSED_EXECUTABLES),$(UPLOAD_CMD);) 63 | 64 | $(EXECUTABLE): 65 | go build -o "$@" 66 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # kubetool 2 | 3 | [![Github Releases](https://img.shields.io/github/downloads/abema/kubetool/total.svg?maxAge=3600)](https://github.com/abema/kubetool/releases) 4 | [![Go Report Card](https://goreportcard.com/badge/github.com/abema/kubetool)](https://goreportcard.com/report/github.com/abema/kubetool) 5 | [![GoDoc](https://godoc.org/github.com/abema/kubetool?status.svg)](https://godoc.org/github.com/abema/kubetool) 6 | [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/abema/kubetool/master/LICENSE) 7 | 8 | kubetool is the tool that supports utility tasks which kubectl doesn't have. 9 | 10 | ## Install 11 | 12 | You have to install `kubectl` on your machine since kubetool uses kubectl command to execute tasks. 13 | 14 | ``` 15 | go get github.com/abema/kubetool 16 | ``` 17 | 18 | ## Features 19 | 20 | `kubetool help` to see all commands. 21 | 22 | ### List replication controllers 23 | 24 | ``` 25 | kubetool rc 26 | ``` 27 | 28 | Output example 29 | ``` 30 | NAME REPLICAS IMAGE VERSION 31 | nginx 2/2 abema/nginx 1.9.1 32 | mysql 2/2 abema/mysql latest 33 | ``` 34 | 35 | ### List pods 36 | 37 | ``` 38 | kubetool pods 39 | ``` 40 | 41 | Output example 42 | ``` 43 | NAME STATUS R POD IP NODE IP IMAGE VERSION 44 | nginx-6k8hq Running 0 10.8.0.4 10.78.0.2 abema/nginx 1.9.1 45 | nginx-s3vj6 Running 0 10.8.1.3 10.78.0.5 abema/nginx 1.9.1 46 | mysql-zm3iu Running 0 10.8.2.7 10.78.0.9 abema/mysql latest 47 | mysql-gdmvb Running 0 10.8.1.4 10.78.0.5 abema/mysql latest 48 | ``` 49 | 50 | 51 | ### Reload pods 52 | 53 | Reload all pods in RC. This is done by destroying all pods one by one. 54 | 55 | ``` 56 | kubetool reload nginx 57 | ``` 58 | 59 | Just reload 1 pod. This is useful when testing new image before reloading all pods. 60 | 61 | ``` 62 | kubetool reload nginx --1 63 | ``` 64 | 65 | ### Update image version of RC 66 | 67 | Patch image version of RC container definition. 68 | ex) `image: nginx:1.9.1` -> `image: nginx:1.9.2` 69 | 70 | ``` 71 | kubetool update nginx 1.9.2 72 | ``` 73 | 74 | with reload 75 | ``` 76 | kubetool update nginx 1.9.2 --reload 77 | ``` 78 | 79 | with reload only 1 pod 80 | 81 | ``` 82 | kubetool update nginx 1.9.2 --reload --1 83 | ``` 84 | 85 | You can also select/input version in console, 86 | 87 | ``` 88 | kubetool update 89 | ``` 90 | 91 | ### Fix version 92 | 93 | Fix container images which has different from RC they depends. This commands is 94 | similar to reload, but only destroy old pods. 95 | 96 | ``` 97 | kubetool fix-version nginx 98 | ``` 99 | 100 | 101 | -------------------------------------------------------------------------------- /cmd.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/abema/kubetool/kube" 8 | "github.com/alecthomas/kingpin" 9 | "github.com/fatih/color" 10 | ) 11 | 12 | var ( 13 | red = color.New(color.FgRed).SprintfFunc() 14 | 15 | app = kingpin.New("kubetool", "kubernetes bulk task executor.") 16 | verbose = app.Flag("verbose", "Enable verbose log.").Short('v').Bool() 17 | namespace = app.Flag("namespace", "Target namespace. default is all namespaces").String() 18 | yes = app.Flag("yes", "Skip confirmation.").Short('y').Bool() 19 | force = app.Flag("force", "Force reload pods. Ignores pod status while reloading.").Short('f').Bool() 20 | interval = app.Flag("interval", "Reloading interval on restarting each pod.").Default("0").Int() 21 | minStable = app.Flag("min-stable", "Minimum value of available pod percentage to detect RC is stable or not. (0.0-1.0). Defalt is 0.8").Default("0.8").Float64() 22 | 23 | // command info 24 | info = app.Command("info", "Print cluster & version info about cluster.").Alias("i") 25 | 26 | // command rc 27 | rc = app.Command("rc", "Print all rc.") 28 | 29 | // command pod 30 | pod = app.Command("pod", "Print all pods").Alias("pods").Alias("po") 31 | podRC = pod.Flag("rc", "rc name for pod target").String() 32 | 33 | // command reload 34 | reload = app.Command("reload", "Reload all pods in rc.") 35 | reloadName = reload.Arg("rc-name", "Name of target RC.").Required().String() 36 | reloadOne = reload.Flag("1", "Reload only 1 pod").Bool() 37 | 38 | // command set version 39 | update = app.Command("update", "Update image version of rc") 40 | updateName = update.Arg("rc-name", "Name of target RC.").Required().String() 41 | updateVersion = update.Arg("version", "Version tag of image.").String() 42 | updateReload = update.Flag("reload", "Reload pods after update.").Bool() 43 | updateReloadOne = update.Flag("1", "Reload only 1 pod after update.").Short('1').Bool() 44 | updateContainer = update.Flag("container", "Target container name. Default is first container in defs.").Short('c').String() 45 | 46 | fixVersion = app.Command("fix-version", "Fix all pods to destroy all that has different version of RC ones.") 47 | fixVersionName = fixVersion.Arg("rc-name", "Name of target RC.").Required().String() 48 | ) 49 | 50 | func init() { 51 | app.Version("0.1.0") 52 | } 53 | 54 | func main() { 55 | 56 | cmd := kingpin.MustParse(app.Parse(os.Args[1:])) 57 | 58 | ktool := kube.Tool{} 59 | ktool.SetYes(*yes) 60 | ktool.SetForce(*force) 61 | ktool.SetInterval(*interval) 62 | 63 | if namespace != nil { 64 | ktool.SetNamespace(*namespace) 65 | } 66 | 67 | if *minStable < 0 || *minStable > 1 { 68 | fmt.Fprintln(os.Stderr, "minimum stable rate must be in range of 0.0-1.0") 69 | os.Exit(1) 70 | } 71 | 72 | var err error 73 | 74 | switch cmd { 75 | case info.FullCommand(): 76 | err = ktool.PrintInfo() 77 | case rc.FullCommand(): 78 | err = ktool.PrintRCList() 79 | case pod.FullCommand(): 80 | rcname := "" 81 | if podRC != nil { 82 | rcname = *podRC 83 | } 84 | err = ktool.PrintPodList(rcname) 85 | case reload.FullCommand(): 86 | err = ktool.Reload(*reloadName, *reloadOne) 87 | case update.FullCommand(): 88 | container := "" 89 | if updateContainer != nil { 90 | container = *updateContainer 91 | } 92 | err = ktool.Update(*updateName, container, *updateVersion) 93 | if *updateReload && err == nil { 94 | err = ktool.Reload(*updateName, *updateReloadOne) 95 | } 96 | case fixVersion.FullCommand(): 97 | err = ktool.FixVersion(*fixVersionName) 98 | } 99 | if err != nil { 100 | fmt.Println(red(err.Error())) 101 | os.Exit(1) 102 | } 103 | 104 | } 105 | -------------------------------------------------------------------------------- /kube/kubectl.go: -------------------------------------------------------------------------------- 1 | package kube 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "errors" 7 | "fmt" 8 | "os" 9 | "os/exec" 10 | "regexp" 11 | "strings" 12 | ) 13 | 14 | // Kubectl executes kubectl as command. 15 | type Kubectl struct { 16 | Debug bool 17 | Namespace string 18 | } 19 | 20 | // Exec kubectl commands with arguments. 21 | func (kc *Kubectl) Exec(args ...string) (b []byte, err error) { 22 | 23 | if kc.Namespace == "all" { 24 | args = append(args, "--all-namespace") 25 | } else if kc.Namespace != "" { 26 | args = append(args, "--namespace="+kc.Namespace) 27 | } 28 | 29 | stdout := bytes.Buffer{} 30 | cmd := exec.Command("kubectl", args...) 31 | if kc.Debug { 32 | log("exec kubectl", args) 33 | } 34 | cmd.Stdout = &stdout 35 | cmd.Stderr = os.Stderr 36 | err = cmd.Run() 37 | if err != nil { 38 | return 39 | } 40 | return stdout.Bytes(), nil 41 | 42 | } 43 | 44 | func trim(text string) string { 45 | return strings.Trim(text, " \n") 46 | } 47 | 48 | // CurrentContext returns current context. 49 | func (kc *Kubectl) CurrentContext() (ctx string, err error) { 50 | b, err := kc.Exec("config", "current-context") 51 | if err != nil { 52 | return 53 | } 54 | return trim(string(b)), nil 55 | } 56 | 57 | // Version returns kubernetes client/server version. 58 | func (kc *Kubectl) Version() (client string, server string, err error) { 59 | b, err := kc.Exec("version") 60 | if err != nil { 61 | return 62 | } 63 | verstr := string(b) 64 | cliptrn := regexp.MustCompile(`(?m)Client Version:.*GitVersion:"(.+?)"`) 65 | srvptrn := regexp.MustCompile(`(?m)Server Version:.*GitVersion:"(.+?)"`) 66 | 67 | cliv := cliptrn.FindStringSubmatch(verstr) 68 | srvv := srvptrn.FindStringSubmatch(verstr) 69 | 70 | if len(cliv) < 2 { 71 | err = fmt.Errorf("client version not found") 72 | return 73 | } 74 | if len(srvv) < 2 { 75 | err = fmt.Errorf("server version not found") 76 | return 77 | } 78 | return cliv[1], srvv[1], nil 79 | } 80 | 81 | type rcList struct { 82 | Items []ReplicationController 83 | } 84 | 85 | // RCList return replication controllers. 86 | func (kc *Kubectl) RCList() (rcs []ReplicationController, err error) { 87 | b, err := kc.Exec("get", "rc", "--output=json") 88 | if err != nil { 89 | return 90 | } 91 | list := rcList{} 92 | if err = json.Unmarshal(b, &list); err != nil { 93 | err = errors.New(trim(string(b))) 94 | } 95 | return list.Items, err 96 | } 97 | 98 | // RC return single replication controller. 99 | func (kc Kubectl) RC(name string) (rc ReplicationController, err error) { 100 | b, err := kc.Exec("get", "rc", name, "--output=json") 101 | if err != nil { 102 | return 103 | } 104 | if err = json.Unmarshal(b, &rc); err != nil { 105 | err = errors.New(trim(string(b))) 106 | } 107 | return 108 | } 109 | 110 | // PatchRC updates RC fields. 111 | func (kc Kubectl) PatchRC(rc string, patch string) (err error) { 112 | _, err = kc.Exec("patch", "rc", rc, "-p", patch) 113 | return 114 | } 115 | 116 | type podList struct { 117 | Items []Pod 118 | } 119 | 120 | // PodList return pods. 121 | func (kc *Kubectl) PodList(selector Selector) (pods []Pod, err error) { 122 | args := []string{"get", "pod", "--output=json"} 123 | if selector != nil && len(selector) > 0 { 124 | args = append(args, "--selector="+selector.Format()) 125 | } 126 | b, err := kc.Exec(args...) 127 | if err != nil { 128 | return 129 | } 130 | list := podList{} 131 | json.Unmarshal(b, &list) 132 | return list.Items, nil 133 | } 134 | 135 | // Pod return single pod. 136 | func (kc *Kubectl) Pod(name string) (pod Pod, err error) { 137 | b, err := kc.Exec("get", "pod", name, "--output=json") 138 | if err != nil { 139 | return 140 | } 141 | if err = json.Unmarshal(b, &pod); err != nil { 142 | err = errors.New(trim(string(b))) 143 | } 144 | return 145 | } 146 | 147 | // DeletePod in cluster 148 | func (kc *Kubectl) DeletePod(name string) (err error) { 149 | _, err = kc.Exec("delete", "pod", name) 150 | return 151 | } 152 | 153 | // Selector map. 154 | type Selector map[string]string 155 | 156 | // Format selector as k=v,k=v style. 157 | func (s Selector) Format() string { 158 | list := []string{} 159 | for k, v := range s { 160 | list = append(list, k+"="+v) 161 | } 162 | return strings.Join(list, ",") 163 | } 164 | -------------------------------------------------------------------------------- /kube/kubectl_test.go: -------------------------------------------------------------------------------- 1 | package kube 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "os/exec" 7 | "testing" 8 | "time" 9 | 10 | "github.com/stretchr/testify/require" 11 | ) 12 | 13 | func TestMain(m *testing.M) { 14 | os.Exit(testMain(m)) 15 | } 16 | 17 | func testMain(m *testing.M) int { 18 | // create test rc 19 | out, err := exec.Command("kubectl", "create", "-f", "test_rc.yml").CombinedOutput() 20 | if err != nil { 21 | fmt.Println(string(out)) 22 | return 1 23 | } 24 | defer func() { 25 | // drop test rc 26 | out, err := exec.Command("kubectl", "delete", "-f", "test_rc.yml").CombinedOutput() 27 | if err != nil { 28 | fmt.Println(string(out)) 29 | } 30 | }() 31 | // drop test rc 32 | return m.Run() 33 | } 34 | 35 | func TestVersion(t *testing.T) { 36 | kc := Kubectl{} 37 | s, c, err := kc.Version() 38 | require.NoError(t, err) 39 | require.NotEmpty(t, s) 40 | require.NotEmpty(t, c) 41 | } 42 | 43 | func TestCurrentContext(t *testing.T) { 44 | kc := Kubectl{} 45 | c, err := kc.CurrentContext() 46 | require.NoError(t, err) 47 | require.NotEmpty(t, c) 48 | } 49 | 50 | func TestPodList(t *testing.T) { 51 | kc := Kubectl{} 52 | c, err := kc.PodList(nil) 53 | require.NoError(t, err) 54 | require.NotEmpty(t, c) 55 | } 56 | 57 | func TestRCList(t *testing.T) { 58 | kc := Kubectl{} 59 | c, err := kc.RCList() 60 | require.NoError(t, err) 61 | require.NotEmpty(t, c) 62 | } 63 | 64 | func TestPod(t *testing.T) { 65 | kc := Kubectl{} 66 | pods, err := kc.PodList(nil) 67 | require.NoError(t, err) 68 | pod, err := kc.Pod(pods[0].Name) 69 | require.NoError(t, err) 70 | require.Equal(t, pod.Name, pods[0].Name) 71 | } 72 | 73 | func TestRC(t *testing.T) { 74 | kc := Kubectl{} 75 | rcs, err := kc.RCList() 76 | require.NoError(t, err) 77 | rc, err := kc.RC(rcs[0].Name) 78 | require.NoError(t, err) 79 | require.Equal(t, rc.Name, rcs[0].Name) 80 | } 81 | 82 | func TestDeletePod(t *testing.T) { 83 | kc := Kubectl{} 84 | // wait until pods ready 85 | time.Sleep(5 * time.Second) 86 | 87 | pods, err := kc.PodList(Selector{"name": "kubetool-test"}) 88 | require.NoError(t, err) 89 | require.Equal(t, 2, len(pods)) 90 | 91 | require.NoError(t, kc.DeletePod(pods[0].Name)) 92 | 93 | /* TODO better deleting timing check 94 | // get status 95 | p, err := kc.Pod(pods[0].Name) 96 | require.NoError(t, err) 97 | // phase will be pending 98 | fmt.Println(p.Status.ContainerStatuses[0].State) 99 | assert.NotNil(t, p.Status.ContainerStatuses[0].State.Running) 100 | assert.NotNil(t, p.Status.ContainerStatuses[0].State.Terminated) 101 | assert.NotNil(t, p.Status.ContainerStatuses[0].State.Waiting) 102 | */ 103 | 104 | } 105 | 106 | func TestPatch(t *testing.T) { 107 | kc := Kubectl{} 108 | rc, err := kc.RC("kubetool-test") 109 | require.NoError(t, err) 110 | 111 | err = kc.PatchRC(rc.Name, `{"metadata":{"labels":{"test":"kubetool"}}}`) 112 | require.NoError(t, err) 113 | 114 | rc, err = kc.RC("kubetool-test") 115 | require.NoError(t, err) 116 | require.Equal(t, "kubetool", rc.ObjectMeta.Labels["test"]) 117 | } 118 | -------------------------------------------------------------------------------- /kube/kubetool_test.go: -------------------------------------------------------------------------------- 1 | package kube 2 | 3 | import ( 4 | "bytes" 5 | "os" 6 | "testing" 7 | 8 | "github.com/stretchr/testify/assert" 9 | "github.com/stretchr/testify/require" 10 | ) 11 | 12 | func TestSetNamespace(t *testing.T) { 13 | kt := Tool{} 14 | require.Equal(t, "", kt.kubectl.Namespace) 15 | kt.SetNamespace("YO") 16 | require.Equal(t, "YO", kt.kubectl.Namespace) 17 | } 18 | 19 | func TestSetForce(t *testing.T) { 20 | kt := Tool{} 21 | assert.False(t, kt.force) 22 | kt.SetForce(true) 23 | assert.True(t, kt.force) 24 | kt.SetForce(false) 25 | assert.False(t, kt.force) 26 | } 27 | 28 | func TestSetYes(t *testing.T) { 29 | kt := Tool{} 30 | assert.False(t, kt.yes) 31 | kt.SetYes(true) 32 | assert.True(t, kt.yes) 33 | kt.SetYes(false) 34 | assert.False(t, kt.yes) 35 | } 36 | 37 | func TestSetInterval(t *testing.T) { 38 | kt := Tool{} 39 | assert.Equal(t, 0, kt.interval) 40 | kt.SetInterval(10) 41 | assert.Equal(t, 10, kt.interval) 42 | } 43 | 44 | func TestSetMinimumStable(t *testing.T) { 45 | kt := Tool{} 46 | assert.Equal(t, float64(0), kt.minStable) 47 | kt.SetMinimumStable(0.8) 48 | assert.Equal(t, float64(0.8), kt.minStable) 49 | } 50 | 51 | func TestPrintInfo(t *testing.T) { 52 | b := bytes.Buffer{} 53 | out = &b 54 | kt := Tool{} 55 | require.NoError(t, kt.PrintInfo()) 56 | text := b.String() 57 | require.NotEmpty(t, text) 58 | } 59 | 60 | func TestPrintContext(t *testing.T) { 61 | b := bytes.Buffer{} 62 | out = &b 63 | kt := Tool{} 64 | require.NoError(t, kt.PrintContext()) 65 | text := b.String() 66 | require.NotEmpty(t, text) 67 | } 68 | 69 | func TestPrintPodList(t *testing.T) { 70 | b := bytes.Buffer{} 71 | out = &b 72 | kt := Tool{} 73 | require.NoError(t, kt.PrintPodList("kubetool-test")) 74 | text := b.String() 75 | require.NotEmpty(t, text) 76 | require.Contains(t, text, "kubetool-test") 77 | } 78 | 79 | func TestPrintRCList(t *testing.T) { 80 | b := bytes.Buffer{} 81 | out = &b 82 | kt := Tool{} 83 | require.NoError(t, kt.PrintRCList()) 84 | text := b.String() 85 | require.NotEmpty(t, text) 86 | require.Contains(t, text, "kubetool-test") 87 | } 88 | 89 | func TestReload(t *testing.T) { 90 | out = os.Stdout 91 | kt := Tool{} 92 | kt.SetYes(true) 93 | 94 | // wait rc available 95 | rc, err := kt.kubectl.RC("kubetool-test") 96 | require.NoError(t, err) 97 | require.NoError(t, kt.waitRCAvailable(rc.Name, []string{})) 98 | 99 | // get pod list of RC 100 | olds, err := kt.kubectl.PodList(Selector{"name": "kubetool-test"}) 101 | require.NoError(t, err) 102 | assert.Equal(t, 2, len(olds)) 103 | 104 | // reload all 105 | kt.Reload("kubetool-test", false) 106 | 107 | // get new pod list of RC 108 | news, err := kt.kubectl.PodList(Selector{"name": "kubetool-test"}) 109 | require.NoError(t, err) 110 | require.Equal(t, 2, len(news)) 111 | for i := range news { 112 | assert.Equal(t, PodRunning, news[i].Status.Phase) 113 | assert.True(t, news[i].Status.ContainerStatuses[0].Ready) 114 | // must be re-created 115 | assert.NotEqual(t, olds[i].Name, news[i].Name) 116 | } 117 | } 118 | 119 | func TestUpdate(t *testing.T) { 120 | 121 | kt := Tool{} 122 | kt.SetYes(true) 123 | require.NoError(t, kt.Update("kubetool-test", "", "1.9.12")) 124 | 125 | rc, err := kt.kubectl.RC("kubetool-test") 126 | require.NoError(t, err) 127 | assert.Equal(t, "nginx:1.9.12", rc.Spec.Template.Spec.Containers[0].Image) 128 | 129 | } 130 | -------------------------------------------------------------------------------- /kube/test_rc.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ReplicationController 3 | metadata: 4 | labels: 5 | name: kubetool-test 6 | name: kubetool-test 7 | namespace: default 8 | spec: 9 | replicas: 2 10 | selector: 11 | name: kubetool-test 12 | template: 13 | metadata: 14 | labels: 15 | name: kubetool-test 16 | spec: 17 | containers: 18 | - image: nginx 19 | name: kubetool-test 20 | 21 | -------------------------------------------------------------------------------- /kube/types_intstr.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2014 The Kubernetes Authors All rights reserved. 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package kube 15 | 16 | import ( 17 | "encoding/json" 18 | "fmt" 19 | "math" 20 | "strconv" 21 | "strings" 22 | 23 | "github.com/google/gofuzz" 24 | ) 25 | 26 | // IntOrString is a type that can hold an int32 or a string. When used in 27 | // JSON or YAML marshalling and unmarshalling, it produces or consumes the 28 | // inner type. This allows you to have, for example, a JSON field that can 29 | // accept a name or number. 30 | // TODO: Rename to Int32OrString 31 | // 32 | // +protobuf=true 33 | // +protobuf.options.(gogoproto.goproto_stringer)=false 34 | type IntOrString struct { 35 | Type Type 36 | IntVal int32 37 | StrVal string 38 | } 39 | 40 | // Type represents the stored type of IntOrString. 41 | type Type int 42 | 43 | const ( 44 | Int Type = iota // The IntOrString holds an int. 45 | String // The IntOrString holds a string. 46 | ) 47 | 48 | // FromInt creates an IntOrString object with an int32 value. It is 49 | // your responsibility not to call this method with a value greater 50 | // than int32. 51 | // TODO: convert to (val int32) 52 | func FromInt(val int) IntOrString { 53 | return IntOrString{Type: Int, IntVal: int32(val)} 54 | } 55 | 56 | // FromString creates an IntOrString object with a string value. 57 | func FromString(val string) IntOrString { 58 | return IntOrString{Type: String, StrVal: val} 59 | } 60 | 61 | // UnmarshalJSON implements the json.Unmarshaller interface. 62 | func (intstr *IntOrString) UnmarshalJSON(value []byte) error { 63 | if value[0] == '"' { 64 | intstr.Type = String 65 | return json.Unmarshal(value, &intstr.StrVal) 66 | } 67 | intstr.Type = Int 68 | return json.Unmarshal(value, &intstr.IntVal) 69 | } 70 | 71 | // String returns the string value, or the Itoa of the int value. 72 | func (intstr *IntOrString) String() string { 73 | if intstr.Type == String { 74 | return intstr.StrVal 75 | } 76 | return strconv.Itoa(intstr.IntValue()) 77 | } 78 | 79 | // IntValue returns the IntVal if type Int, or if 80 | // it is a String, will attempt a conversion to int. 81 | func (intstr *IntOrString) IntValue() int { 82 | if intstr.Type == String { 83 | i, _ := strconv.Atoi(intstr.StrVal) 84 | return i 85 | } 86 | return int(intstr.IntVal) 87 | } 88 | 89 | // MarshalJSON implements the json.Marshaller interface. 90 | func (intstr IntOrString) MarshalJSON() ([]byte, error) { 91 | switch intstr.Type { 92 | case Int: 93 | return json.Marshal(intstr.IntVal) 94 | case String: 95 | return json.Marshal(intstr.StrVal) 96 | default: 97 | return []byte{}, fmt.Errorf("impossible IntOrString.Type") 98 | } 99 | } 100 | 101 | func (intstr *IntOrString) Fuzz(c fuzz.Continue) { 102 | if intstr == nil { 103 | return 104 | } 105 | if c.RandBool() { 106 | intstr.Type = Int 107 | c.Fuzz(&intstr.IntVal) 108 | intstr.StrVal = "" 109 | } else { 110 | intstr.Type = String 111 | intstr.IntVal = 0 112 | c.Fuzz(&intstr.StrVal) 113 | } 114 | } 115 | 116 | func GetValueFromIntOrPercent(intOrPercent *IntOrString, total int, roundUp bool) (int, error) { 117 | value, isPercent, err := getIntOrPercentValue(intOrPercent) 118 | if err != nil { 119 | return 0, fmt.Errorf("invalid value for IntOrString: %v", err) 120 | } 121 | if isPercent { 122 | if roundUp { 123 | value = int(math.Ceil(float64(value) * (float64(total)) / 100)) 124 | } else { 125 | value = int(math.Floor(float64(value) * (float64(total)) / 100)) 126 | } 127 | } 128 | return value, nil 129 | } 130 | 131 | func getIntOrPercentValue(intOrStr *IntOrString) (int, bool, error) { 132 | switch intOrStr.Type { 133 | case Int: 134 | return intOrStr.IntValue(), false, nil 135 | case String: 136 | s := strings.Replace(intOrStr.StrVal, "%", "", -1) 137 | v, err := strconv.Atoi(s) 138 | if err != nil { 139 | return 0, false, fmt.Errorf("invalid value %q: %v", intOrStr.StrVal, err) 140 | } 141 | return int(v), true, nil 142 | } 143 | return 0, false, fmt.Errorf("invalid value: neither int nor percentage") 144 | } 145 | -------------------------------------------------------------------------------- /kube/types_time.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2014 The Kubernetes Authors All rights reserved. 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package kube 15 | 16 | import ( 17 | "encoding/json" 18 | "time" 19 | 20 | "github.com/google/gofuzz" 21 | ) 22 | 23 | // Time is a wrapper around time.Time which supports correct 24 | // marshaling to YAML and JSON. Wrappers are provided for many 25 | // of the factory methods that the time package offers. 26 | // 27 | // +protobuf.options.marshal=false 28 | type Time struct { 29 | time.Time `protobuf:"Timestamp,1,req,name=time"` 30 | } 31 | 32 | // NewTime returns a wrapped instance of the provided time 33 | func NewTime(time time.Time) Time { 34 | return Time{time} 35 | } 36 | 37 | // Date returns the Time corresponding to the supplied parameters 38 | // by wrapping time.Date. 39 | func Date(year int, month time.Month, day, hour, min, sec, nsec int, loc *time.Location) Time { 40 | return Time{time.Date(year, month, day, hour, min, sec, nsec, loc)} 41 | } 42 | 43 | // Now returns the current local time. 44 | func Now() Time { 45 | return Time{time.Now()} 46 | } 47 | 48 | // IsZero returns true if the value is nil or time is zero. 49 | func (t *Time) IsZero() bool { 50 | if t == nil { 51 | return true 52 | } 53 | return t.Time.IsZero() 54 | } 55 | 56 | // Before reports whether the time instant t is before u. 57 | func (t Time) Before(u Time) bool { 58 | return t.Time.Before(u.Time) 59 | } 60 | 61 | // Equal reports whether the time instant t is equal to u. 62 | func (t Time) Equal(u Time) bool { 63 | return t.Time.Equal(u.Time) 64 | } 65 | 66 | // Unix returns the local time corresponding to the given Unix time 67 | // by wrapping time.Unix. 68 | func Unix(sec int64, nsec int64) Time { 69 | return Time{time.Unix(sec, nsec)} 70 | } 71 | 72 | // Rfc3339Copy returns a copy of the Time at second-level precision. 73 | func (t Time) Rfc3339Copy() Time { 74 | copied, _ := time.Parse(time.RFC3339, t.Format(time.RFC3339)) 75 | return Time{copied} 76 | } 77 | 78 | // UnmarshalJSON implements the json.Unmarshaller interface. 79 | func (t *Time) UnmarshalJSON(b []byte) error { 80 | if len(b) == 4 && string(b) == "null" { 81 | t.Time = time.Time{} 82 | return nil 83 | } 84 | 85 | var str string 86 | json.Unmarshal(b, &str) 87 | 88 | pt, err := time.Parse(time.RFC3339, str) 89 | if err != nil { 90 | return err 91 | } 92 | 93 | t.Time = pt.Local() 94 | return nil 95 | } 96 | 97 | // UnmarshalQueryParameter converts from a URL query parameter value to an object 98 | func (t *Time) UnmarshalQueryParameter(str string) error { 99 | if len(str) == 0 { 100 | t.Time = time.Time{} 101 | return nil 102 | } 103 | // Tolerate requests from older clients that used JSON serialization to build query params 104 | if len(str) == 4 && str == "null" { 105 | t.Time = time.Time{} 106 | return nil 107 | } 108 | 109 | pt, err := time.Parse(time.RFC3339, str) 110 | if err != nil { 111 | return err 112 | } 113 | 114 | t.Time = pt.Local() 115 | return nil 116 | } 117 | 118 | // MarshalJSON implements the json.Marshaler interface. 119 | func (t Time) MarshalJSON() ([]byte, error) { 120 | if t.IsZero() { 121 | // Encode unset/nil objects as JSON's "null". 122 | return []byte("null"), nil 123 | } 124 | 125 | return json.Marshal(t.UTC().Format(time.RFC3339)) 126 | } 127 | 128 | // MarshalQueryParameter converts to a URL query parameter value 129 | func (t Time) MarshalQueryParameter() (string, error) { 130 | if t.IsZero() { 131 | // Encode unset/nil objects as an empty string 132 | return "", nil 133 | } 134 | 135 | return t.UTC().Format(time.RFC3339), nil 136 | } 137 | 138 | // Fuzz satisfies fuzz.Interface. 139 | func (t *Time) Fuzz(c fuzz.Continue) { 140 | if t == nil { 141 | return 142 | } 143 | // Allow for about 1000 years of randomness. Leave off nanoseconds 144 | // because JSON doesn't represent them so they can't round-trip 145 | // properly. 146 | t.Time = time.Unix(c.Rand.Int63n(1000*365*24*60*60), 0) 147 | } 148 | 149 | var _ fuzz.Interface = &Time{} 150 | -------------------------------------------------------------------------------- /kube/types_unversioned.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 The Kubernetes Authors All rights reserved. 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | package kube 14 | 15 | // TypeMeta describes an individual object in an API response or request 16 | // with strings representing the type of the object and its API schema version. 17 | // Structures that are versioned or persisted should inline TypeMeta. 18 | type TypeMeta struct { 19 | // Kind is a string value representing the REST resource this object represents. 20 | // Servers may infer this from the endpoint the client submits requests to. 21 | // Cannot be updated. 22 | // In CamelCase. 23 | // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#types-kinds 24 | Kind string `json:"kind,omitempty"` 25 | 26 | // APIVersion defines the versioned schema of this representation of an object. 27 | // Servers should convert recognized schemas to the latest internal value, and 28 | // may reject unrecognized values. 29 | // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#resources 30 | APIVersion string `json:"apiVersion,omitempty"` 31 | } 32 | 33 | // ListMeta describes metadata that synthetic resources must have, including lists and 34 | // various status objects. A resource may have only one of {ObjectMeta, ListMeta}. 35 | type ListMeta struct { 36 | // SelfLink is a URL representing this object. 37 | // Populated by the system. 38 | // Read-only. 39 | SelfLink string `json:"selfLink,omitempty"` 40 | 41 | // String that identifies the server's internal version of this object that 42 | // can be used by clients to determine when objects have changed. 43 | // Value must be treated as opaque by clients and passed unmodified back to the server. 44 | // Populated by the system. 45 | // Read-only. 46 | // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#concurrency-control-and-consistency 47 | ResourceVersion string `json:"resourceVersion,omitempty"` 48 | } 49 | -------------------------------------------------------------------------------- /vendor/github.com/alecthomas/kingpin/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: go 3 | install: go get -t -v ./... 4 | go: 1.2 5 | -------------------------------------------------------------------------------- /vendor/github.com/alecthomas/kingpin/COPYING: -------------------------------------------------------------------------------- 1 | Copyright (C) 2014 Alec Thomas 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /vendor/github.com/alecthomas/kingpin/actions.go: -------------------------------------------------------------------------------- 1 | package kingpin 2 | 3 | // Action callback executed at various stages after all values are populated. 4 | // The application, commands, arguments and flags all have corresponding 5 | // actions. 6 | type Action func(*ParseContext) error 7 | 8 | type actionMixin struct { 9 | actions []Action 10 | preActions []Action 11 | } 12 | 13 | type actionApplier interface { 14 | applyActions(*ParseContext) error 15 | applyPreActions(*ParseContext) error 16 | } 17 | 18 | func (a *actionMixin) addAction(action Action) { 19 | a.actions = append(a.actions, action) 20 | } 21 | 22 | func (a *actionMixin) addPreAction(action Action) { 23 | a.preActions = append(a.preActions, action) 24 | } 25 | 26 | func (a *actionMixin) applyActions(context *ParseContext) error { 27 | for _, action := range a.actions { 28 | if err := action(context); err != nil { 29 | return err 30 | } 31 | } 32 | return nil 33 | } 34 | 35 | func (a *actionMixin) applyPreActions(context *ParseContext) error { 36 | for _, preAction := range a.preActions { 37 | if err := preAction(context); err != nil { 38 | return err 39 | } 40 | } 41 | return nil 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/alecthomas/kingpin/args.go: -------------------------------------------------------------------------------- 1 | package kingpin 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | type argGroup struct { 8 | args []*ArgClause 9 | } 10 | 11 | func newArgGroup() *argGroup { 12 | return &argGroup{} 13 | } 14 | 15 | func (a *argGroup) have() bool { 16 | return len(a.args) > 0 17 | } 18 | 19 | // GetArg gets an argument definition. 20 | // 21 | // This allows existing arguments to be modified after definition but before parsing. Useful for 22 | // modular applications. 23 | func (a *argGroup) GetArg(name string) *ArgClause { 24 | for _, arg := range a.args { 25 | if arg.name == name { 26 | return arg 27 | } 28 | } 29 | return nil 30 | } 31 | 32 | func (a *argGroup) Arg(name, help string) *ArgClause { 33 | arg := newArg(name, help) 34 | a.args = append(a.args, arg) 35 | return arg 36 | } 37 | 38 | func (a *argGroup) init() error { 39 | required := 0 40 | seen := map[string]struct{}{} 41 | previousArgMustBeLast := false 42 | for i, arg := range a.args { 43 | if previousArgMustBeLast { 44 | return fmt.Errorf("Args() can't be followed by another argument '%s'", arg.name) 45 | } 46 | if arg.consumesRemainder() { 47 | previousArgMustBeLast = true 48 | } 49 | if _, ok := seen[arg.name]; ok { 50 | return fmt.Errorf("duplicate argument '%s'", arg.name) 51 | } 52 | seen[arg.name] = struct{}{} 53 | if arg.required && required != i { 54 | return fmt.Errorf("required arguments found after non-required") 55 | } 56 | if arg.required { 57 | required++ 58 | } 59 | if err := arg.init(); err != nil { 60 | return err 61 | } 62 | } 63 | return nil 64 | } 65 | 66 | type ArgClause struct { 67 | actionMixin 68 | parserMixin 69 | completionsMixin 70 | envarMixin 71 | name string 72 | help string 73 | defaultValues []string 74 | required bool 75 | } 76 | 77 | func newArg(name, help string) *ArgClause { 78 | a := &ArgClause{ 79 | name: name, 80 | help: help, 81 | } 82 | return a 83 | } 84 | 85 | func (a *ArgClause) setDefault() error { 86 | if a.HasEnvarValue() { 87 | if v, ok := a.value.(remainderArg); !ok || !v.IsCumulative() { 88 | // Use the value as-is 89 | return a.value.Set(a.GetEnvarValue()) 90 | } else { 91 | for _, value := range a.GetSplitEnvarValue() { 92 | if err := a.value.Set(value); err != nil { 93 | return err 94 | } 95 | } 96 | return nil 97 | } 98 | } 99 | 100 | if len(a.defaultValues) > 0 { 101 | for _, defaultValue := range a.defaultValues { 102 | if err := a.value.Set(defaultValue); err != nil { 103 | return err 104 | } 105 | } 106 | return nil 107 | } 108 | 109 | return nil 110 | } 111 | 112 | func (a *ArgClause) needsValue() bool { 113 | haveDefault := len(a.defaultValues) > 0 114 | return a.required && !(haveDefault || a.HasEnvarValue()) 115 | } 116 | 117 | func (a *ArgClause) consumesRemainder() bool { 118 | if r, ok := a.value.(remainderArg); ok { 119 | return r.IsCumulative() 120 | } 121 | return false 122 | } 123 | 124 | // Required arguments must be input by the user. They can not have a Default() value provided. 125 | func (a *ArgClause) Required() *ArgClause { 126 | a.required = true 127 | return a 128 | } 129 | 130 | // Default values for this argument. They *must* be parseable by the value of the argument. 131 | func (a *ArgClause) Default(values ...string) *ArgClause { 132 | a.defaultValues = values 133 | return a 134 | } 135 | 136 | // Envar overrides the default value(s) for a flag from an environment variable, 137 | // if it is set. Several default values can be provided by using new lines to 138 | // separate them. 139 | func (a *ArgClause) Envar(name string) *ArgClause { 140 | a.envar = name 141 | a.noEnvar = false 142 | return a 143 | } 144 | 145 | // NoEnvar forces environment variable defaults to be disabled for this flag. 146 | // Most useful in conjunction with app.DefaultEnvars(). 147 | func (a *ArgClause) NoEnvar() *ArgClause { 148 | a.envar = "" 149 | a.noEnvar = true 150 | return a 151 | } 152 | 153 | func (a *ArgClause) Action(action Action) *ArgClause { 154 | a.addAction(action) 155 | return a 156 | } 157 | 158 | func (a *ArgClause) PreAction(action Action) *ArgClause { 159 | a.addPreAction(action) 160 | return a 161 | } 162 | 163 | // HintAction registers a HintAction (function) for the arg to provide completions 164 | func (a *ArgClause) HintAction(action HintAction) *ArgClause { 165 | a.addHintAction(action) 166 | return a 167 | } 168 | 169 | // HintOptions registers any number of options for the flag to provide completions 170 | func (a *ArgClause) HintOptions(options ...string) *ArgClause { 171 | a.addHintAction(func() []string { 172 | return options 173 | }) 174 | return a 175 | } 176 | 177 | func (a *ArgClause) init() error { 178 | if a.required && len(a.defaultValues) > 0 { 179 | return fmt.Errorf("required argument '%s' with unusable default value", a.name) 180 | } 181 | if a.value == nil { 182 | return fmt.Errorf("no parser defined for arg '%s'", a.name) 183 | } 184 | return nil 185 | } 186 | -------------------------------------------------------------------------------- /vendor/github.com/alecthomas/kingpin/completions.go: -------------------------------------------------------------------------------- 1 | package kingpin 2 | 3 | // HintAction is a function type who is expected to return a slice of possible 4 | // command line arguments. 5 | type HintAction func() []string 6 | type completionsMixin struct { 7 | hintActions []HintAction 8 | builtinHintActions []HintAction 9 | } 10 | 11 | func (a *completionsMixin) addHintAction(action HintAction) { 12 | a.hintActions = append(a.hintActions, action) 13 | } 14 | 15 | // Allow adding of HintActions which are added internally, ie, EnumVar 16 | func (a *completionsMixin) addHintActionBuiltin(action HintAction) { 17 | a.builtinHintActions = append(a.builtinHintActions, action) 18 | } 19 | 20 | func (a *completionsMixin) resolveCompletions() []string { 21 | var hints []string 22 | 23 | options := a.builtinHintActions 24 | if len(a.hintActions) > 0 { 25 | // User specified their own hintActions. Use those instead. 26 | options = a.hintActions 27 | } 28 | 29 | for _, hintAction := range options { 30 | hints = append(hints, hintAction()...) 31 | } 32 | return hints 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/alecthomas/kingpin/doc.go: -------------------------------------------------------------------------------- 1 | // Package kingpin provides command line interfaces like this: 2 | // 3 | // $ chat 4 | // usage: chat [] [] [ ...] 5 | // 6 | // Flags: 7 | // --debug enable debug mode 8 | // --help Show help. 9 | // --server=127.0.0.1 server address 10 | // 11 | // Commands: 12 | // help 13 | // Show help for a command. 14 | // 15 | // post [] 16 | // Post a message to a channel. 17 | // 18 | // register 19 | // Register a new user. 20 | // 21 | // $ chat help post 22 | // usage: chat [] post [] [] 23 | // 24 | // Post a message to a channel. 25 | // 26 | // Flags: 27 | // --image=IMAGE image to post 28 | // 29 | // Args: 30 | // channel to post to 31 | // [] text to post 32 | // $ chat post --image=~/Downloads/owls.jpg pics 33 | // 34 | // From code like this: 35 | // 36 | // package main 37 | // 38 | // import "gopkg.in/alecthomas/kingpin.v1" 39 | // 40 | // var ( 41 | // debug = kingpin.Flag("debug", "enable debug mode").Default("false").Bool() 42 | // serverIP = kingpin.Flag("server", "server address").Default("127.0.0.1").IP() 43 | // 44 | // register = kingpin.Command("register", "Register a new user.") 45 | // registerNick = register.Arg("nick", "nickname for user").Required().String() 46 | // registerName = register.Arg("name", "name of user").Required().String() 47 | // 48 | // post = kingpin.Command("post", "Post a message to a channel.") 49 | // postImage = post.Flag("image", "image to post").ExistingFile() 50 | // postChannel = post.Arg("channel", "channel to post to").Required().String() 51 | // postText = post.Arg("text", "text to post").String() 52 | // ) 53 | // 54 | // func main() { 55 | // switch kingpin.Parse() { 56 | // // Register user 57 | // case "register": 58 | // println(*registerNick) 59 | // 60 | // // Post message 61 | // case "post": 62 | // if *postImage != nil { 63 | // } 64 | // if *postText != "" { 65 | // } 66 | // } 67 | // } 68 | package kingpin 69 | -------------------------------------------------------------------------------- /vendor/github.com/alecthomas/kingpin/envar.go: -------------------------------------------------------------------------------- 1 | package kingpin 2 | 3 | import ( 4 | "os" 5 | "regexp" 6 | ) 7 | 8 | var ( 9 | envVarValuesSeparator = "\r?\n" 10 | envVarValuesTrimmer = regexp.MustCompile(envVarValuesSeparator + "$") 11 | envVarValuesSplitter = regexp.MustCompile(envVarValuesSeparator) 12 | ) 13 | 14 | type envarMixin struct { 15 | envar string 16 | noEnvar bool 17 | } 18 | 19 | func (e *envarMixin) HasEnvarValue() bool { 20 | return e.GetEnvarValue() != "" 21 | } 22 | 23 | func (e *envarMixin) GetEnvarValue() string { 24 | if e.noEnvar || e.envar == "" { 25 | return "" 26 | } 27 | return os.Getenv(e.envar) 28 | } 29 | 30 | func (e *envarMixin) GetSplitEnvarValue() []string { 31 | values := make([]string, 0) 32 | 33 | envarValue := e.GetEnvarValue() 34 | if envarValue == "" { 35 | return values 36 | } 37 | 38 | // Split by new line to extract multiple values, if any. 39 | trimmed := envVarValuesTrimmer.ReplaceAllString(envarValue, "") 40 | for _, value := range envVarValuesSplitter.Split(trimmed, -1) { 41 | values = append(values, value) 42 | } 43 | 44 | return values 45 | } 46 | -------------------------------------------------------------------------------- /vendor/github.com/alecthomas/kingpin/global.go: -------------------------------------------------------------------------------- 1 | package kingpin 2 | 3 | import ( 4 | "os" 5 | "path/filepath" 6 | ) 7 | 8 | var ( 9 | // CommandLine is the default Kingpin parser. 10 | CommandLine = New(filepath.Base(os.Args[0]), "") 11 | // Global help flag. Exposed for user customisation. 12 | HelpFlag = CommandLine.HelpFlag 13 | // Top-level help command. Exposed for user customisation. May be nil. 14 | HelpCommand = CommandLine.HelpCommand 15 | // Global version flag. Exposed for user customisation. May be nil. 16 | VersionFlag = CommandLine.VersionFlag 17 | ) 18 | 19 | // Command adds a new command to the default parser. 20 | func Command(name, help string) *CmdClause { 21 | return CommandLine.Command(name, help) 22 | } 23 | 24 | // Flag adds a new flag to the default parser. 25 | func Flag(name, help string) *FlagClause { 26 | return CommandLine.Flag(name, help) 27 | } 28 | 29 | // Arg adds a new argument to the top-level of the default parser. 30 | func Arg(name, help string) *ArgClause { 31 | return CommandLine.Arg(name, help) 32 | } 33 | 34 | // Parse and return the selected command. Will call the termination handler if 35 | // an error is encountered. 36 | func Parse() string { 37 | selected := MustParse(CommandLine.Parse(os.Args[1:])) 38 | if selected == "" && CommandLine.cmdGroup.have() { 39 | Usage() 40 | CommandLine.terminate(0) 41 | } 42 | return selected 43 | } 44 | 45 | // Errorf prints an error message to stderr. 46 | func Errorf(format string, args ...interface{}) { 47 | CommandLine.Errorf(format, args...) 48 | } 49 | 50 | // Fatalf prints an error message to stderr and exits. 51 | func Fatalf(format string, args ...interface{}) { 52 | CommandLine.Fatalf(format, args...) 53 | } 54 | 55 | // FatalIfError prints an error and exits if err is not nil. The error is printed 56 | // with the given prefix. 57 | func FatalIfError(err error, format string, args ...interface{}) { 58 | CommandLine.FatalIfError(err, format, args...) 59 | } 60 | 61 | // FatalUsage prints an error message followed by usage information, then 62 | // exits with a non-zero status. 63 | func FatalUsage(format string, args ...interface{}) { 64 | CommandLine.FatalUsage(format, args...) 65 | } 66 | 67 | // FatalUsageContext writes a printf formatted error message to stderr, then 68 | // usage information for the given ParseContext, before exiting. 69 | func FatalUsageContext(context *ParseContext, format string, args ...interface{}) { 70 | CommandLine.FatalUsageContext(context, format, args...) 71 | } 72 | 73 | // Usage prints usage to stderr. 74 | func Usage() { 75 | CommandLine.Usage(os.Args[1:]) 76 | } 77 | 78 | // Set global usage template to use (defaults to DefaultUsageTemplate). 79 | func UsageTemplate(template string) *Application { 80 | return CommandLine.UsageTemplate(template) 81 | } 82 | 83 | // MustParse can be used with app.Parse(args) to exit with an error if parsing fails. 84 | func MustParse(command string, err error) string { 85 | if err != nil { 86 | Fatalf("%s, try --help", err) 87 | } 88 | return command 89 | } 90 | 91 | // Version adds a flag for displaying the application version number. 92 | func Version(version string) *Application { 93 | return CommandLine.Version(version) 94 | } 95 | -------------------------------------------------------------------------------- /vendor/github.com/alecthomas/kingpin/guesswidth.go: -------------------------------------------------------------------------------- 1 | // +build appengine !linux,!freebsd,!darwin,!dragonfly,!netbsd,!openbsd 2 | 3 | package kingpin 4 | 5 | import "io" 6 | 7 | func guessWidth(w io.Writer) int { 8 | return 80 9 | } 10 | -------------------------------------------------------------------------------- /vendor/github.com/alecthomas/kingpin/guesswidth_unix.go: -------------------------------------------------------------------------------- 1 | // +build !appengine,linux freebsd darwin dragonfly netbsd openbsd 2 | 3 | package kingpin 4 | 5 | import ( 6 | "io" 7 | "os" 8 | "strconv" 9 | "syscall" 10 | "unsafe" 11 | ) 12 | 13 | func guessWidth(w io.Writer) int { 14 | // check if COLUMNS env is set to comply with 15 | // http://pubs.opengroup.org/onlinepubs/009604499/basedefs/xbd_chap08.html 16 | colsStr := os.Getenv("COLUMNS") 17 | if colsStr != "" { 18 | if cols, err := strconv.Atoi(colsStr); err == nil { 19 | return cols 20 | } 21 | } 22 | 23 | if t, ok := w.(*os.File); ok { 24 | fd := t.Fd() 25 | var dimensions [4]uint16 26 | 27 | if _, _, err := syscall.Syscall6( 28 | syscall.SYS_IOCTL, 29 | uintptr(fd), 30 | uintptr(syscall.TIOCGWINSZ), 31 | uintptr(unsafe.Pointer(&dimensions)), 32 | 0, 0, 0, 33 | ); err == 0 { 34 | return int(dimensions[1]) 35 | } 36 | } 37 | return 80 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/alecthomas/kingpin/model.go: -------------------------------------------------------------------------------- 1 | package kingpin 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | "strings" 7 | ) 8 | 9 | // Data model for Kingpin command-line structure. 10 | 11 | type FlagGroupModel struct { 12 | Flags []*FlagModel 13 | } 14 | 15 | func (f *FlagGroupModel) FlagSummary() string { 16 | out := []string{} 17 | count := 0 18 | for _, flag := range f.Flags { 19 | if flag.Name != "help" { 20 | count++ 21 | } 22 | if flag.Required { 23 | if flag.IsBoolFlag() { 24 | out = append(out, fmt.Sprintf("--[no-]%s", flag.Name)) 25 | } else { 26 | out = append(out, fmt.Sprintf("--%s=%s", flag.Name, flag.FormatPlaceHolder())) 27 | } 28 | } 29 | } 30 | if count != len(out) { 31 | out = append(out, "[]") 32 | } 33 | return strings.Join(out, " ") 34 | } 35 | 36 | type FlagModel struct { 37 | Name string 38 | Help string 39 | Short rune 40 | Default []string 41 | Envar string 42 | PlaceHolder string 43 | Required bool 44 | Hidden bool 45 | Value Value 46 | } 47 | 48 | func (f *FlagModel) String() string { 49 | return f.Value.String() 50 | } 51 | 52 | func (f *FlagModel) IsBoolFlag() bool { 53 | if fl, ok := f.Value.(boolFlag); ok { 54 | return fl.IsBoolFlag() 55 | } 56 | return false 57 | } 58 | 59 | func (f *FlagModel) FormatPlaceHolder() string { 60 | if f.PlaceHolder != "" { 61 | return f.PlaceHolder 62 | } 63 | if len(f.Default) > 0 { 64 | ellipsis := "" 65 | if len(f.Default) > 1 { 66 | ellipsis = "..." 67 | } 68 | if _, ok := f.Value.(*stringValue); ok { 69 | return strconv.Quote(f.Default[0]) + ellipsis 70 | } 71 | return f.Default[0] + ellipsis 72 | } 73 | return strings.ToUpper(f.Name) 74 | } 75 | 76 | type ArgGroupModel struct { 77 | Args []*ArgModel 78 | } 79 | 80 | func (a *ArgGroupModel) ArgSummary() string { 81 | depth := 0 82 | out := []string{} 83 | for _, arg := range a.Args { 84 | h := "<" + arg.Name + ">" 85 | if !arg.Required { 86 | h = "[" + h 87 | depth++ 88 | } 89 | out = append(out, h) 90 | } 91 | out[len(out)-1] = out[len(out)-1] + strings.Repeat("]", depth) 92 | return strings.Join(out, " ") 93 | } 94 | 95 | type ArgModel struct { 96 | Name string 97 | Help string 98 | Default []string 99 | Envar string 100 | Required bool 101 | Value Value 102 | } 103 | 104 | func (a *ArgModel) String() string { 105 | return a.Value.String() 106 | } 107 | 108 | type CmdGroupModel struct { 109 | Commands []*CmdModel 110 | } 111 | 112 | func (c *CmdGroupModel) FlattenedCommands() (out []*CmdModel) { 113 | for _, cmd := range c.Commands { 114 | if len(cmd.Commands) == 0 { 115 | out = append(out, cmd) 116 | } 117 | out = append(out, cmd.FlattenedCommands()...) 118 | } 119 | return 120 | } 121 | 122 | type CmdModel struct { 123 | Name string 124 | Aliases []string 125 | Help string 126 | FullCommand string 127 | Depth int 128 | Hidden bool 129 | Default bool 130 | *FlagGroupModel 131 | *ArgGroupModel 132 | *CmdGroupModel 133 | } 134 | 135 | func (c *CmdModel) String() string { 136 | return c.FullCommand 137 | } 138 | 139 | type ApplicationModel struct { 140 | Name string 141 | Help string 142 | Version string 143 | Author string 144 | *ArgGroupModel 145 | *CmdGroupModel 146 | *FlagGroupModel 147 | } 148 | 149 | func (a *Application) Model() *ApplicationModel { 150 | return &ApplicationModel{ 151 | Name: a.Name, 152 | Help: a.Help, 153 | Version: a.version, 154 | Author: a.author, 155 | FlagGroupModel: a.flagGroup.Model(), 156 | ArgGroupModel: a.argGroup.Model(), 157 | CmdGroupModel: a.cmdGroup.Model(), 158 | } 159 | } 160 | 161 | func (a *argGroup) Model() *ArgGroupModel { 162 | m := &ArgGroupModel{} 163 | for _, arg := range a.args { 164 | m.Args = append(m.Args, arg.Model()) 165 | } 166 | return m 167 | } 168 | 169 | func (a *ArgClause) Model() *ArgModel { 170 | return &ArgModel{ 171 | Name: a.name, 172 | Help: a.help, 173 | Default: a.defaultValues, 174 | Envar: a.envar, 175 | Required: a.required, 176 | Value: a.value, 177 | } 178 | } 179 | 180 | func (f *flagGroup) Model() *FlagGroupModel { 181 | m := &FlagGroupModel{} 182 | for _, fl := range f.flagOrder { 183 | m.Flags = append(m.Flags, fl.Model()) 184 | } 185 | return m 186 | } 187 | 188 | func (f *FlagClause) Model() *FlagModel { 189 | return &FlagModel{ 190 | Name: f.name, 191 | Help: f.help, 192 | Short: rune(f.shorthand), 193 | Default: f.defaultValues, 194 | Envar: f.envar, 195 | PlaceHolder: f.placeholder, 196 | Required: f.required, 197 | Hidden: f.hidden, 198 | Value: f.value, 199 | } 200 | } 201 | 202 | func (c *cmdGroup) Model() *CmdGroupModel { 203 | m := &CmdGroupModel{} 204 | for _, cm := range c.commandOrder { 205 | m.Commands = append(m.Commands, cm.Model()) 206 | } 207 | return m 208 | } 209 | 210 | func (c *CmdClause) Model() *CmdModel { 211 | depth := 0 212 | for i := c; i != nil; i = i.parent { 213 | depth++ 214 | } 215 | return &CmdModel{ 216 | Name: c.name, 217 | Aliases: c.aliases, 218 | Help: c.help, 219 | Depth: depth, 220 | Hidden: c.hidden, 221 | Default: c.isDefault, 222 | FullCommand: c.FullCommand(), 223 | FlagGroupModel: c.flagGroup.Model(), 224 | ArgGroupModel: c.argGroup.Model(), 225 | CmdGroupModel: c.cmdGroup.Model(), 226 | } 227 | } 228 | -------------------------------------------------------------------------------- /vendor/github.com/alecthomas/kingpin/values.json: -------------------------------------------------------------------------------- 1 | [ 2 | {"type": "bool", "parser": "strconv.ParseBool(s)"}, 3 | {"type": "string", "parser": "s, error(nil)", "format": "string(*f.v)", "plural": "Strings"}, 4 | {"type": "uint", "parser": "strconv.ParseUint(s, 0, 64)", "plural": "Uints"}, 5 | {"type": "uint8", "parser": "strconv.ParseUint(s, 0, 8)"}, 6 | {"type": "uint16", "parser": "strconv.ParseUint(s, 0, 16)"}, 7 | {"type": "uint32", "parser": "strconv.ParseUint(s, 0, 32)"}, 8 | {"type": "uint64", "parser": "strconv.ParseUint(s, 0, 64)"}, 9 | {"type": "int", "parser": "strconv.ParseFloat(s, 64)", "plural": "Ints"}, 10 | {"type": "int8", "parser": "strconv.ParseInt(s, 0, 8)"}, 11 | {"type": "int16", "parser": "strconv.ParseInt(s, 0, 16)"}, 12 | {"type": "int32", "parser": "strconv.ParseInt(s, 0, 32)"}, 13 | {"type": "int64", "parser": "strconv.ParseInt(s, 0, 64)"}, 14 | {"type": "float64", "parser": "strconv.ParseFloat(s, 64)"}, 15 | {"type": "float32", "parser": "strconv.ParseFloat(s, 32)"}, 16 | {"name": "Duration", "type": "time.Duration", "no_value_parser": true}, 17 | {"name": "IP", "type": "net.IP", "no_value_parser": true}, 18 | {"name": "TCPAddr", "Type": "*net.TCPAddr", "plural": "TCPList", "no_value_parser": true}, 19 | {"name": "ExistingFile", "Type": "string", "plural": "ExistingFiles", "no_value_parser": true}, 20 | {"name": "ExistingDir", "Type": "string", "plural": "ExistingDirs", "no_value_parser": true}, 21 | {"name": "ExistingFileOrDir", "Type": "string", "plural": "ExistingFilesOrDirs", "no_value_parser": true}, 22 | {"name": "Regexp", "Type": "*regexp.Regexp", "parser": "regexp.Compile(s)"}, 23 | {"name": "ResolvedIP", "Type": "net.IP", "parser": "resolveHost(s)", "help": "Resolve a hostname or IP to an IP."}, 24 | {"name": "HexBytes", "Type": "[]byte", "parser": "hex.DecodeString(s)", "help": "Bytes as a hex string."} 25 | ] 26 | -------------------------------------------------------------------------------- /vendor/github.com/alecthomas/template/README.md: -------------------------------------------------------------------------------- 1 | # Go's `text/template` package with newline elision 2 | 3 | This is a fork of Go 1.4's [text/template](http://golang.org/pkg/text/template/) package with one addition: a backslash immediately after a closing delimiter will delete all subsequent newlines until a non-newline. 4 | 5 | eg. 6 | 7 | ``` 8 | {{if true}}\ 9 | hello 10 | {{end}}\ 11 | ``` 12 | 13 | Will result in: 14 | 15 | ``` 16 | hello\n 17 | ``` 18 | 19 | Rather than: 20 | 21 | ``` 22 | \n 23 | hello\n 24 | \n 25 | ``` 26 | -------------------------------------------------------------------------------- /vendor/github.com/alecthomas/template/helper.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 | // Helper functions to make constructing templates easier. 6 | 7 | package template 8 | 9 | import ( 10 | "fmt" 11 | "io/ioutil" 12 | "path/filepath" 13 | ) 14 | 15 | // Functions and methods to parse templates. 16 | 17 | // Must is a helper that wraps a call to a function returning (*Template, error) 18 | // and panics if the error is non-nil. It is intended for use in variable 19 | // initializations such as 20 | // var t = template.Must(template.New("name").Parse("text")) 21 | func Must(t *Template, err error) *Template { 22 | if err != nil { 23 | panic(err) 24 | } 25 | return t 26 | } 27 | 28 | // ParseFiles creates a new Template and parses the template definitions from 29 | // the named files. The returned template's name will have the (base) name and 30 | // (parsed) contents of the first file. There must be at least one file. 31 | // If an error occurs, parsing stops and the returned *Template is nil. 32 | func ParseFiles(filenames ...string) (*Template, error) { 33 | return parseFiles(nil, filenames...) 34 | } 35 | 36 | // ParseFiles parses the named files and associates the resulting templates with 37 | // t. If an error occurs, parsing stops and the returned template is nil; 38 | // otherwise it is t. There must be at least one file. 39 | func (t *Template) ParseFiles(filenames ...string) (*Template, error) { 40 | return parseFiles(t, filenames...) 41 | } 42 | 43 | // parseFiles is the helper for the method and function. If the argument 44 | // template is nil, it is created from the first file. 45 | func parseFiles(t *Template, filenames ...string) (*Template, error) { 46 | if len(filenames) == 0 { 47 | // Not really a problem, but be consistent. 48 | return nil, fmt.Errorf("template: no files named in call to ParseFiles") 49 | } 50 | for _, filename := range filenames { 51 | b, err := ioutil.ReadFile(filename) 52 | if err != nil { 53 | return nil, err 54 | } 55 | s := string(b) 56 | name := filepath.Base(filename) 57 | // First template becomes return value if not already defined, 58 | // and we use that one for subsequent New calls to associate 59 | // all the templates together. Also, if this file has the same name 60 | // as t, this file becomes the contents of t, so 61 | // t, err := New(name).Funcs(xxx).ParseFiles(name) 62 | // works. Otherwise we create a new template associated with t. 63 | var tmpl *Template 64 | if t == nil { 65 | t = New(name) 66 | } 67 | if name == t.Name() { 68 | tmpl = t 69 | } else { 70 | tmpl = t.New(name) 71 | } 72 | _, err = tmpl.Parse(s) 73 | if err != nil { 74 | return nil, err 75 | } 76 | } 77 | return t, nil 78 | } 79 | 80 | // ParseGlob creates a new Template and parses the template definitions from the 81 | // files identified by the pattern, which must match at least one file. The 82 | // returned template will have the (base) name and (parsed) contents of the 83 | // first file matched by the pattern. ParseGlob is equivalent to calling 84 | // ParseFiles with the list of files matched by the pattern. 85 | func ParseGlob(pattern string) (*Template, error) { 86 | return parseGlob(nil, pattern) 87 | } 88 | 89 | // ParseGlob parses the template definitions in the files identified by the 90 | // pattern and associates the resulting templates with t. The pattern is 91 | // processed by filepath.Glob and must match at least one file. ParseGlob is 92 | // equivalent to calling t.ParseFiles with the list of files matched by the 93 | // pattern. 94 | func (t *Template) ParseGlob(pattern string) (*Template, error) { 95 | return parseGlob(t, pattern) 96 | } 97 | 98 | // parseGlob is the implementation of the function and method ParseGlob. 99 | func parseGlob(t *Template, pattern string) (*Template, error) { 100 | filenames, err := filepath.Glob(pattern) 101 | if err != nil { 102 | return nil, err 103 | } 104 | if len(filenames) == 0 { 105 | return nil, fmt.Errorf("template: pattern matches no files: %#q", pattern) 106 | } 107 | return parseFiles(t, filenames...) 108 | } 109 | -------------------------------------------------------------------------------- /vendor/github.com/alecthomas/units/COPYING: -------------------------------------------------------------------------------- 1 | Copyright (C) 2014 Alec Thomas 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /vendor/github.com/alecthomas/units/README.md: -------------------------------------------------------------------------------- 1 | # Units - Helpful unit multipliers and functions for Go 2 | 3 | The goal of this package is to have functionality similar to the [time](http://golang.org/pkg/time/) package. 4 | 5 | It allows for code like this: 6 | 7 | ```go 8 | n, err := ParseBase2Bytes("1KB") 9 | // n == 1024 10 | n = units.Mebibyte * 512 11 | ``` 12 | -------------------------------------------------------------------------------- /vendor/github.com/alecthomas/units/bytes.go: -------------------------------------------------------------------------------- 1 | package units 2 | 3 | // Base2Bytes is the old non-SI power-of-2 byte scale (1024 bytes in a kilobyte, 4 | // etc.). 5 | type Base2Bytes int64 6 | 7 | // Base-2 byte units. 8 | const ( 9 | Kibibyte Base2Bytes = 1024 10 | KiB = Kibibyte 11 | Mebibyte = Kibibyte * 1024 12 | MiB = Mebibyte 13 | Gibibyte = Mebibyte * 1024 14 | GiB = Gibibyte 15 | Tebibyte = Gibibyte * 1024 16 | TiB = Tebibyte 17 | Pebibyte = Tebibyte * 1024 18 | PiB = Pebibyte 19 | Exbibyte = Pebibyte * 1024 20 | EiB = Exbibyte 21 | ) 22 | 23 | var ( 24 | bytesUnitMap = MakeUnitMap("iB", "B", 1024) 25 | oldBytesUnitMap = MakeUnitMap("B", "B", 1024) 26 | ) 27 | 28 | // ParseBase2Bytes supports both iB and B in base-2 multipliers. That is, KB 29 | // and KiB are both 1024. 30 | func ParseBase2Bytes(s string) (Base2Bytes, error) { 31 | n, err := ParseUnit(s, bytesUnitMap) 32 | if err != nil { 33 | n, err = ParseUnit(s, oldBytesUnitMap) 34 | } 35 | return Base2Bytes(n), err 36 | } 37 | 38 | func (b Base2Bytes) String() string { 39 | return ToString(int64(b), 1024, "iB", "B") 40 | } 41 | 42 | var ( 43 | metricBytesUnitMap = MakeUnitMap("B", "B", 1000) 44 | ) 45 | 46 | // MetricBytes are SI byte units (1000 bytes in a kilobyte). 47 | type MetricBytes SI 48 | 49 | // SI base-10 byte units. 50 | const ( 51 | Kilobyte MetricBytes = 1000 52 | KB = Kilobyte 53 | Megabyte = Kilobyte * 1000 54 | MB = Megabyte 55 | Gigabyte = Megabyte * 1000 56 | GB = Gigabyte 57 | Terabyte = Gigabyte * 1000 58 | TB = Terabyte 59 | Petabyte = Terabyte * 1000 60 | PB = Petabyte 61 | Exabyte = Petabyte * 1000 62 | EB = Exabyte 63 | ) 64 | 65 | // ParseMetricBytes parses base-10 metric byte units. That is, KB is 1000 bytes. 66 | func ParseMetricBytes(s string) (MetricBytes, error) { 67 | n, err := ParseUnit(s, metricBytesUnitMap) 68 | return MetricBytes(n), err 69 | } 70 | 71 | func (m MetricBytes) String() string { 72 | return ToString(int64(m), 1000, "B", "B") 73 | } 74 | 75 | // ParseStrictBytes supports both iB and B suffixes for base 2 and metric, 76 | // respectively. That is, KiB represents 1024 and KB represents 1000. 77 | func ParseStrictBytes(s string) (int64, error) { 78 | n, err := ParseUnit(s, bytesUnitMap) 79 | if err != nil { 80 | n, err = ParseUnit(s, metricBytesUnitMap) 81 | } 82 | return int64(n), err 83 | } 84 | -------------------------------------------------------------------------------- /vendor/github.com/alecthomas/units/doc.go: -------------------------------------------------------------------------------- 1 | // Package units provides helpful unit multipliers and functions for Go. 2 | // 3 | // The goal of this package is to have functionality similar to the time [1] package. 4 | // 5 | // 6 | // [1] http://golang.org/pkg/time/ 7 | // 8 | // It allows for code like this: 9 | // 10 | // n, err := ParseBase2Bytes("1KB") 11 | // // n == 1024 12 | // n = units.Mebibyte * 512 13 | package units 14 | -------------------------------------------------------------------------------- /vendor/github.com/alecthomas/units/si.go: -------------------------------------------------------------------------------- 1 | package units 2 | 3 | // SI units. 4 | type SI int64 5 | 6 | // SI unit multiples. 7 | const ( 8 | Kilo SI = 1000 9 | Mega = Kilo * 1000 10 | Giga = Mega * 1000 11 | Tera = Giga * 1000 12 | Peta = Tera * 1000 13 | Exa = Peta * 1000 14 | ) 15 | 16 | func MakeUnitMap(suffix, shortSuffix string, scale int64) map[string]float64 { 17 | return map[string]float64{ 18 | shortSuffix: 1, 19 | "K" + suffix: float64(scale), 20 | "M" + suffix: float64(scale * scale), 21 | "G" + suffix: float64(scale * scale * scale), 22 | "T" + suffix: float64(scale * scale * scale * scale), 23 | "P" + suffix: float64(scale * scale * scale * scale * scale), 24 | "E" + suffix: float64(scale * scale * scale * scale * scale * scale), 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/alecthomas/units/util.go: -------------------------------------------------------------------------------- 1 | package units 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "strings" 7 | ) 8 | 9 | var ( 10 | siUnits = []string{"", "K", "M", "G", "T", "P", "E"} 11 | ) 12 | 13 | func ToString(n int64, scale int64, suffix, baseSuffix string) string { 14 | mn := len(siUnits) 15 | out := make([]string, mn) 16 | for i, m := range siUnits { 17 | if n%scale != 0 || i == 0 && n == 0 { 18 | s := suffix 19 | if i == 0 { 20 | s = baseSuffix 21 | } 22 | out[mn-1-i] = fmt.Sprintf("%d%s%s", n%scale, m, s) 23 | } 24 | n /= scale 25 | if n == 0 { 26 | break 27 | } 28 | } 29 | return strings.Join(out, "") 30 | } 31 | 32 | // Below code ripped straight from http://golang.org/src/pkg/time/format.go?s=33392:33438#L1123 33 | var errLeadingInt = errors.New("units: bad [0-9]*") // never printed 34 | 35 | // leadingInt consumes the leading [0-9]* from s. 36 | func leadingInt(s string) (x int64, rem string, err error) { 37 | i := 0 38 | for ; i < len(s); i++ { 39 | c := s[i] 40 | if c < '0' || c > '9' { 41 | break 42 | } 43 | if x >= (1<<63-10)/10 { 44 | // overflow 45 | return 0, "", errLeadingInt 46 | } 47 | x = x*10 + int64(c) - '0' 48 | } 49 | return x, s[i:], nil 50 | } 51 | 52 | func ParseUnit(s string, unitMap map[string]float64) (int64, error) { 53 | // [-+]?([0-9]*(\.[0-9]*)?[a-z]+)+ 54 | orig := s 55 | f := float64(0) 56 | neg := false 57 | 58 | // Consume [-+]? 59 | if s != "" { 60 | c := s[0] 61 | if c == '-' || c == '+' { 62 | neg = c == '-' 63 | s = s[1:] 64 | } 65 | } 66 | // Special case: if all that is left is "0", this is zero. 67 | if s == "0" { 68 | return 0, nil 69 | } 70 | if s == "" { 71 | return 0, errors.New("units: invalid " + orig) 72 | } 73 | for s != "" { 74 | g := float64(0) // this element of the sequence 75 | 76 | var x int64 77 | var err error 78 | 79 | // The next character must be [0-9.] 80 | if !(s[0] == '.' || ('0' <= s[0] && s[0] <= '9')) { 81 | return 0, errors.New("units: invalid " + orig) 82 | } 83 | // Consume [0-9]* 84 | pl := len(s) 85 | x, s, err = leadingInt(s) 86 | if err != nil { 87 | return 0, errors.New("units: invalid " + orig) 88 | } 89 | g = float64(x) 90 | pre := pl != len(s) // whether we consumed anything before a period 91 | 92 | // Consume (\.[0-9]*)? 93 | post := false 94 | if s != "" && s[0] == '.' { 95 | s = s[1:] 96 | pl := len(s) 97 | x, s, err = leadingInt(s) 98 | if err != nil { 99 | return 0, errors.New("units: invalid " + orig) 100 | } 101 | scale := 1.0 102 | for n := pl - len(s); n > 0; n-- { 103 | scale *= 10 104 | } 105 | g += float64(x) / scale 106 | post = pl != len(s) 107 | } 108 | if !pre && !post { 109 | // no digits (e.g. ".s" or "-.s") 110 | return 0, errors.New("units: invalid " + orig) 111 | } 112 | 113 | // Consume unit. 114 | i := 0 115 | for ; i < len(s); i++ { 116 | c := s[i] 117 | if c == '.' || ('0' <= c && c <= '9') { 118 | break 119 | } 120 | } 121 | u := s[:i] 122 | s = s[i:] 123 | unit, ok := unitMap[u] 124 | if !ok { 125 | return 0, errors.New("units: unknown unit " + u + " in " + orig) 126 | } 127 | 128 | f += g * unit 129 | } 130 | 131 | if neg { 132 | f = -f 133 | } 134 | if f < float64(-1<<63) || f > float64(1<<63-1) { 135 | return 0, errors.New("units: overflow parsing unit") 136 | } 137 | return int64(f), nil 138 | } 139 | -------------------------------------------------------------------------------- /vendor/github.com/buger/goterm/README.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | 3 | This library provides basic building blocks for building advanced console UIs. 4 | 5 | Initially created for [Gor](http://github.com/buger/gor). 6 | 7 | Full API documentation: http://godoc.org/github.com/buger/goterm 8 | 9 | ## Basic usage 10 | 11 | Full screen console app, printing current time: 12 | 13 | ```go 14 | import ( 15 | tm "github.com/buger/goterm" 16 | "time" 17 | ) 18 | 19 | func main() { 20 | tm.Clear() // Clear current screen 21 | 22 | for { 23 | // By moving cursor to top-left position we ensure that console output 24 | // will be overwritten each time, instead of adding new. 25 | tm.MoveCursor(1,1) 26 | 27 | tm.Println("Current Time:", time.Now().Format(time.RFC1123)) 28 | 29 | tm.Flush() // Call it every time at the end of rendering 30 | 31 | time.Sleep(time.Second) 32 | } 33 | } 34 | ``` 35 | 36 | This can be seen in [examples/time_example.go](examples/time_example.go). To 37 | run it yourself, go into your `$GOPATH/src/github.com/buger/goterm` directory 38 | and run `go run ./examples/time_example.go` 39 | 40 | 41 | Print red bold message on white background: 42 | 43 | ```go 44 | tm.Println(tm.Backgound(tm.Color(tm.Bold("Important header"), tm.RED), tm.WHITE)) 45 | ``` 46 | 47 | 48 | Create box and move it to center of the screen: 49 | 50 | ```go 51 | tm.Clear() 52 | 53 | // Create Box with 30% width of current screen, and height of 20 lines 54 | box := tm.NewBox(30|tm.PCT, 20, 0) 55 | 56 | // Add some content to the box 57 | // Note that you can add ANY content, even tables 58 | fmt.Fprint(box, "Some box content") 59 | 60 | // Move Box to approx center of the screen 61 | tm.Print(tm.MoveTo(box.String(), 40|tm.PCT, 40|tm.PCT)) 62 | 63 | tm.Flush() 64 | ``` 65 | 66 | This can be found in [examples/box_example.go](examples/box_example.go). 67 | 68 | Draw table: 69 | 70 | ```go 71 | // Based on http://golang.org/pkg/text/tabwriter 72 | totals := tm.NewTable(0, 10, 5, ' ', 0) 73 | fmt.Fprintf(totals, "Time\tStarted\tActive\tFinished\n") 74 | fmt.Fprintf(totals, "%s\t%d\t%d\t%d\n", "All", started, started-finished, finished) 75 | tm.Println(totals) 76 | tm.Flush() 77 | ``` 78 | 79 | This can be found in [examples/table_example.go](examples/table_example.go). 80 | 81 | ## Line charts 82 | 83 | Chart example: 84 | 85 | ![screen shot 2013-07-09 at 5 05 37 pm](https://f.cloud.github.com/assets/14009/767676/e3dd35aa-e887-11e2-9cd2-f6451eb26adc.png) 86 | 87 | 88 | ```go 89 | import ( 90 | tm "github.com/buger/goterm" 91 | ) 92 | 93 | chart := tm.NewLineChart(100, 20) 94 | 95 | data := new(tm.DataTable) 96 | data.addColumn("Time") 97 | data.addColumn("Sin(x)") 98 | data.addColumn("Cos(x+1)") 99 | 100 | for i := 0.1; i < 10; i += 0.1 { 101 | data.addRow(i, math.Sin(i), math.Cos(i+1)) 102 | } 103 | 104 | tm.Println(chart.Draw(data)) 105 | ``` 106 | 107 | This can be found in [examples/chart_example.go](examples/chart_example.go). 108 | 109 | Drawing 2 separate graphs in different scales. Each graph have its own Y axe. 110 | 111 | ```go 112 | chart.Flags = tm.DRAW_INDEPENDENT 113 | ``` 114 | 115 | Drawing graph with relative scale (Grapwh draw starting from min value instead of zero) 116 | 117 | ```go 118 | chart.Flags = tm.DRAW_RELATIVE 119 | ``` 120 | -------------------------------------------------------------------------------- /vendor/github.com/buger/goterm/box.go: -------------------------------------------------------------------------------- 1 | package goterm 2 | 3 | import ( 4 | "bytes" 5 | "strings" 6 | ) 7 | 8 | const DEFAULT_BORDER = "- │ ┌ ┐ └ ┘" 9 | 10 | // Box allows you to create independent parts of screen, with its own buffer and borders. 11 | // Can be used for creating modal windows 12 | // 13 | // Generates boxes likes this: 14 | // ┌--------┐ 15 | // │hello │ 16 | // │world │ 17 | // │ │ 18 | // └--------┘ 19 | // 20 | type Box struct { 21 | Buf *bytes.Buffer 22 | 23 | Width int 24 | Height int 25 | 26 | // To get even padding: PaddingX ~= PaddingY*4 27 | PaddingX int 28 | PaddingY int 29 | 30 | // Should contain 6 border pieces separated by spaces 31 | // 32 | // Example border: 33 | // "- │ ┌ ┐ └ ┘" 34 | Border string 35 | 36 | Flags int // Not used now 37 | } 38 | 39 | // Create new Box. 40 | // Width and height can be relative: 41 | // 42 | // // Create box with 50% with of current screen and 10 lines height 43 | // box := tm.NewBox(50|tm.PCT, 10, 0) 44 | // 45 | func NewBox(width, height int, flags int) *Box { 46 | width, height = GetXY(width, height) 47 | 48 | box := new(Box) 49 | box.Buf = new(bytes.Buffer) 50 | box.Width = width 51 | box.Height = height 52 | box.Border = DEFAULT_BORDER 53 | box.PaddingX = 1 54 | box.PaddingY = 0 55 | box.Flags = flags 56 | 57 | return box 58 | } 59 | 60 | func (b *Box) Write(p []byte) (int, error) { 61 | return b.Buf.Write(p) 62 | } 63 | 64 | // Render Box 65 | func (b *Box) String() (out string) { 66 | borders := strings.Split(b.Border, " ") 67 | lines := strings.Split(b.Buf.String(), "\n") 68 | 69 | // Border + padding 70 | prefix := borders[1] + strings.Repeat(" ", b.PaddingX) 71 | suffix := strings.Repeat(" ", b.PaddingX) + borders[1] 72 | 73 | offset := b.PaddingY + 1 // 1 is border width 74 | 75 | // Content width without borders and padding 76 | contentWidth := b.Width - (b.PaddingX+1)*2 77 | 78 | for y := 0; y < b.Height; y++ { 79 | var line string 80 | 81 | switch { 82 | // Draw borders for first line 83 | case y == 0: 84 | line = borders[2] + strings.Repeat(borders[0], b.Width-2) + borders[3] 85 | 86 | // Draw borders for last line 87 | case y == (b.Height - 1): 88 | line = borders[4] + strings.Repeat(borders[0], b.Width-2) + borders[5] 89 | 90 | // Draw top and bottom padding 91 | case y <= b.PaddingY || y >= (b.Height-b.PaddingY): 92 | line = borders[1] + strings.Repeat(" ", b.Width-2) + borders[1] 93 | 94 | // Render content 95 | default: 96 | if len(lines) > y-offset { 97 | line = lines[y-offset] 98 | } else { 99 | line = "" 100 | } 101 | 102 | if len(line) > contentWidth-1 { 103 | // If line is too large limit it 104 | line = line[0:contentWidth] 105 | } else { 106 | // If line is too small enlarge it by adding spaces 107 | line = line + strings.Repeat(" ", contentWidth-len(line)) 108 | } 109 | 110 | line = prefix + line + suffix 111 | } 112 | 113 | // Don't add newline for last element 114 | if y != b.Height-1 { 115 | line = line + "\n" 116 | } 117 | 118 | out += line 119 | } 120 | 121 | return out 122 | } 123 | -------------------------------------------------------------------------------- /vendor/github.com/buger/goterm/table.go: -------------------------------------------------------------------------------- 1 | package goterm 2 | 3 | import ( 4 | "bytes" 5 | "text/tabwriter" 6 | ) 7 | 8 | // Tabwriter with own buffer: 9 | // 10 | // totals := tm.NewTable(0, 10, 5, ' ', 0) 11 | // fmt.Fprintf(totals, "Time\tStarted\tActive\tFinished\n") 12 | // fmt.Fprintf(totals, "%s\t%d\t%d\t%d\n", "All", started, started-finished, finished) 13 | // tm.Println(totals) 14 | // 15 | // Based on http://golang.org/pkg/text/tabwriter 16 | type Table struct { 17 | tabwriter.Writer 18 | 19 | Buf *bytes.Buffer 20 | } 21 | 22 | // Same as here http://golang.org/pkg/text/tabwriter/#Writer.Init 23 | func NewTable(minwidth, tabwidth, padding int, padchar byte, flags uint) *Table { 24 | tbl := new(Table) 25 | tbl.Buf = new(bytes.Buffer) 26 | tbl.Init(tbl.Buf, minwidth, tabwidth, padding, padchar, flags) 27 | 28 | return tbl 29 | } 30 | 31 | func (t *Table) String() string { 32 | t.Flush() 33 | return t.Buf.String() 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/buger/goterm/terminal.go: -------------------------------------------------------------------------------- 1 | // Provides basic bulding blocks for advanced console UI 2 | // 3 | // Coordinate system: 4 | // 5 | // 1/1---X----> 6 | // | 7 | // Y 8 | // | 9 | // v 10 | // 11 | // Documentation for ANSI codes: http://en.wikipedia.org/wiki/ANSI_escape_code#Colors 12 | // 13 | // Inspired by: http://www.darkcoding.net/software/pretty-command-line-console-output-on-unix-in-python-and-go-lang/ 14 | package goterm 15 | 16 | import ( 17 | "bufio" 18 | "bytes" 19 | "fmt" 20 | "os" 21 | "strings" 22 | ) 23 | 24 | // Reset all custom styles 25 | const RESET = "\033[0m" 26 | 27 | // Reset to default color 28 | const RESET_COLOR = "\033[32m" 29 | 30 | // Return curor to start of line and clean it 31 | const RESET_LINE = "\r\033[K" 32 | 33 | // List of possible colors 34 | const ( 35 | BLACK = iota 36 | RED 37 | GREEN 38 | YELLOW 39 | BLUE 40 | MAGENTA 41 | CYAN 42 | WHITE 43 | ) 44 | 45 | var Output *bufio.Writer = bufio.NewWriter(os.Stdout) 46 | 47 | func getColor(code int) string { 48 | return fmt.Sprintf("\033[3%dm", code) 49 | } 50 | 51 | func getBgColor(code int) string { 52 | return fmt.Sprintf("\033[4%dm", code) 53 | } 54 | 55 | // Set percent flag: num | PCT 56 | // 57 | // Check percent flag: num & PCT 58 | // 59 | // Reset percent flag: num & 0xFF 60 | const PCT = 0x80000000 61 | 62 | type winsize struct { 63 | Row uint16 64 | Col uint16 65 | Xpixel uint16 66 | Ypixel uint16 67 | } 68 | 69 | // Global screen buffer 70 | // Its not recommented write to buffer dirrectly, use package Print,Printf,Println fucntions instead. 71 | var Screen *bytes.Buffer = new(bytes.Buffer) 72 | 73 | // Get relative or absolute coorditantes 74 | // To get relative, set PCT flag to number: 75 | // 76 | // // Get 10% of total width to `x` and 20 to y 77 | // x, y = tm.GetXY(10|tm.PCT, 20) 78 | // 79 | func GetXY(x int, y int) (int, int) { 80 | if y == -1 { 81 | y = CurrentHeight() + 1 82 | } 83 | 84 | if x&PCT != 0 { 85 | x = int((x & 0xFF) * Width() / 100) 86 | } 87 | 88 | if y&PCT != 0 { 89 | y = int((y & 0xFF) * Height() / 100) 90 | } 91 | 92 | return x, y 93 | } 94 | 95 | type sf func(int, string) string 96 | 97 | // Apply given transformation func for each line in string 98 | func applyTransform(str string, transform sf) (out string) { 99 | out = "" 100 | 101 | for idx, line := range strings.Split(str, "\n") { 102 | out += transform(idx, line) 103 | } 104 | 105 | return 106 | } 107 | 108 | // Clear screen 109 | func Clear() { 110 | Output.WriteString("\033[2J") 111 | } 112 | 113 | // Move cursor to given position 114 | func MoveCursor(x int, y int) { 115 | fmt.Fprintf(Screen, "\033[%d;%dH", x, y) 116 | } 117 | 118 | // Move string to possition 119 | func MoveTo(str string, x int, y int) (out string) { 120 | x, y = GetXY(x, y) 121 | 122 | return applyTransform(str, func(idx int, line string) string { 123 | return fmt.Sprintf("\033[%d;%dH%s", y+idx, x, line) 124 | }) 125 | } 126 | 127 | // Return carrier to start of line 128 | func ResetLine(str string) (out string) { 129 | return applyTransform(str, func(idx int, line string) string { 130 | return fmt.Sprintf(RESET_LINE, line) 131 | }) 132 | } 133 | 134 | // Make bold 135 | func Bold(str string) string { 136 | return applyTransform(str, func(idx int, line string) string { 137 | return fmt.Sprintf("\033[1m%s\033[0m", line) 138 | }) 139 | } 140 | 141 | // Apply given color to string: 142 | // 143 | // tm.Color("RED STRING", tm.RED) 144 | // 145 | func Color(str string, color int) string { 146 | return applyTransform(str, func(idx int, line string) string { 147 | return fmt.Sprintf("%s%s%s", getColor(color), line, RESET) 148 | }) 149 | } 150 | 151 | func Highlight(str, substr string, color int) string { 152 | hiSubstr := Color(substr, color) 153 | return strings.Replace(str, substr, hiSubstr, -1) 154 | } 155 | 156 | func HighlightRegion(str string, from, to, color int) string { 157 | return str[:from] + Color(str[from:to], color) + str[to:] 158 | } 159 | 160 | // Change background color of string: 161 | // 162 | // tm.Background("string", tm.RED) 163 | // 164 | func Background(str string, color int) string { 165 | return applyTransform(str, func(idx int, line string) string { 166 | return fmt.Sprintf("%s%s%s", getBgColor(color), line, RESET) 167 | }) 168 | } 169 | 170 | // Get console width 171 | func Width() int { 172 | ws, err := getWinsize() 173 | 174 | if err != nil { 175 | return -1 176 | } 177 | 178 | return int(ws.Col) 179 | } 180 | 181 | // Get console height 182 | func Height() int { 183 | ws, err := getWinsize() 184 | if err != nil { 185 | return -1 186 | } 187 | return int(ws.Row) 188 | } 189 | 190 | // Get current height. Line count in Screen buffer. 191 | func CurrentHeight() int { 192 | return strings.Count(Screen.String(), "\n") 193 | } 194 | 195 | // Flush buffer and ensure that it will not overflow screen 196 | func Flush() { 197 | for idx, str := range strings.Split(Screen.String(), "\n") { 198 | if idx > Height() { 199 | return 200 | } 201 | 202 | Output.WriteString(str + "\n") 203 | } 204 | 205 | Output.Flush() 206 | Screen.Reset() 207 | } 208 | 209 | func Print(a ...interface{}) { 210 | fmt.Fprint(Screen, a...) 211 | } 212 | 213 | func Println(a ...interface{}) { 214 | fmt.Fprintln(Screen, a...) 215 | } 216 | 217 | func Printf(format string, a ...interface{}) { 218 | fmt.Fprintf(Screen, format, a...) 219 | } 220 | 221 | func Context(data string, idx, max int) string { 222 | var start, end int 223 | 224 | if len(data[:idx]) < (max / 2) { 225 | start = 0 226 | } else { 227 | start = idx - max/2 228 | } 229 | 230 | if len(data)-idx < (max / 2) { 231 | end = len(data) - 1 232 | } else { 233 | end = idx + max/2 234 | } 235 | 236 | return data[start:end] 237 | } 238 | -------------------------------------------------------------------------------- /vendor/github.com/buger/goterm/terminal_nosysioctl.go: -------------------------------------------------------------------------------- 1 | // +build windows plan9 solaris 2 | 3 | package goterm 4 | 5 | func getWinsize() (*winsize, error) { 6 | ws := new(winsize) 7 | 8 | ws.Col = 80 9 | ws.Row = 24 10 | 11 | return ws, nil 12 | } 13 | -------------------------------------------------------------------------------- /vendor/github.com/buger/goterm/terminal_sysioctl.go: -------------------------------------------------------------------------------- 1 | // +build !windows,!plan9,!solaris 2 | 3 | package goterm 4 | 5 | import ( 6 | "fmt" 7 | "os" 8 | "runtime" 9 | "syscall" 10 | "unsafe" 11 | ) 12 | 13 | func getWinsize() (*winsize, error) { 14 | ws := new(winsize) 15 | 16 | var _TIOCGWINSZ int64 17 | 18 | switch runtime.GOOS { 19 | case "linux": 20 | _TIOCGWINSZ = 0x5413 21 | case "darwin": 22 | _TIOCGWINSZ = 1074295912 23 | } 24 | 25 | r1, _, errno := syscall.Syscall(syscall.SYS_IOCTL, 26 | uintptr(syscall.Stdin), 27 | uintptr(_TIOCGWINSZ), 28 | uintptr(unsafe.Pointer(ws)), 29 | ) 30 | 31 | if int(r1) == -1 { 32 | fmt.Println("Error:", os.NewSyscallError("GetWinsize", errno)) 33 | return nil, os.NewSyscallError("GetWinsize", errno) 34 | } 35 | return ws, nil 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012-2013 Dave Collins 2 | 3 | Permission to use, copy, modify, and distribute this software for any 4 | purpose with or without fee is hereby granted, provided that the above 5 | copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/spew/bypasssafe.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Dave Collins 2 | // 3 | // Permission to use, copy, modify, and distribute this software for any 4 | // purpose with or without fee is hereby granted, provided that the above 5 | // copyright notice and this permission notice appear in all copies. 6 | // 7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | 15 | // NOTE: Due to the following build constraints, this file will only be compiled 16 | // when either the code is running on Google App Engine or "-tags disableunsafe" 17 | // is added to the go build command line. 18 | // +build appengine disableunsafe 19 | 20 | package spew 21 | 22 | import "reflect" 23 | 24 | const ( 25 | // UnsafeDisabled is a build-time constant which specifies whether or 26 | // not access to the unsafe package is available. 27 | UnsafeDisabled = true 28 | ) 29 | 30 | // unsafeReflectValue typically converts the passed reflect.Value into a one 31 | // that bypasses the typical safety restrictions preventing access to 32 | // unaddressable and unexported data. However, doing this relies on access to 33 | // the unsafe package. This is a stub version which simply returns the passed 34 | // reflect.Value when the unsafe package is not available. 35 | func unsafeReflectValue(v reflect.Value) reflect.Value { 36 | return v 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/fatih/color/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.6 4 | - tip 5 | 6 | -------------------------------------------------------------------------------- /vendor/github.com/fatih/color/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Fatih Arslan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /vendor/github.com/fatih/color/README.md: -------------------------------------------------------------------------------- 1 | # Color [![GoDoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](http://godoc.org/github.com/fatih/color) [![Build Status](http://img.shields.io/travis/fatih/color.svg?style=flat-square)](https://travis-ci.org/fatih/color) 2 | 3 | 4 | 5 | Color lets you use colorized outputs in terms of [ANSI Escape 6 | Codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors) in Go (Golang). It 7 | has support for Windows too! The API can be used in several ways, pick one that 8 | suits you. 9 | 10 | 11 | 12 | ![Color](http://i.imgur.com/c1JI0lA.png) 13 | 14 | 15 | ## Install 16 | 17 | ```bash 18 | go get github.com/fatih/color 19 | ``` 20 | 21 | ## Examples 22 | 23 | ### Standard colors 24 | 25 | ```go 26 | // Print with default helper functions 27 | color.Cyan("Prints text in cyan.") 28 | 29 | // A newline will be appended automatically 30 | color.Blue("Prints %s in blue.", "text") 31 | 32 | // These are using the default foreground colors 33 | color.Red("We have red") 34 | color.Magenta("And many others ..") 35 | 36 | ``` 37 | 38 | ### Mix and reuse colors 39 | 40 | ```go 41 | // Create a new color object 42 | c := color.New(color.FgCyan).Add(color.Underline) 43 | c.Println("Prints cyan text with an underline.") 44 | 45 | // Or just add them to New() 46 | d := color.New(color.FgCyan, color.Bold) 47 | d.Printf("This prints bold cyan %s\n", "too!.") 48 | 49 | // Mix up foreground and background colors, create new mixes! 50 | red := color.New(color.FgRed) 51 | 52 | boldRed := red.Add(color.Bold) 53 | boldRed.Println("This will print text in bold red.") 54 | 55 | whiteBackground := red.Add(color.BgWhite) 56 | whiteBackground.Println("Red text with white background.") 57 | ``` 58 | 59 | ### Custom print functions (PrintFunc) 60 | 61 | ```go 62 | // Create a custom print function for convenience 63 | red := color.New(color.FgRed).PrintfFunc() 64 | red("Warning") 65 | red("Error: %s", err) 66 | 67 | // Mix up multiple attributes 68 | notice := color.New(color.Bold, color.FgGreen).PrintlnFunc() 69 | notice("Don't forget this...") 70 | ``` 71 | 72 | ### Insert into noncolor strings (SprintFunc) 73 | 74 | ```go 75 | // Create SprintXxx functions to mix strings with other non-colorized strings: 76 | yellow := color.New(color.FgYellow).SprintFunc() 77 | red := color.New(color.FgRed).SprintFunc() 78 | fmt.Printf("This is a %s and this is %s.\n", yellow("warning"), red("error")) 79 | 80 | info := color.New(color.FgWhite, color.BgGreen).SprintFunc() 81 | fmt.Printf("This %s rocks!\n", info("package")) 82 | 83 | // Use helper functions 84 | fmt.Printf("This", color.RedString("warning"), "should be not neglected.") 85 | fmt.Printf(color.GreenString("Info:"), "an important message." ) 86 | 87 | // Windows supported too! Just don't forget to change the output to color.Output 88 | fmt.Fprintf(color.Output, "Windows support: %s", color.GreenString("PASS")) 89 | ``` 90 | 91 | ### Plug into existing code 92 | 93 | ```go 94 | // Use handy standard colors 95 | color.Set(color.FgYellow) 96 | 97 | fmt.Println("Existing text will now be in yellow") 98 | fmt.Printf("This one %s\n", "too") 99 | 100 | color.Unset() // Don't forget to unset 101 | 102 | // You can mix up parameters 103 | color.Set(color.FgMagenta, color.Bold) 104 | defer color.Unset() // Use it in your function 105 | 106 | fmt.Println("All text will now be bold magenta.") 107 | ``` 108 | 109 | ### Disable color 110 | 111 | There might be a case where you want to disable color output (for example to 112 | pipe the standard output of your app to somewhere else). `Color` has support to 113 | disable colors both globally and for single color definition. For example 114 | suppose you have a CLI app and a `--no-color` bool flag. You can easily disable 115 | the color output with: 116 | 117 | ```go 118 | 119 | var flagNoColor = flag.Bool("no-color", false, "Disable color output") 120 | 121 | if *flagNoColor { 122 | color.NoColor = true // disables colorized output 123 | } 124 | ``` 125 | 126 | It also has support for single color definitions (local). You can 127 | disable/enable color output on the fly: 128 | 129 | ```go 130 | c := color.New(color.FgCyan) 131 | c.Println("Prints cyan text") 132 | 133 | c.DisableColor() 134 | c.Println("This is printed without any color") 135 | 136 | c.EnableColor() 137 | c.Println("This prints again cyan...") 138 | ``` 139 | 140 | ## Todo 141 | 142 | * Save/Return previous values 143 | * Evaluate fmt.Formatter interface 144 | 145 | 146 | ## Credits 147 | 148 | * [Fatih Arslan](https://github.com/fatih) 149 | * Windows support via @mattn: [colorable](https://github.com/mattn/go-colorable) 150 | 151 | ## License 152 | 153 | The MIT License (MIT) - see [`LICENSE.md`](https://github.com/fatih/color/blob/master/LICENSE.md) for more details 154 | 155 | -------------------------------------------------------------------------------- /vendor/github.com/fatih/color/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package color is an ANSI color package to output colorized or SGR defined 3 | output to the standard output. The API can be used in several way, pick one 4 | that suits you. 5 | 6 | Use simple and default helper functions with predefined foreground colors: 7 | 8 | color.Cyan("Prints text in cyan.") 9 | 10 | // a newline will be appended automatically 11 | color.Blue("Prints %s in blue.", "text") 12 | 13 | // More default foreground colors.. 14 | color.Red("We have red") 15 | color.Yellow("Yellow color too!") 16 | color.Magenta("And many others ..") 17 | 18 | However there are times where custom color mixes are required. Below are some 19 | examples to create custom color objects and use the print functions of each 20 | separate color object. 21 | 22 | // Create a new color object 23 | c := color.New(color.FgCyan).Add(color.Underline) 24 | c.Println("Prints cyan text with an underline.") 25 | 26 | // Or just add them to New() 27 | d := color.New(color.FgCyan, color.Bold) 28 | d.Printf("This prints bold cyan %s\n", "too!.") 29 | 30 | 31 | // Mix up foreground and background colors, create new mixes! 32 | red := color.New(color.FgRed) 33 | 34 | boldRed := red.Add(color.Bold) 35 | boldRed.Println("This will print text in bold red.") 36 | 37 | whiteBackground := red.Add(color.BgWhite) 38 | whiteBackground.Println("Red text with White background.") 39 | 40 | 41 | You can create PrintXxx functions to simplify even more: 42 | 43 | // Create a custom print function for convenient 44 | red := color.New(color.FgRed).PrintfFunc() 45 | red("warning") 46 | red("error: %s", err) 47 | 48 | // Mix up multiple attributes 49 | notice := color.New(color.Bold, color.FgGreen).PrintlnFunc() 50 | notice("don't forget this...") 51 | 52 | 53 | Or create SprintXxx functions to mix strings with other non-colorized strings: 54 | 55 | yellow := New(FgYellow).SprintFunc() 56 | red := New(FgRed).SprintFunc() 57 | 58 | fmt.Printf("this is a %s and this is %s.\n", yellow("warning"), red("error")) 59 | 60 | info := New(FgWhite, BgGreen).SprintFunc() 61 | fmt.Printf("this %s rocks!\n", info("package")) 62 | 63 | Windows support is enabled by default. All Print functions works as intended. 64 | However only for color.SprintXXX functions, user should use fmt.FprintXXX and 65 | set the output to color.Output: 66 | 67 | fmt.Fprintf(color.Output, "Windows support: %s", color.GreenString("PASS")) 68 | 69 | info := New(FgWhite, BgGreen).SprintFunc() 70 | fmt.Fprintf(color.Output, "this %s rocks!\n", info("package")) 71 | 72 | Using with existing code is possible. Just use the Set() method to set the 73 | standard output to the given parameters. That way a rewrite of an existing 74 | code is not required. 75 | 76 | // Use handy standard colors. 77 | color.Set(color.FgYellow) 78 | 79 | fmt.Println("Existing text will be now in Yellow") 80 | fmt.Printf("This one %s\n", "too") 81 | 82 | color.Unset() // don't forget to unset 83 | 84 | // You can mix up parameters 85 | color.Set(color.FgMagenta, color.Bold) 86 | defer color.Unset() // use it in your function 87 | 88 | fmt.Println("All text will be now bold magenta.") 89 | 90 | There might be a case where you want to disable color output (for example to 91 | pipe the standard output of your app to somewhere else). `Color` has support to 92 | disable colors both globally and for single color definition. For example 93 | suppose you have a CLI app and a `--no-color` bool flag. You can easily disable 94 | the color output with: 95 | 96 | var flagNoColor = flag.Bool("no-color", false, "Disable color output") 97 | 98 | if *flagNoColor { 99 | color.NoColor = true // disables colorized output 100 | } 101 | 102 | It also has support for single color definitions (local). You can 103 | disable/enable color output on the fly: 104 | 105 | c := color.New(color.FgCyan) 106 | c.Println("Prints cyan text") 107 | 108 | c.DisableColor() 109 | c.Println("This is printed without any color") 110 | 111 | c.EnableColor() 112 | c.Println("This prints again cyan...") 113 | */ 114 | package color 115 | -------------------------------------------------------------------------------- /vendor/github.com/google/gofuzz/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.4 5 | - 1.3 6 | - 1.2 7 | - tip 8 | 9 | install: 10 | - if ! go get code.google.com/p/go.tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi 11 | 12 | script: 13 | - go test -cover 14 | -------------------------------------------------------------------------------- /vendor/github.com/google/gofuzz/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute # 2 | 3 | We'd love to accept your patches and contributions to this project. There are 4 | a just a few small guidelines you need to follow. 5 | 6 | 7 | ## Contributor License Agreement ## 8 | 9 | Contributions to any Google project must be accompanied by a Contributor 10 | License Agreement. This is not a copyright **assignment**, it simply gives 11 | Google permission to use and redistribute your contributions as part of the 12 | project. 13 | 14 | * If you are an individual writing original source code and you're sure you 15 | own the intellectual property, then you'll need to sign an [individual 16 | CLA][]. 17 | 18 | * If you work for a company that wants to allow you to contribute your work, 19 | then you'll need to sign a [corporate CLA][]. 20 | 21 | You generally only need to submit a CLA once, so if you've already submitted 22 | one (even if it was for a different project), you probably don't need to do it 23 | again. 24 | 25 | [individual CLA]: https://developers.google.com/open-source/cla/individual 26 | [corporate CLA]: https://developers.google.com/open-source/cla/corporate 27 | 28 | 29 | ## Submitting a patch ## 30 | 31 | 1. It's generally best to start by opening a new issue describing the bug or 32 | feature you're intending to fix. Even if you think it's relatively minor, 33 | it's helpful to know what people are working on. Mention in the initial 34 | issue that you are planning to work on that bug or feature so that it can 35 | be assigned to you. 36 | 37 | 1. Follow the normal process of [forking][] the project, and setup a new 38 | branch to work in. It's important that each group of changes be done in 39 | separate branches in order to ensure that a pull request only includes the 40 | commits related to that bug or feature. 41 | 42 | 1. Go makes it very simple to ensure properly formatted code, so always run 43 | `go fmt` on your code before committing it. You should also run 44 | [golint][] over your code. As noted in the [golint readme][], it's not 45 | strictly necessary that your code be completely "lint-free", but this will 46 | help you find common style issues. 47 | 48 | 1. Any significant changes should almost always be accompanied by tests. The 49 | project already has good test coverage, so look at some of the existing 50 | tests if you're unsure how to go about it. [gocov][] and [gocov-html][] 51 | are invaluable tools for seeing which parts of your code aren't being 52 | exercised by your tests. 53 | 54 | 1. Do your best to have [well-formed commit messages][] for each change. 55 | This provides consistency throughout the project, and ensures that commit 56 | messages are able to be formatted properly by various git tools. 57 | 58 | 1. Finally, push the commits to your fork and submit a [pull request][]. 59 | 60 | [forking]: https://help.github.com/articles/fork-a-repo 61 | [golint]: https://github.com/golang/lint 62 | [golint readme]: https://github.com/golang/lint/blob/master/README 63 | [gocov]: https://github.com/axw/gocov 64 | [gocov-html]: https://github.com/matm/gocov-html 65 | [well-formed commit messages]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html 66 | [squash]: http://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits 67 | [pull request]: https://help.github.com/articles/creating-a-pull-request 68 | -------------------------------------------------------------------------------- /vendor/github.com/google/gofuzz/README.md: -------------------------------------------------------------------------------- 1 | gofuzz 2 | ====== 3 | 4 | gofuzz is a library for populating go objects with random values. 5 | 6 | [![GoDoc](https://godoc.org/github.com/google/gofuzz?status.png)](https://godoc.org/github.com/google/gofuzz) 7 | [![Travis](https://travis-ci.org/google/gofuzz.svg?branch=master)](https://travis-ci.org/google/gofuzz) 8 | 9 | This is useful for testing: 10 | 11 | * Do your project's objects really serialize/unserialize correctly in all cases? 12 | * Is there an incorrectly formatted object that will cause your project to panic? 13 | 14 | Import with ```import "github.com/google/gofuzz"``` 15 | 16 | You can use it on single variables: 17 | ```go 18 | f := fuzz.New() 19 | var myInt int 20 | f.Fuzz(&myInt) // myInt gets a random value. 21 | ``` 22 | 23 | You can use it on maps: 24 | ```go 25 | f := fuzz.New().NilChance(0).NumElements(1, 1) 26 | var myMap map[ComplexKeyType]string 27 | f.Fuzz(&myMap) // myMap will have exactly one element. 28 | ``` 29 | 30 | Customize the chance of getting a nil pointer: 31 | ```go 32 | f := fuzz.New().NilChance(.5) 33 | var fancyStruct struct { 34 | A, B, C, D *string 35 | } 36 | f.Fuzz(&fancyStruct) // About half the pointers should be set. 37 | ``` 38 | 39 | You can even customize the randomization completely if needed: 40 | ```go 41 | type MyEnum string 42 | const ( 43 | A MyEnum = "A" 44 | B MyEnum = "B" 45 | ) 46 | type MyInfo struct { 47 | Type MyEnum 48 | AInfo *string 49 | BInfo *string 50 | } 51 | 52 | f := fuzz.New().NilChance(0).Funcs( 53 | func(e *MyInfo, c fuzz.Continue) { 54 | switch c.Intn(2) { 55 | case 0: 56 | e.Type = A 57 | c.Fuzz(&e.AInfo) 58 | case 1: 59 | e.Type = B 60 | c.Fuzz(&e.BInfo) 61 | } 62 | }, 63 | ) 64 | 65 | var myObject MyInfo 66 | f.Fuzz(&myObject) // Type will correspond to whether A or B info is set. 67 | ``` 68 | 69 | See more examples in ```example_test.go```. 70 | 71 | Happy testing! 72 | -------------------------------------------------------------------------------- /vendor/github.com/google/gofuzz/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2014 Google Inc. All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package fuzz is a library for populating go objects with random values. 18 | package fuzz 19 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/README.md: -------------------------------------------------------------------------------- 1 | # go-colorable 2 | 3 | Colorable writer for windows. 4 | 5 | For example, most of logger packages doesn't show colors on windows. (I know we can do it with ansicon. But I don't want.) 6 | This package is possible to handle escape sequence for ansi color on windows. 7 | 8 | ## Too Bad! 9 | 10 | ![](https://raw.githubusercontent.com/mattn/go-colorable/gh-pages/bad.png) 11 | 12 | 13 | ## So Good! 14 | 15 | ![](https://raw.githubusercontent.com/mattn/go-colorable/gh-pages/good.png) 16 | 17 | ## Usage 18 | 19 | ```go 20 | logrus.SetFormatter(&logrus.TextFormatter{ForceColors: true}) 21 | logrus.SetOutput(colorable.NewColorableStdout()) 22 | 23 | logrus.Info("succeeded") 24 | logrus.Warn("not correct") 25 | logrus.Error("something error") 26 | logrus.Fatal("panic") 27 | ``` 28 | 29 | You can compile above code on non-windows OSs. 30 | 31 | ## Installation 32 | 33 | ``` 34 | $ go get github.com/mattn/go-colorable 35 | ``` 36 | 37 | # License 38 | 39 | MIT 40 | 41 | # Author 42 | 43 | Yasuhiro Matsumoto (a.k.a mattn) 44 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/colorable_others.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package colorable 4 | 5 | import ( 6 | "io" 7 | "os" 8 | ) 9 | 10 | func NewColorableStdout() io.Writer { 11 | return os.Stdout 12 | } 13 | 14 | func NewColorableStderr() io.Writer { 15 | return os.Stderr 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) Yasuhiro MATSUMOTO 2 | 3 | MIT License (Expat) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/README.md: -------------------------------------------------------------------------------- 1 | # go-isatty 2 | 3 | isatty for golang 4 | 5 | ## Usage 6 | 7 | ```go 8 | package main 9 | 10 | import ( 11 | "fmt" 12 | "github.com/mattn/go-isatty" 13 | "os" 14 | ) 15 | 16 | func main() { 17 | if isatty.IsTerminal(os.Stdout.Fd()) { 18 | fmt.Println("Is Terminal") 19 | } else { 20 | fmt.Println("Is Not Terminal") 21 | } 22 | } 23 | ``` 24 | 25 | ## Installation 26 | 27 | ``` 28 | $ go get github.com/mattn/go-isatty 29 | ``` 30 | 31 | # License 32 | 33 | MIT 34 | 35 | # Author 36 | 37 | Yasuhiro Matsumoto (a.k.a mattn) 38 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/doc.go: -------------------------------------------------------------------------------- 1 | // Package isatty implements interface to isatty 2 | package isatty 3 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package isatty 4 | 5 | // IsTerminal returns true if the file descriptor is terminal which 6 | // is always false on on appengine classic which is a sandboxed PaaS. 7 | func IsTerminal(fd uintptr) bool { 8 | return false 9 | } 10 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd openbsd netbsd 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | const ioctlReadTermios = syscall.TIOCGETA 12 | 13 | // IsTerminal return true if the file descriptor is terminal. 14 | func IsTerminal(fd uintptr) bool { 15 | var termios syscall.Termios 16 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 17 | return err == 0 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_linux.go: -------------------------------------------------------------------------------- 1 | // +build linux 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | const ioctlReadTermios = syscall.TCGETS 12 | 13 | // IsTerminal return true if the file descriptor is terminal. 14 | func IsTerminal(fd uintptr) bool { 15 | var termios syscall.Termios 16 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 17 | return err == 0 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_solaris.go: -------------------------------------------------------------------------------- 1 | // +build solaris 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "golang.org/x/sys/unix" 8 | ) 9 | 10 | // IsTerminal returns true if the given file descriptor is a terminal. 11 | // see: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libbc/libc/gen/common/isatty.c 12 | func IsTerminal(fd uintptr) bool { 13 | var termio unix.Termio 14 | err := unix.IoctlSetTermio(int(fd), unix.TCGETA, &termio) 15 | return err == nil 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | var kernel32 = syscall.NewLazyDLL("kernel32.dll") 12 | var procGetConsoleMode = kernel32.NewProc("GetConsoleMode") 13 | 14 | // IsTerminal return true if the file descriptor is terminal. 15 | func IsTerminal(fd uintptr) bool { 16 | var st uint32 17 | r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, fd, uintptr(unsafe.Pointer(&st)), 0) 18 | return r != 0 && e == 0 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/pmezard/go-difflib/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Patrick Mezard 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | The names of its contributors may not be used to endorse or promote 14 | products derived from this software without specific prior written 15 | permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 18 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 20 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 23 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/LICENCE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 - 2013 Mat Ryer and Tyler Bunnell 2 | 3 | Please consider promoting this project if you find it useful. 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT 21 | OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 22 | OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 - 2013 Mat Ryer and Tyler Bunnell 2 | 3 | Please consider promoting this project if you find it useful. 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT 21 | OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 22 | OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.CommentWithoutT "a"}} 2 | func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) bool { 3 | return {{.DocInfo.Name}}(a.t, {{.ForwardedParams}}) 4 | } 5 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/doc.go: -------------------------------------------------------------------------------- 1 | // Package assert provides a set of comprehensive testing tools for use with the normal Go testing system. 2 | // 3 | // Example Usage 4 | // 5 | // The following is a complete example using assert in a standard test function: 6 | // import ( 7 | // "testing" 8 | // "github.com/stretchr/testify/assert" 9 | // ) 10 | // 11 | // func TestSomething(t *testing.T) { 12 | // 13 | // var a string = "Hello" 14 | // var b string = "Hello" 15 | // 16 | // assert.Equal(t, a, b, "The two words should be the same.") 17 | // 18 | // } 19 | // 20 | // if you assert many times, use the format below: 21 | // 22 | // import ( 23 | // "testing" 24 | // "github.com/stretchr/testify/assert" 25 | // ) 26 | // 27 | // func TestSomething(t *testing.T) { 28 | // assert := assert.New(t) 29 | // 30 | // var a string = "Hello" 31 | // var b string = "Hello" 32 | // 33 | // assert.Equal(a, b, "The two words should be the same.") 34 | // } 35 | // 36 | // Assertions 37 | // 38 | // Assertions allow you to easily write test code, and are global funcs in the `assert` package. 39 | // All assertion functions take, as the first argument, the `*testing.T` object provided by the 40 | // testing framework. This allows the assertion funcs to write the failings and other details to 41 | // the correct place. 42 | // 43 | // Every assertion function also takes an optional string message as the final argument, 44 | // allowing custom error messages to be appended to the message the assertion method outputs. 45 | package assert 46 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/errors.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | import ( 4 | "errors" 5 | ) 6 | 7 | // AnError is an error instance useful for testing. If the code does not care 8 | // about error specifics, and only needs to return the error for example, this 9 | // error should be used to make the test code more readable. 10 | var AnError = errors.New("assert.AnError general error for testing") 11 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/forward_assertions.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | // Assertions provides assertion methods around the 4 | // TestingT interface. 5 | type Assertions struct { 6 | t TestingT 7 | } 8 | 9 | // New makes a new Assertions object for the specified TestingT. 10 | func New(t TestingT) *Assertions { 11 | return &Assertions{ 12 | t: t, 13 | } 14 | } 15 | 16 | //go:generate go run ../_codegen/main.go -output-package=assert -template=assertion_forward.go.tmpl 17 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/http_assertions.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | "net/http/httptest" 7 | "net/url" 8 | "strings" 9 | ) 10 | 11 | // httpCode is a helper that returns HTTP code of the response. It returns -1 12 | // if building a new request fails. 13 | func httpCode(handler http.HandlerFunc, method, url string, values url.Values) int { 14 | w := httptest.NewRecorder() 15 | req, err := http.NewRequest(method, url+"?"+values.Encode(), nil) 16 | if err != nil { 17 | return -1 18 | } 19 | handler(w, req) 20 | return w.Code 21 | } 22 | 23 | // HTTPSuccess asserts that a specified handler returns a success status code. 24 | // 25 | // assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil) 26 | // 27 | // Returns whether the assertion was successful (true) or not (false). 28 | func HTTPSuccess(t TestingT, handler http.HandlerFunc, method, url string, values url.Values) bool { 29 | code := httpCode(handler, method, url, values) 30 | if code == -1 { 31 | return false 32 | } 33 | return code >= http.StatusOK && code <= http.StatusPartialContent 34 | } 35 | 36 | // HTTPRedirect asserts that a specified handler returns a redirect status code. 37 | // 38 | // assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} 39 | // 40 | // Returns whether the assertion was successful (true) or not (false). 41 | func HTTPRedirect(t TestingT, handler http.HandlerFunc, method, url string, values url.Values) bool { 42 | code := httpCode(handler, method, url, values) 43 | if code == -1 { 44 | return false 45 | } 46 | return code >= http.StatusMultipleChoices && code <= http.StatusTemporaryRedirect 47 | } 48 | 49 | // HTTPError asserts that a specified handler returns an error status code. 50 | // 51 | // assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} 52 | // 53 | // Returns whether the assertion was successful (true) or not (false). 54 | func HTTPError(t TestingT, handler http.HandlerFunc, method, url string, values url.Values) bool { 55 | code := httpCode(handler, method, url, values) 56 | if code == -1 { 57 | return false 58 | } 59 | return code >= http.StatusBadRequest 60 | } 61 | 62 | // HTTPBody is a helper that returns HTTP body of the response. It returns 63 | // empty string if building a new request fails. 64 | func HTTPBody(handler http.HandlerFunc, method, url string, values url.Values) string { 65 | w := httptest.NewRecorder() 66 | req, err := http.NewRequest(method, url+"?"+values.Encode(), nil) 67 | if err != nil { 68 | return "" 69 | } 70 | handler(w, req) 71 | return w.Body.String() 72 | } 73 | 74 | // HTTPBodyContains asserts that a specified handler returns a 75 | // body that contains a string. 76 | // 77 | // assert.HTTPBodyContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky") 78 | // 79 | // Returns whether the assertion was successful (true) or not (false). 80 | func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, str interface{}) bool { 81 | body := HTTPBody(handler, method, url, values) 82 | 83 | contains := strings.Contains(body, fmt.Sprint(str)) 84 | if !contains { 85 | Fail(t, fmt.Sprintf("Expected response body for \"%s\" to contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body)) 86 | } 87 | 88 | return contains 89 | } 90 | 91 | // HTTPBodyNotContains asserts that a specified handler returns a 92 | // body that does not contain a string. 93 | // 94 | // assert.HTTPBodyNotContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky") 95 | // 96 | // Returns whether the assertion was successful (true) or not (false). 97 | func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, str interface{}) bool { 98 | body := HTTPBody(handler, method, url, values) 99 | 100 | contains := strings.Contains(body, fmt.Sprint(str)) 101 | if contains { 102 | Fail(t, "Expected response body for %s to NOT contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body) 103 | } 104 | 105 | return !contains 106 | } 107 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/doc.go: -------------------------------------------------------------------------------- 1 | // Package require implements the same assertions as the `assert` package but 2 | // stops test execution when a test fails. 3 | // 4 | // Example Usage 5 | // 6 | // The following is a complete example using require in a standard test function: 7 | // import ( 8 | // "testing" 9 | // "github.com/stretchr/testify/require" 10 | // ) 11 | // 12 | // func TestSomething(t *testing.T) { 13 | // 14 | // var a string = "Hello" 15 | // var b string = "Hello" 16 | // 17 | // require.Equal(t, a, b, "The two words should be the same.") 18 | // 19 | // } 20 | // 21 | // Assertions 22 | // 23 | // The `require` package have same global functions as in the `assert` package, 24 | // but instead of returning a boolean result they call `t.FailNow()`. 25 | // 26 | // Every assertion function also takes an optional string message as the final argument, 27 | // allowing custom error messages to be appended to the message the assertion method outputs. 28 | package require 29 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/forward_requirements.go: -------------------------------------------------------------------------------- 1 | package require 2 | 3 | // Assertions provides assertion methods around the 4 | // TestingT interface. 5 | type Assertions struct { 6 | t TestingT 7 | } 8 | 9 | // New makes a new Assertions object for the specified TestingT. 10 | func New(t TestingT) *Assertions { 11 | return &Assertions{ 12 | t: t, 13 | } 14 | } 15 | 16 | //go:generate go run ../_codegen/main.go -output-package=require -template=require_forward.go.tmpl 17 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/require.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.Comment}} 2 | func {{.DocInfo.Name}}(t TestingT, {{.Params}}) { 3 | if !assert.{{.DocInfo.Name}}(t, {{.ForwardedParams}}) { 4 | t.FailNow() 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/require_forward.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.CommentWithoutT "a"}} 2 | func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) { 3 | {{.DocInfo.Name}}(a.t, {{.ForwardedParams}}) 4 | } 5 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/requirements.go: -------------------------------------------------------------------------------- 1 | package require 2 | 3 | // TestingT is an interface wrapper around *testing.T 4 | type TestingT interface { 5 | Errorf(format string, args ...interface{}) 6 | FailNow() 7 | } 8 | 9 | //go:generate go run ../_codegen/main.go -output-package=require -template=require.go.tmpl 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/.gitignore: -------------------------------------------------------------------------------- 1 | _obj/ 2 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm.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 | TEXT ·use(SB),NOSPLIT,$0 10 | RET 11 | -------------------------------------------------------------------------------- /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_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_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/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/asm_dragonfly_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-32 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-44 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-56 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-32 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-44 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/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_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_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_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 | // 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 ·RawSyscall(SB),NOSPLIT,$0-28 23 | JMP syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 26 | JMP syscall·RawSyscall6(SB) 27 | 28 | TEXT ·socketcall(SB),NOSPLIT,$0-36 29 | JMP syscall·socketcall(SB) 30 | 31 | TEXT ·rawsocketcall(SB),NOSPLIT,$0-36 32 | JMP syscall·rawsocketcall(SB) 33 | 34 | TEXT ·seek(SB),NOSPLIT,$0-28 35 | JMP syscall·seek(SB) 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_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 calls for AMD64, Linux 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 ·RawSyscall(SB),NOSPLIT,$0-56 23 | JMP syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 26 | JMP syscall·RawSyscall6(SB) 27 | 28 | TEXT ·gettimeofday(SB),NOSPLIT,$0-16 29 | JMP syscall·gettimeofday(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm.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 arm, Linux 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 ·RawSyscall(SB),NOSPLIT,$0-28 23 | B syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 26 | B syscall·RawSyscall6(SB) 27 | 28 | TEXT ·seek(SB),NOSPLIT,$0-32 29 | B syscall·seek(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_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 linux 6 | // +build arm64 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-56 15 | B syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 18 | B syscall·Syscall6(SB) 19 | 20 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 21 | B syscall·RawSyscall(SB) 22 | 23 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 24 | B syscall·RawSyscall6(SB) 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mips64x.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 linux 6 | // +build mips64 mips64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | JMP syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | JMP syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_ppc64x.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 linux 6 | // +build ppc64 ppc64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for ppc64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | BR syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | BR syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /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_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_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_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_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_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-64 14 | JMP syscall·sysvicall6(SB) 15 | 16 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-64 17 | JMP syscall·rawSysvicall6(SB) 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/constants.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | const ( 10 | R_OK = 0x4 11 | W_OK = 0x2 12 | X_OK = 0x1 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/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 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unset.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 go1.4 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | func Unsetenv(key string) error { 12 | // This was added in Go 1.4. 13 | return syscall.Unsetenv(key) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/flock.go: -------------------------------------------------------------------------------- 1 | // +build linux darwin freebsd openbsd netbsd dragonfly 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 | // +build darwin dragonfly freebsd linux netbsd openbsd 8 | 9 | package unix 10 | 11 | import "unsafe" 12 | 13 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux 14 | // systems by flock_linux_32bit.go to be SYS_FCNTL64. 15 | var fcntl64Syscall uintptr = SYS_FCNTL 16 | 17 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 18 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 19 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 20 | if errno == 0 { 21 | return nil 22 | } 23 | return errno 24 | } 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/flock_linux_32bit.go: -------------------------------------------------------------------------------- 1 | // +build linux,386 linux,arm 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/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 gccgoRealSyscall 15 | func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr) 16 | 17 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 18 | syscall.Entersyscall() 19 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 20 | syscall.Exitsyscall() 21 | return r, 0, syscall.Errno(errno) 22 | } 23 | 24 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 25 | syscall.Entersyscall() 26 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 27 | syscall.Exitsyscall() 28 | return r, 0, syscall.Errno(errno) 29 | } 30 | 31 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) { 32 | syscall.Entersyscall() 33 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9) 34 | syscall.Exitsyscall() 35 | return r, 0, syscall.Errno(errno) 36 | } 37 | 38 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 39 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 40 | return r, 0, syscall.Errno(errno) 41 | } 42 | 43 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 44 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 45 | return r, 0, syscall.Errno(errno) 46 | } 47 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_c.c: -------------------------------------------------------------------------------- 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 | #include 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 | // Define the use function in C so that it is not inlined. 35 | 36 | extern void use(void *) __asm__ (GOSYM_PREFIX GOPKGPATH ".use") __attribute__((noinline)); 37 | 38 | void 39 | use(void *p __attribute__ ((unused))) 40 | { 41 | } 42 | -------------------------------------------------------------------------------- /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/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 <){ 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 | if($name =~ /^SYS_CAP_+/ || $name =~ /^SYS___CAP_+/){ 44 | next 45 | } 46 | 47 | print " $name = $num; // $proto\n"; 48 | 49 | # We keep Capsicum syscall numbers for FreeBSD 50 | # 9-STABLE here because we are not sure whether they 51 | # are mature and stable. 52 | if($num == 513){ 53 | print " SYS_CAP_NEW = 514 // { int cap_new(int fd, uint64_t rights); }\n"; 54 | print " SYS_CAP_GETRIGHTS = 515 // { int cap_getrights(int fd, \\\n"; 55 | print " SYS_CAP_ENTER = 516 // { int cap_enter(void); }\n"; 56 | print " SYS_CAP_GETMODE = 517 // { int cap_getmode(u_int *modep); }\n"; 57 | } 58 | } 59 | } 60 | 61 | print < 999){ 29 | # ignore deprecated syscalls that are no longer implemented 30 | # https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/unistd.h?id=refs/heads/master#n716 31 | return; 32 | } 33 | $name =~ y/a-z/A-Z/; 34 | print " SYS_$name = $num;\n"; 35 | } 36 | 37 | my $prev; 38 | open(GCC, "gcc -E -dD $ARGV[0] |") || die "can't run gcc"; 39 | while(){ 40 | if(/^#define __NR_syscalls\s+/) { 41 | # ignore redefinitions of __NR_syscalls 42 | } 43 | elsif(/^#define __NR_(\w+)\s+([0-9]+)/){ 44 | $prev = $2; 45 | fmt($1, $2); 46 | } 47 | elsif(/^#define __NR3264_(\w+)\s+([0-9]+)/){ 48 | $prev = $2; 49 | fmt($1, $2); 50 | } 51 | elsif(/^#define __NR_(\w+)\s+\(\w+\+\s*([0-9]+)\)/){ 52 | fmt($1, $prev+$2) 53 | } 54 | } 55 | 56 | 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 '30' || $compat eq '50') { 51 | print " $name = $num; // $proto\n"; 52 | } 53 | } 54 | } 55 | 56 | 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 < len(b) { 66 | return nil, nil, EINVAL 67 | } 68 | return h, b[cmsgAlignOf(SizeofCmsghdr):h.Len], nil 69 | } 70 | 71 | // UnixRights encodes a set of open file descriptors into a socket 72 | // control message for sending to another process. 73 | func UnixRights(fds ...int) []byte { 74 | datalen := len(fds) * 4 75 | b := make([]byte, CmsgSpace(datalen)) 76 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 77 | h.Level = SOL_SOCKET 78 | h.Type = SCM_RIGHTS 79 | h.SetLen(CmsgLen(datalen)) 80 | data := cmsgData(h) 81 | for _, fd := range fds { 82 | *(*int32)(data) = int32(fd) 83 | data = unsafe.Pointer(uintptr(data) + 4) 84 | } 85 | return b 86 | } 87 | 88 | // ParseUnixRights decodes a socket control message that contains an 89 | // integer array of open file descriptors from another process. 90 | func ParseUnixRights(m *SocketControlMessage) ([]int, error) { 91 | if m.Header.Level != SOL_SOCKET { 92 | return nil, EINVAL 93 | } 94 | if m.Header.Type != SCM_RIGHTS { 95 | return nil, EINVAL 96 | } 97 | fds := make([]int, len(m.Data)>>2) 98 | for i, j := 0, 0; i < len(m.Data); i += 4 { 99 | fds[j] = int(*(*int32)(unsafe.Pointer(&m.Data[i]))) 100 | j++ 101 | } 102 | return fds, nil 103 | } 104 | -------------------------------------------------------------------------------- /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/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 23 | 24 | import "unsafe" 25 | 26 | // ByteSliceFromString returns a NUL-terminated slice of bytes 27 | // containing the text of s. If s contains a NUL byte at any 28 | // location, it returns (nil, EINVAL). 29 | func ByteSliceFromString(s string) ([]byte, error) { 30 | for i := 0; i < len(s); i++ { 31 | if s[i] == 0 { 32 | return nil, EINVAL 33 | } 34 | } 35 | a := make([]byte, len(s)+1) 36 | copy(a, s) 37 | return a, nil 38 | } 39 | 40 | // BytePtrFromString returns a pointer to a NUL-terminated array of 41 | // bytes containing the text of s. If s contains a NUL byte at any 42 | // location, it returns (nil, EINVAL). 43 | func BytePtrFromString(s string) (*byte, error) { 44 | a, err := ByteSliceFromString(s) 45 | if err != nil { 46 | return nil, err 47 | } 48 | return &a[0], nil 49 | } 50 | 51 | // Single-word zero for use when we need a valid pointer to 0 bytes. 52 | // See mkunix.pl. 53 | var _zero uintptr 54 | 55 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 56 | return int64(ts.Sec), int64(ts.Nsec) 57 | } 58 | 59 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 60 | return int64(tv.Sec), int64(tv.Usec) * 1000 61 | } 62 | 63 | func (ts *Timespec) Nano() int64 { 64 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 65 | } 66 | 67 | func (tv *Timeval) Nano() int64 { 68 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 69 | } 70 | 71 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 72 | 73 | // use is a no-op, but the compiler cannot see that it is. 74 | // Calling use(p) ensures that p is kept live until that point. 75 | //go:noescape 76 | func use(p unsafe.Pointer) 77 | -------------------------------------------------------------------------------- /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 Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int32(nsec / 1e9) 28 | return 29 | } 30 | 31 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 32 | func Gettimeofday(tv *Timeval) (err error) { 33 | // The tv passed to gettimeofday must be non-nil 34 | // but is otherwise unused. The answers come back 35 | // in the two registers. 36 | sec, usec, err := gettimeofday(tv) 37 | tv.Sec = int32(sec) 38 | tv.Usec = int32(usec) 39 | return err 40 | } 41 | 42 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 43 | k.Ident = uint32(fd) 44 | k.Filter = int16(mode) 45 | k.Flags = uint16(flags) 46 | } 47 | 48 | func (iov *Iovec) SetLen(length int) { 49 | iov.Len = uint32(length) 50 | } 51 | 52 | func (msghdr *Msghdr) SetControllen(length int) { 53 | msghdr.Controllen = uint32(length) 54 | } 55 | 56 | func (cmsg *Cmsghdr) SetLen(length int) { 57 | cmsg.Len = uint32(length) 58 | } 59 | 60 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 61 | var length = uint64(count) 62 | 63 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 64 | 65 | written = int(length) 66 | 67 | if e1 != 0 { 68 | err = e1 69 | } 70 | return 71 | } 72 | 73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 74 | 75 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 76 | // of darwin/386 the syscall is called sysctl instead of __sysctl. 77 | const SYS___SYSCTL = SYS_SYSCTL 78 | -------------------------------------------------------------------------------- /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 | //sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) 15 | 16 | func Getpagesize() int { return 4096 } 17 | 18 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 19 | 20 | func NsecToTimespec(nsec int64) (ts Timespec) { 21 | ts.Sec = nsec / 1e9 22 | ts.Nsec = nsec % 1e9 23 | return 24 | } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = int32(nsec % 1e9 / 1e3) 29 | tv.Sec = int64(nsec / 1e9) 30 | return 31 | } 32 | 33 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 34 | func Gettimeofday(tv *Timeval) (err error) { 35 | // The tv passed to gettimeofday must be non-nil 36 | // but is otherwise unused. The answers come back 37 | // in the two registers. 38 | sec, usec, err := gettimeofday(tv) 39 | tv.Sec = sec 40 | tv.Usec = usec 41 | return err 42 | } 43 | 44 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 45 | k.Ident = uint64(fd) 46 | k.Filter = int16(mode) 47 | k.Flags = uint16(flags) 48 | } 49 | 50 | func (iov *Iovec) SetLen(length int) { 51 | iov.Len = uint64(length) 52 | } 53 | 54 | func (msghdr *Msghdr) SetControllen(length int) { 55 | msghdr.Controllen = uint32(length) 56 | } 57 | 58 | func (cmsg *Cmsghdr) SetLen(length int) { 59 | cmsg.Len = uint32(length) 60 | } 61 | 62 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 63 | var length = uint64(count) 64 | 65 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 66 | 67 | written = int(length) 68 | 69 | if e1 != 0 { 70 | err = e1 71 | } 72 | return 73 | } 74 | 75 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 76 | 77 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 78 | // of darwin/amd64 the syscall is called sysctl instead of __sysctl. 79 | const SYS___SYSCTL = SYS_SYSCTL 80 | -------------------------------------------------------------------------------- /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 Getpagesize() int { return 4096 } 13 | 14 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 15 | 16 | func NsecToTimespec(nsec int64) (ts Timespec) { 17 | ts.Sec = int32(nsec / 1e9) 18 | ts.Nsec = int32(nsec % 1e9) 19 | return 20 | } 21 | 22 | func NsecToTimeval(nsec int64) (tv Timeval) { 23 | nsec += 999 // round up to microsecond 24 | tv.Usec = int32(nsec % 1e9 / 1e3) 25 | tv.Sec = int32(nsec / 1e9) 26 | return 27 | } 28 | 29 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 30 | func Gettimeofday(tv *Timeval) (err error) { 31 | // The tv passed to gettimeofday must be non-nil 32 | // but is otherwise unused. The answers come back 33 | // in the two registers. 34 | sec, usec, err := gettimeofday(tv) 35 | tv.Sec = int32(sec) 36 | tv.Usec = int32(usec) 37 | return err 38 | } 39 | 40 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 41 | k.Ident = uint32(fd) 42 | k.Filter = int16(mode) 43 | k.Flags = uint16(flags) 44 | } 45 | 46 | func (iov *Iovec) SetLen(length int) { 47 | iov.Len = uint32(length) 48 | } 49 | 50 | func (msghdr *Msghdr) SetControllen(length int) { 51 | msghdr.Controllen = uint32(length) 52 | } 53 | 54 | func (cmsg *Cmsghdr) SetLen(length int) { 55 | cmsg.Len = uint32(length) 56 | } 57 | 58 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 59 | var length = uint64(count) 60 | 61 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 62 | 63 | written = int(length) 64 | 65 | if e1 != 0 { 66 | err = e1 67 | } 68 | return 69 | } 70 | 71 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 72 | -------------------------------------------------------------------------------- /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 Getpagesize() int { return 16384 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 32 | func Gettimeofday(tv *Timeval) (err error) { 33 | // The tv passed to gettimeofday must be non-nil 34 | // but is otherwise unused. The answers come back 35 | // in the two registers. 36 | sec, usec, err := gettimeofday(tv) 37 | tv.Sec = sec 38 | tv.Usec = usec 39 | return err 40 | } 41 | 42 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 43 | k.Ident = uint64(fd) 44 | k.Filter = int16(mode) 45 | k.Flags = uint16(flags) 46 | } 47 | 48 | func (iov *Iovec) SetLen(length int) { 49 | iov.Len = uint64(length) 50 | } 51 | 52 | func (msghdr *Msghdr) SetControllen(length int) { 53 | msghdr.Controllen = uint32(length) 54 | } 55 | 56 | func (cmsg *Cmsghdr) SetLen(length int) { 57 | cmsg.Len = uint32(length) 58 | } 59 | 60 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 61 | var length = uint64(count) 62 | 63 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 64 | 65 | written = int(length) 66 | 67 | if e1 != 0 { 68 | err = e1 69 | } 70 | return 71 | } 72 | 73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 74 | 75 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 76 | // of darwin/arm64 the syscall is called sysctl instead of __sysctl. 77 | const SYS___SYSCTL = SYS_SYSCTL 78 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_dragonfly_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,dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int32(nsec / 1e9) 28 | return 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 writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_dragonfly_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,dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = nsec % 1e9 / 1e3 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint64(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint64(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 writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /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 Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int32(nsec / 1e9) 28 | return 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 writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_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,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = nsec % 1e9 / 1e3 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint64(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint64(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 writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /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 Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return ts.Sec*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = nsec / 1e9 28 | return 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 writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /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 | import "syscall" 10 | 11 | //sys Dup2(oldfd int, newfd int) (err error) 12 | //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 13 | //sys Fchown(fd int, uid int, gid int) (err error) 14 | //sys Fstat(fd int, stat *Stat_t) (err error) 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 Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 29 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 30 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK 31 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) 32 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) 33 | //sys Setfsgid(gid int) (err error) 34 | //sys Setfsuid(uid int) (err error) 35 | //sysnb Setregid(rgid int, egid int) (err error) 36 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error) 37 | //sysnb Setresuid(ruid int, euid int, suid int) (err error) 38 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 39 | //sysnb Setreuid(ruid int, euid int) (err error) 40 | //sys Shutdown(fd int, how int) (err error) 41 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) 42 | //sys Stat(path string, stat *Stat_t) (err error) 43 | //sys Statfs(path string, buf *Statfs_t) (err error) 44 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) 45 | //sys Truncate(path string, length int64) (err error) 46 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 47 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 48 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 49 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 50 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) 51 | //sysnb setgroups(n int, list *_Gid_t) (err error) 52 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 53 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 54 | //sysnb socket(domain int, typ int, proto int) (fd int, err error) 55 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) 56 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 57 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 58 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 59 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 60 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 61 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 62 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 63 | 64 | //go:noescape 65 | func gettimeofday(tv *Timeval) (err syscall.Errno) 66 | 67 | func Gettimeofday(tv *Timeval) (err error) { 68 | errno := gettimeofday(tv) 69 | if errno != 0 { 70 | return errno 71 | } 72 | return nil 73 | } 74 | 75 | func Getpagesize() int { return 4096 } 76 | 77 | func Time(t *Time_t) (tt Time_t, err error) { 78 | var tv Timeval 79 | errno := gettimeofday(&tv) 80 | if errno != 0 { 81 | return 0, errno 82 | } 83 | if t != nil { 84 | *t = Time_t(tv.Sec) 85 | } 86 | return Time_t(tv.Sec), nil 87 | } 88 | 89 | //sys Utime(path string, buf *Utimbuf) (err error) 90 | 91 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 92 | 93 | func NsecToTimespec(nsec int64) (ts Timespec) { 94 | ts.Sec = nsec / 1e9 95 | ts.Nsec = nsec % 1e9 96 | return 97 | } 98 | 99 | func NsecToTimeval(nsec int64) (tv Timeval) { 100 | nsec += 999 // round up to microsecond 101 | tv.Sec = nsec / 1e9 102 | tv.Usec = nsec % 1e9 / 1e3 103 | return 104 | } 105 | 106 | //sysnb pipe(p *[2]_C_int) (err error) 107 | 108 | func Pipe(p []int) (err error) { 109 | if len(p) != 2 { 110 | return EINVAL 111 | } 112 | var pp [2]_C_int 113 | err = pipe(&pp) 114 | p[0] = int(pp[0]) 115 | p[1] = int(pp[1]) 116 | return 117 | } 118 | 119 | //sysnb pipe2(p *[2]_C_int, flags int) (err error) 120 | 121 | func Pipe2(p []int, flags int) (err error) { 122 | if len(p) != 2 { 123 | return EINVAL 124 | } 125 | var pp [2]_C_int 126 | err = pipe2(&pp, flags) 127 | p[0] = int(pp[0]) 128 | p[1] = int(pp[1]) 129 | return 130 | } 131 | 132 | func (r *PtraceRegs) PC() uint64 { return r.Rip } 133 | 134 | func (r *PtraceRegs) SetPC(pc uint64) { r.Rip = pc } 135 | 136 | func (iov *Iovec) SetLen(length int) { 137 | iov.Len = uint64(length) 138 | } 139 | 140 | func (msghdr *Msghdr) SetControllen(length int) { 141 | msghdr.Controllen = uint64(length) 142 | } 143 | 144 | func (cmsg *Cmsghdr) SetLen(length int) { 145 | cmsg.Len = uint64(length) 146 | } 147 | -------------------------------------------------------------------------------- /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 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 Fstatfs(fd int, buf *Statfs_t) (err error) 14 | //sys Ftruncate(fd int, length int64) (err error) 15 | //sysnb Getegid() (egid int) 16 | //sysnb Geteuid() (euid int) 17 | //sysnb Getgid() (gid int) 18 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = SYS_UGETRLIMIT 19 | //sysnb Getuid() (uid int) 20 | //sys Ioperm(from int, num int, on int) (err error) 21 | //sys Iopl(level 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 Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 26 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 27 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK 28 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) 29 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) 30 | //sys Setfsgid(gid int) (err error) 31 | //sys Setfsuid(uid int) (err error) 32 | //sysnb Setregid(rgid int, egid int) (err error) 33 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error) 34 | //sysnb Setresuid(ruid int, euid int, suid int) (err error) 35 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 36 | //sysnb Setreuid(ruid int, euid int) (err error) 37 | //sys Shutdown(fd int, how int) (err error) 38 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) 39 | //sys Stat(path string, stat *Stat_t) (err error) 40 | //sys Statfs(path string, buf *Statfs_t) (err error) 41 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) = SYS_SYNC_FILE_RANGE2 42 | //sys Truncate(path string, length int64) (err error) 43 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 44 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 45 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 46 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 47 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) 48 | //sysnb setgroups(n int, list *_Gid_t) (err error) 49 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 50 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 51 | //sysnb socket(domain int, typ int, proto int) (fd int, err error) 52 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) 53 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 54 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 55 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 56 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 57 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 58 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 59 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 60 | 61 | func Getpagesize() int { return 65536 } 62 | 63 | //sysnb Gettimeofday(tv *Timeval) (err error) 64 | //sysnb Time(t *Time_t) (tt Time_t, err error) 65 | 66 | //sys Utime(path string, buf *Utimbuf) (err error) 67 | 68 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 69 | 70 | func NsecToTimespec(nsec int64) (ts Timespec) { 71 | ts.Sec = nsec / 1e9 72 | ts.Nsec = nsec % 1e9 73 | return 74 | } 75 | 76 | func NsecToTimeval(nsec int64) (tv Timeval) { 77 | nsec += 999 // round up to microsecond 78 | tv.Sec = nsec / 1e9 79 | tv.Usec = nsec % 1e9 / 1e3 80 | return 81 | } 82 | 83 | func (r *PtraceRegs) PC() uint64 { return r.Nip } 84 | 85 | func (r *PtraceRegs) SetPC(pc uint64) { r.Nip = pc } 86 | 87 | func (iov *Iovec) SetLen(length int) { 88 | iov.Len = uint64(length) 89 | } 90 | 91 | func (msghdr *Msghdr) SetControllen(length int) { 92 | msghdr.Controllen = uint64(length) 93 | } 94 | 95 | func (cmsg *Cmsghdr) SetLen(length int) { 96 | cmsg.Len = uint64(length) 97 | } 98 | -------------------------------------------------------------------------------- /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 Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /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 Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int64(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint64(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint64(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /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 Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_no_getwd.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 dragonfly freebsd netbsd openbsd 6 | 7 | package unix 8 | 9 | const ImplementsGetwd = false 10 | 11 | func Getwd() (string, error) { return "", ENOTSUP } 12 | -------------------------------------------------------------------------------- /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 Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = int16(mode) 29 | k.Flags = uint16(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /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 Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = nsec / 1e9 15 | ts.Nsec = nsec % 1e9 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = nsec % 1e9 / 1e3 22 | tv.Sec = nsec / 1e9 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint64(fd) 28 | k.Filter = int16(mode) 29 | k.Flags = uint16(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint64(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /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 TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 10 | 11 | func NsecToTimespec(nsec int64) (ts Timespec) { 12 | ts.Sec = nsec / 1e9 13 | ts.Nsec = nsec % 1e9 14 | return 15 | } 16 | 17 | func NsecToTimeval(nsec int64) (tv Timeval) { 18 | nsec += 999 // round up to microsecond 19 | tv.Usec = nsec % 1e9 / 1e3 20 | tv.Sec = int64(nsec / 1e9) 21 | return 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (cmsg *Cmsghdr) SetLen(length int) { 29 | cmsg.Len = uint32(length) 30 | } 31 | 32 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 33 | // TODO(aram): implement this, see issue 5847. 34 | panic("unimplemented") 35 | } 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/types_netbsd.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 ignore 6 | 7 | /* 8 | Input to cgo -godefs. See also mkerrors.sh and mkall.sh 9 | */ 10 | 11 | // +godefs map struct_in_addr [4]byte /* in_addr */ 12 | // +godefs map struct_in6_addr [16]byte /* in6_addr */ 13 | 14 | package unix 15 | 16 | /* 17 | #define KERNEL 18 | #include 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 | 48 | enum { 49 | sizeofPtr = sizeof(void*), 50 | }; 51 | 52 | union sockaddr_all { 53 | struct sockaddr s1; // this one gets used for fields 54 | struct sockaddr_in s2; // these pad it out 55 | struct sockaddr_in6 s3; 56 | struct sockaddr_un s4; 57 | struct sockaddr_dl s5; 58 | }; 59 | 60 | struct sockaddr_any { 61 | struct sockaddr addr; 62 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; 63 | }; 64 | 65 | */ 66 | import "C" 67 | 68 | // Machine characteristics; for internal use. 69 | 70 | const ( 71 | sizeofPtr = C.sizeofPtr 72 | sizeofShort = C.sizeof_short 73 | sizeofInt = C.sizeof_int 74 | sizeofLong = C.sizeof_long 75 | sizeofLongLong = C.sizeof_longlong 76 | ) 77 | 78 | // Basic types 79 | 80 | type ( 81 | _C_short C.short 82 | _C_int C.int 83 | _C_long C.long 84 | _C_long_long C.longlong 85 | ) 86 | 87 | // Time 88 | 89 | type Timespec C.struct_timespec 90 | 91 | type Timeval C.struct_timeval 92 | 93 | // Processes 94 | 95 | type Rusage C.struct_rusage 96 | 97 | type Rlimit C.struct_rlimit 98 | 99 | type _Gid_t C.gid_t 100 | 101 | // Files 102 | 103 | type Stat_t C.struct_stat 104 | 105 | type Statfs_t C.struct_statfs 106 | 107 | type Flock_t C.struct_flock 108 | 109 | type Dirent C.struct_dirent 110 | 111 | type Fsid C.fsid_t 112 | 113 | // Sockets 114 | 115 | type RawSockaddrInet4 C.struct_sockaddr_in 116 | 117 | type RawSockaddrInet6 C.struct_sockaddr_in6 118 | 119 | type RawSockaddrUnix C.struct_sockaddr_un 120 | 121 | type RawSockaddrDatalink C.struct_sockaddr_dl 122 | 123 | type RawSockaddr C.struct_sockaddr 124 | 125 | type RawSockaddrAny C.struct_sockaddr_any 126 | 127 | type _Socklen C.socklen_t 128 | 129 | type Linger C.struct_linger 130 | 131 | type Iovec C.struct_iovec 132 | 133 | type IPMreq C.struct_ip_mreq 134 | 135 | type IPv6Mreq C.struct_ipv6_mreq 136 | 137 | type Msghdr C.struct_msghdr 138 | 139 | type Cmsghdr C.struct_cmsghdr 140 | 141 | type Inet6Pktinfo C.struct_in6_pktinfo 142 | 143 | type IPv6MTUInfo C.struct_ip6_mtuinfo 144 | 145 | type ICMPv6Filter C.struct_icmp6_filter 146 | 147 | const ( 148 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in 149 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 150 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any 151 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un 152 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl 153 | SizeofLinger = C.sizeof_struct_linger 154 | SizeofIPMreq = C.sizeof_struct_ip_mreq 155 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq 156 | SizeofMsghdr = C.sizeof_struct_msghdr 157 | SizeofCmsghdr = C.sizeof_struct_cmsghdr 158 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo 159 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo 160 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter 161 | ) 162 | 163 | // Ptrace requests 164 | 165 | const ( 166 | PTRACE_TRACEME = C.PT_TRACE_ME 167 | PTRACE_CONT = C.PT_CONTINUE 168 | PTRACE_KILL = C.PT_KILL 169 | ) 170 | 171 | // Events (kqueue, kevent) 172 | 173 | type Kevent_t C.struct_kevent 174 | 175 | // Select 176 | 177 | type FdSet C.fd_set 178 | 179 | // Routing and interface messages 180 | 181 | const ( 182 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr 183 | SizeofIfData = C.sizeof_struct_if_data 184 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr 185 | SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr 186 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr 187 | SizeofRtMetrics = C.sizeof_struct_rt_metrics 188 | ) 189 | 190 | type IfMsghdr C.struct_if_msghdr 191 | 192 | type IfData C.struct_if_data 193 | 194 | type IfaMsghdr C.struct_ifa_msghdr 195 | 196 | type IfAnnounceMsghdr C.struct_if_announcemsghdr 197 | 198 | type RtMsghdr C.struct_rt_msghdr 199 | 200 | type RtMetrics C.struct_rt_metrics 201 | 202 | type Mclpool C.struct_mclpool 203 | 204 | // Berkeley packet filter 205 | 206 | const ( 207 | SizeofBpfVersion = C.sizeof_struct_bpf_version 208 | SizeofBpfStat = C.sizeof_struct_bpf_stat 209 | SizeofBpfProgram = C.sizeof_struct_bpf_program 210 | SizeofBpfInsn = C.sizeof_struct_bpf_insn 211 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr 212 | ) 213 | 214 | type BpfVersion C.struct_bpf_version 215 | 216 | type BpfStat C.struct_bpf_stat 217 | 218 | type BpfProgram C.struct_bpf_program 219 | 220 | type BpfInsn C.struct_bpf_insn 221 | 222 | type BpfHdr C.struct_bpf_hdr 223 | 224 | type BpfTimeval C.struct_bpf_timeval 225 | 226 | // Terminal handling 227 | 228 | type Termios C.struct_termios 229 | 230 | // Sysctl 231 | 232 | type Sysctlnode C.struct_sysctlnode 233 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zsysnum_solaris_amd64.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 amd64,solaris 6 | 7 | package unix 8 | 9 | // TODO(aram): remove these before Go 1.3. 10 | const ( 11 | SYS_EXECVE = 59 12 | SYS_FCNTL = 62 13 | ) 14 | --------------------------------------------------------------------------------