├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── cli.go ├── cmd ├── build │ └── build.go ├── clean │ └── clean.go ├── cmd.go ├── commands │ └── commands.go ├── complete │ └── complete.go ├── install │ └── install.go ├── lint │ └── lint.go ├── list │ └── list.go ├── test │ └── test.go └── version │ └── version.go ├── lib ├── buildflags │ ├── buildflags.go │ ├── stringsflag.go │ └── testflags.go ├── dag │ ├── functions.go │ ├── functions_test.go │ ├── graph.go │ └── graph_test.go ├── dependency │ ├── dependency.go │ ├── file.go │ ├── gofile.go │ ├── gogeneratefile.go │ ├── gopackage.go │ └── target.go ├── ellipsis │ └── ellipsis.go ├── lintflags │ ├── lintflags.go │ └── sortkey.go ├── project │ ├── list.go │ ├── package.go │ ├── packages.go │ ├── project.go │ └── projects.go ├── zbcontext │ └── zbcontext.go ├── zblint │ └── zblint.go └── zbtest │ └── zbtest.go ├── main.go ├── vendor ├── github.com │ ├── pkg │ │ └── errors │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── appveyor.yml │ │ │ ├── errors.go │ │ │ └── stack.go │ ├── sergi │ │ └── go-diff │ │ │ ├── LICENSE │ │ │ └── diffmatchpatch │ │ │ ├── diff.go │ │ │ ├── diffmatchpatch.go │ │ │ ├── match.go │ │ │ ├── mathutil.go │ │ │ ├── patch.go │ │ │ └── stringutil.go │ ├── src-d │ │ └── gcfg │ │ │ ├── LICENSE │ │ │ ├── README │ │ │ ├── doc.go │ │ │ ├── errors.go │ │ │ ├── go1_0.go │ │ │ ├── go1_2.go │ │ │ ├── read.go │ │ │ ├── scanner │ │ │ ├── errors.go │ │ │ └── scanner.go │ │ │ ├── set.go │ │ │ ├── token │ │ │ ├── position.go │ │ │ ├── serialize.go │ │ │ └── token.go │ │ │ └── types │ │ │ ├── bool.go │ │ │ ├── doc.go │ │ │ ├── enum.go │ │ │ ├── int.go │ │ │ └── scan.go │ └── urfave │ │ └── cli │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── app.go │ │ ├── appveyor.yml │ │ ├── category.go │ │ ├── cli.go │ │ ├── command.go │ │ ├── context.go │ │ ├── errors.go │ │ ├── flag-types.json │ │ ├── flag.go │ │ ├── flag_generated.go │ │ ├── funcs.go │ │ ├── generate-flag-types │ │ ├── help.go │ │ └── runtests ├── golang.org │ └── x │ │ ├── crypto │ │ ├── LICENSE │ │ ├── PATENTS │ │ ├── curve25519 │ │ │ ├── const_amd64.h │ │ │ ├── const_amd64.s │ │ │ ├── cswap_amd64.s │ │ │ ├── curve25519.go │ │ │ ├── doc.go │ │ │ ├── freeze_amd64.s │ │ │ ├── ladderstep_amd64.s │ │ │ ├── mont25519_amd64.go │ │ │ ├── mul_amd64.s │ │ │ └── square_amd64.s │ │ ├── ed25519 │ │ │ ├── ed25519.go │ │ │ └── internal │ │ │ │ └── edwards25519 │ │ │ │ ├── const.go │ │ │ │ └── edwards25519.go │ │ └── ssh │ │ │ ├── agent │ │ │ ├── client.go │ │ │ ├── forward.go │ │ │ ├── keyring.go │ │ │ └── server.go │ │ │ ├── buffer.go │ │ │ ├── certs.go │ │ │ ├── channel.go │ │ │ ├── cipher.go │ │ │ ├── client.go │ │ │ ├── client_auth.go │ │ │ ├── common.go │ │ │ ├── connection.go │ │ │ ├── doc.go │ │ │ ├── handshake.go │ │ │ ├── kex.go │ │ │ ├── keys.go │ │ │ ├── mac.go │ │ │ ├── messages.go │ │ │ ├── mux.go │ │ │ ├── server.go │ │ │ ├── session.go │ │ │ ├── streamlocal.go │ │ │ ├── tcpip.go │ │ │ └── transport.go │ │ ├── net │ │ ├── LICENSE │ │ ├── PATENTS │ │ └── context │ │ │ ├── context.go │ │ │ ├── go17.go │ │ │ └── pre_go17.go │ │ ├── sync │ │ ├── LICENSE │ │ ├── PATENTS │ │ └── errgroup │ │ │ └── errgroup.go │ │ └── sys │ │ ├── LICENSE │ │ ├── PATENTS │ │ └── unix │ │ ├── README.md │ │ ├── asm_darwin_386.s │ │ ├── asm_darwin_amd64.s │ │ ├── asm_darwin_arm.s │ │ ├── asm_darwin_arm64.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_mipsx.s │ │ ├── asm_linux_ppc64x.s │ │ ├── asm_linux_s390x.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 │ │ ├── bluetooth_linux.go │ │ ├── constants.go │ │ ├── dirent.go │ │ ├── endian_big.go │ │ ├── endian_little.go │ │ ├── env_unix.go │ │ ├── env_unset.go │ │ ├── flock.go │ │ ├── flock_linux_32bit.go │ │ ├── gccgo.go │ │ ├── gccgo_c.c │ │ ├── gccgo_linux_amd64.go │ │ ├── gccgo_linux_sparc64.go │ │ ├── mkall.sh │ │ ├── mkerrors.sh │ │ ├── mkpost.go │ │ ├── mksyscall.pl │ │ ├── mksyscall_solaris.pl │ │ ├── mksysctl_openbsd.pl │ │ ├── mksysnum_darwin.pl │ │ ├── mksysnum_dragonfly.pl │ │ ├── mksysnum_freebsd.pl │ │ ├── mksysnum_netbsd.pl │ │ ├── mksysnum_openbsd.pl │ │ ├── openbsd_pledge.go │ │ ├── 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_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_amd64_gc.go │ │ ├── syscall_linux_arm.go │ │ ├── syscall_linux_arm64.go │ │ ├── syscall_linux_mips64x.go │ │ ├── syscall_linux_mipsx.go │ │ ├── syscall_linux_ppc64x.go │ │ ├── syscall_linux_s390x.go │ │ ├── syscall_linux_sparc64.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 │ │ ├── syscall_unix_gc.go │ │ ├── types_darwin.go │ │ ├── types_dragonfly.go │ │ ├── types_freebsd.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_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_mips.go │ │ ├── zerrors_linux_mips64.go │ │ ├── zerrors_linux_mips64le.go │ │ ├── zerrors_linux_mipsle.go │ │ ├── zerrors_linux_ppc64.go │ │ ├── zerrors_linux_ppc64le.go │ │ ├── zerrors_linux_s390x.go │ │ ├── zerrors_linux_sparc64.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_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_mips.go │ │ ├── zsyscall_linux_mips64.go │ │ ├── zsyscall_linux_mips64le.go │ │ ├── zsyscall_linux_mipsle.go │ │ ├── zsyscall_linux_ppc64.go │ │ ├── zsyscall_linux_ppc64le.go │ │ ├── zsyscall_linux_s390x.go │ │ ├── zsyscall_linux_sparc64.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_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_mips.go │ │ ├── zsysnum_linux_mips64.go │ │ ├── zsysnum_linux_mips64le.go │ │ ├── zsysnum_linux_mipsle.go │ │ ├── zsysnum_linux_ppc64.go │ │ ├── zsysnum_linux_ppc64le.go │ │ ├── zsysnum_linux_s390x.go │ │ ├── zsysnum_linux_sparc64.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_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_mips.go │ │ ├── ztypes_linux_mips64.go │ │ ├── ztypes_linux_mips64le.go │ │ ├── ztypes_linux_mipsle.go │ │ ├── ztypes_linux_ppc64.go │ │ ├── ztypes_linux_ppc64le.go │ │ ├── ztypes_linux_s390x.go │ │ ├── ztypes_linux_sparc64.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 ├── gopkg.in │ └── warnings.v0 │ │ ├── LICENSE │ │ ├── README │ │ └── warnings.go ├── jrubin.io │ └── slog │ │ ├── LICENSE │ │ ├── Readme.md │ │ ├── entry.go │ │ ├── handlers │ │ └── text │ │ │ ├── terminal_bsd.go │ │ │ ├── terminal_linux.go │ │ │ ├── terminal_notwindows.go │ │ │ ├── terminal_solaris.go │ │ │ ├── terminal_windows.go │ │ │ └── text.go │ │ ├── import.go │ │ ├── interface.go │ │ ├── levels.go │ │ ├── logger.go │ │ └── writer.go ├── srcd.works │ ├── go-billy.v1 │ │ ├── LICENSE │ │ ├── README.md │ │ ├── fs.go │ │ └── osfs │ │ │ └── os.go │ └── go-git.v4 │ │ ├── LICENSE │ │ ├── Makefile │ │ ├── README.md │ │ ├── blame.go │ │ ├── cache │ │ ├── common.go │ │ ├── object.go │ │ └── queue.go │ │ ├── common.go │ │ ├── config │ │ ├── config.go │ │ ├── modules.go │ │ └── refspec.go │ │ ├── doc.go │ │ ├── options.go │ │ ├── plumbing │ │ ├── error.go │ │ ├── format │ │ │ ├── config │ │ │ │ ├── common.go │ │ │ │ ├── decoder.go │ │ │ │ ├── doc.go │ │ │ │ ├── encoder.go │ │ │ │ ├── option.go │ │ │ │ └── section.go │ │ │ ├── idxfile │ │ │ │ ├── decoder.go │ │ │ │ ├── doc.go │ │ │ │ ├── encoder.go │ │ │ │ └── idxfile.go │ │ │ ├── index │ │ │ │ ├── decoder.go │ │ │ │ ├── doc.go │ │ │ │ ├── encoder.go │ │ │ │ └── index.go │ │ │ ├── objfile │ │ │ │ ├── reader.go │ │ │ │ └── writer.go │ │ │ ├── packfile │ │ │ │ ├── common.go │ │ │ │ ├── decoder.go │ │ │ │ ├── delta_selector.go │ │ │ │ ├── diff.go │ │ │ │ ├── diff_delta.go │ │ │ │ ├── doc.go │ │ │ │ ├── encoder.go │ │ │ │ ├── error.go │ │ │ │ ├── object_pack.go │ │ │ │ ├── patch_delta.go │ │ │ │ └── scanner.go │ │ │ └── pktline │ │ │ │ ├── encoder.go │ │ │ │ └── scanner.go │ │ ├── hash.go │ │ ├── memory.go │ │ ├── object.go │ │ ├── object │ │ │ ├── blob.go │ │ │ ├── commit.go │ │ │ ├── commit_walker.go │ │ │ ├── file.go │ │ │ ├── object.go │ │ │ ├── tag.go │ │ │ └── tree.go │ │ ├── protocol │ │ │ └── packp │ │ │ │ ├── advrefs.go │ │ │ │ ├── advrefs_decode.go │ │ │ │ ├── advrefs_encode.go │ │ │ │ ├── capability │ │ │ │ ├── capability.go │ │ │ │ └── list.go │ │ │ │ ├── common.go │ │ │ │ ├── doc.go │ │ │ │ ├── report_status.go │ │ │ │ ├── shallowupd.go │ │ │ │ ├── sideband │ │ │ │ ├── common.go │ │ │ │ ├── demux.go │ │ │ │ ├── doc.go │ │ │ │ └── muxer.go │ │ │ │ ├── srvresp.go │ │ │ │ ├── ulreq.go │ │ │ │ ├── ulreq_decode.go │ │ │ │ ├── ulreq_encode.go │ │ │ │ ├── updreq.go │ │ │ │ ├── updreq_decode.go │ │ │ │ ├── updreq_encode.go │ │ │ │ ├── uppackreq.go │ │ │ │ └── uppackresp.go │ │ ├── reference.go │ │ ├── revlist │ │ │ └── revlist.go │ │ ├── storer │ │ │ ├── index.go │ │ │ ├── object.go │ │ │ ├── reference.go │ │ │ ├── shallow.go │ │ │ └── storer.go │ │ └── transport │ │ │ ├── client │ │ │ └── client.go │ │ │ ├── common.go │ │ │ ├── file │ │ │ ├── client.go │ │ │ └── server.go │ │ │ ├── git │ │ │ └── common.go │ │ │ ├── http │ │ │ ├── common.go │ │ │ ├── receive_pack.go │ │ │ └── upload_pack.go │ │ │ ├── internal │ │ │ └── common │ │ │ │ ├── common.go │ │ │ │ └── server.go │ │ │ ├── server │ │ │ ├── loader.go │ │ │ └── server.go │ │ │ └── ssh │ │ │ ├── auth_method.go │ │ │ └── common.go │ │ ├── references.go │ │ ├── remote.go │ │ ├── repository.go │ │ ├── storage │ │ ├── filesystem │ │ │ ├── config.go │ │ │ ├── index.go │ │ │ ├── internal │ │ │ │ └── dotgit │ │ │ │ │ ├── dotgit.go │ │ │ │ │ └── writers.go │ │ │ ├── object.go │ │ │ ├── reference.go │ │ │ ├── shallow.go │ │ │ └── storage.go │ │ └── memory │ │ │ └── storage.go │ │ ├── utils │ │ ├── binary │ │ │ ├── read.go │ │ │ └── write.go │ │ ├── diff │ │ │ └── diff.go │ │ └── ioutil │ │ │ └── common.go │ │ ├── worktree.go │ │ ├── worktree_darwin.go │ │ └── worktree_linux.go └── vendor.json └── wrap.go /.gitignore: -------------------------------------------------------------------------------- 1 | /zb 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Joshua Rubin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | GOVENDOR ?= govendor 2 | 3 | save: 4 | $(GOVENDOR) init 5 | $(GOVENDOR) remove +unused 6 | GOOS=linux GOARCH=amd64 $(GOVENDOR) update +vendor 7 | GOOS=linux GOARCH=amd64 $(GOVENDOR) add +external,^program 8 | .PHONY: save 9 | -------------------------------------------------------------------------------- /cli.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/urfave/cli" 5 | "jrubin.io/slog" 6 | ) 7 | 8 | func init() { 9 | cli.ErrWriter = ctx.Logger.Writer(slog.ErrorLevel) 10 | 11 | cli.BashCompletionFlag = cli.BoolFlag{ 12 | Name: "compgen", 13 | Hidden: true, 14 | } 15 | 16 | cli.CommandHelpTemplate = `NAME: 17 | {{.HelpName}} - {{.Usage}} 18 | 19 | USAGE: 20 | {{.HelpName}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{if .Category}} 21 | 22 | CATEGORY: 23 | {{.Category}}{{end}}{{if .Description}} 24 | 25 | DESCRIPTION: 26 | {{.Description}}{{end}}{{if .VisibleFlags}} 27 | 28 | OPTIONS: 29 | {{range .VisibleFlags}}{{.}} 30 | {{end}}{{end}} 31 | ` 32 | } 33 | -------------------------------------------------------------------------------- /cmd/build/build.go: -------------------------------------------------------------------------------- 1 | package build 2 | 3 | import ( 4 | "github.com/urfave/cli" 5 | "jrubin.io/zb/cmd" 6 | "jrubin.io/zb/cmd/install" 7 | "jrubin.io/zb/lib/buildflags" 8 | "jrubin.io/zb/lib/dependency" 9 | ) 10 | 11 | // Cmd is the build command 12 | var Cmd cmd.Constructor = &cc{} 13 | 14 | type cc struct { 15 | buildflags.Data 16 | } 17 | 18 | func (co *cc) New(*cli.App) cli.Command { 19 | return cli.Command{ 20 | Name: "build", 21 | Usage: "build all of the packages in each of the projects", 22 | ArgsUsage: "[build flags] [packages]", 23 | Action: func(c *cli.Context) error { 24 | ctx := cmd.Context(c) 25 | ctx.BuildContext = co.Data.BuildContext() 26 | ctx.BuildArger = co 27 | return install.Run(ctx, dependency.TargetBuild, c.Args()...) 28 | }, 29 | Flags: co.BuildFlags(true), 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /cmd/clean/clean.go: -------------------------------------------------------------------------------- 1 | package clean 2 | 3 | import ( 4 | "io" 5 | "os" 6 | "path/filepath" 7 | 8 | "github.com/urfave/cli" 9 | "jrubin.io/slog" 10 | "jrubin.io/zb/cmd" 11 | "jrubin.io/zb/lib/project" 12 | "jrubin.io/zb/lib/zbcontext" 13 | ) 14 | 15 | // Cmd is the clean command 16 | var Cmd cmd.Constructor = &cc{} 17 | 18 | type cc struct{} 19 | 20 | func (co *cc) New(_ *cli.App) cli.Command { 21 | return cli.Command{ 22 | Name: "clean", 23 | Usage: "remove executables in repo produced by build", 24 | ArgsUsage: "[packages]", 25 | Action: func(c *cli.Context) error { 26 | ctx := cmd.Context(c) 27 | ctx.ExcludeVendor = true 28 | return co.run(ctx, c.App.Writer, c.Args()...) 29 | }, 30 | } 31 | } 32 | 33 | func (co *cc) run(ctx zbcontext.Context, w io.Writer, args ...string) error { 34 | if ctx.Package { 35 | return co.cleanPackage(ctx, w, args...) 36 | } 37 | 38 | return co.cleanProject(ctx, w, args...) 39 | } 40 | 41 | func (co *cc) cleanPackage(ctx zbcontext.Context, w io.Writer, args ...string) error { 42 | pkgs, err := project.ListPackages(ctx, args...) 43 | if err != nil { 44 | return err 45 | } 46 | 47 | for _, pkg := range pkgs { 48 | cleanPackage(ctx.Logger, pkg.Dir, pkg) 49 | } 50 | 51 | return nil 52 | } 53 | 54 | func (co *cc) cleanProject(ctx zbcontext.Context, w io.Writer, args ...string) error { 55 | projects, err := project.Projects(ctx, args...) 56 | if err != nil { 57 | return err 58 | } 59 | 60 | for _, p := range projects { 61 | for _, pkg := range p.Packages { 62 | cleanPackage(ctx.Logger, p.Dir, pkg) 63 | } 64 | } 65 | 66 | return nil 67 | } 68 | 69 | func cleanPackage(logger slog.Interface, dir string, pkg *project.Package) { 70 | if !pkg.IsCommand() { 71 | return 72 | } 73 | 74 | path := pkg.BuildPath(dir) 75 | logger = logger.WithField("path", path) 76 | 77 | if rel, err := filepath.Rel(zbcontext.CWD, pkg.BuildPath(dir)); err == nil { 78 | logger = logger.WithField("path", rel) 79 | } 80 | 81 | err := os.Remove(path) 82 | 83 | if err == nil { 84 | logger.Info("removed") 85 | return 86 | } 87 | 88 | if os.IsNotExist(err) { 89 | logger.Info(err.(*os.PathError).Err.Error()) 90 | return 91 | } 92 | 93 | logger.WithError(err).Error("error removing executable") 94 | } 95 | -------------------------------------------------------------------------------- /cmd/cmd.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "path/filepath" 7 | "runtime" 8 | "strings" 9 | 10 | "jrubin.io/zb/lib/zbcontext" 11 | 12 | "github.com/urfave/cli" 13 | ) 14 | 15 | // Constructor returns a cli.Command 16 | type Constructor interface { 17 | New(app *cli.App) cli.Command 18 | } 19 | 20 | // BashComplete prints words suitable for completion of the App 21 | func BashComplete(c *cli.Context) { 22 | bashComplete(c, c.App.Commands, c.App.Flags) 23 | } 24 | 25 | // BashCommandComplete prints words suitable for completion of a Command 26 | func BashCommandComplete(cmd cli.Command) cli.BashCompleteFunc { 27 | return func(c *cli.Context) { 28 | bashComplete(c, cmd.Subcommands, cmd.Flags) 29 | } 30 | } 31 | 32 | func bashComplete(c *cli.Context, cmds []cli.Command, flags []cli.Flag) { 33 | for _, command := range cmds { 34 | if command.Hidden { 35 | continue 36 | } 37 | 38 | for _, name := range command.Names() { 39 | fmt.Fprintln(c.App.Writer, name) 40 | } 41 | } 42 | 43 | for _, flag := range flags { 44 | for _, name := range strings.Split(flag.GetName(), ",") { 45 | if name == cli.BashCompletionFlag.Name { 46 | continue 47 | } 48 | 49 | switch name = strings.TrimSpace(name); len(name) { 50 | case 0: 51 | case 1: 52 | fmt.Fprintln(c.App.Writer, "-"+name) 53 | default: 54 | fmt.Fprintln(c.App.Writer, "--"+name) 55 | } 56 | } 57 | } 58 | } 59 | 60 | // DefaultCacheDir returns the base directory that should be used for caching 61 | // data 62 | func DefaultCacheDir(name string) string { 63 | if runtime.GOOS == "darwin" { 64 | return filepath.Join(os.Getenv("HOME"), "Library", "Caches", name) 65 | } 66 | 67 | return filepath.Join(os.Getenv("HOME"), ".cache", name) 68 | } 69 | 70 | // Context extracts zbcontext from app metadata 71 | func Context(c *cli.Context) zbcontext.Context { 72 | if ctx, ok := c.App.Metadata["Context"].(zbcontext.Context); ok { 73 | return ctx 74 | } 75 | panic("context not available") 76 | } 77 | -------------------------------------------------------------------------------- /cmd/commands/commands.go: -------------------------------------------------------------------------------- 1 | package commands 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | 7 | "github.com/urfave/cli" 8 | "jrubin.io/zb/cmd" 9 | "jrubin.io/zb/lib/project" 10 | "jrubin.io/zb/lib/zbcontext" 11 | ) 12 | 13 | // Cmd is the commands command 14 | var Cmd cmd.Constructor = &cc{} 15 | 16 | type cc struct{} 17 | 18 | func (co *cc) New(_ *cli.App) cli.Command { 19 | return cli.Command{ 20 | Name: "commands", 21 | Usage: "list all of the executables that will be emitted by the build command", 22 | ArgsUsage: "[packages]", 23 | Action: func(c *cli.Context) error { 24 | ctx := cmd.Context(c) 25 | ctx.ExcludeVendor = true 26 | return co.run(ctx, c.App.Writer, c.Args()...) 27 | }, 28 | } 29 | } 30 | 31 | func (co *cc) run(ctx zbcontext.Context, w io.Writer, args ...string) error { 32 | if ctx.Package { 33 | return co.commandsPackage(ctx, w, args...) 34 | } 35 | 36 | return co.commandsProject(ctx, w, args...) 37 | } 38 | 39 | func (co *cc) commandsPackage(ctx zbcontext.Context, w io.Writer, args ...string) error { 40 | pkgs, err := project.ListPackages(ctx, args...) 41 | if err != nil { 42 | return err 43 | } 44 | 45 | for _, pkg := range pkgs { 46 | if pkg.IsCommand() { 47 | fmt.Fprintln(w, pkg.BuildPath(pkg.Dir)) 48 | } 49 | } 50 | 51 | return nil 52 | } 53 | 54 | func (co *cc) commandsProject(ctx zbcontext.Context, w io.Writer, args ...string) error { 55 | projects, err := project.Projects(ctx, args...) 56 | if err != nil { 57 | return err 58 | } 59 | 60 | for _, p := range projects { 61 | for _, pkg := range p.Packages { 62 | if pkg.IsCommand() { 63 | fmt.Fprintln(w, pkg.BuildPath(p.Dir)) 64 | } 65 | } 66 | } 67 | 68 | return nil 69 | } 70 | -------------------------------------------------------------------------------- /cmd/complete/complete.go: -------------------------------------------------------------------------------- 1 | package complete 2 | 3 | import ( 4 | "os" 5 | "path/filepath" 6 | "text/template" 7 | 8 | "github.com/pkg/errors" 9 | "github.com/urfave/cli" 10 | "jrubin.io/zb/cmd" 11 | ) 12 | 13 | // Cmd is the complete command 14 | var Cmd cmd.Constructor = &cc{} 15 | 16 | type shell int 17 | 18 | const ( 19 | bash shell = iota 20 | zsh 21 | ) 22 | 23 | type cc struct { 24 | AppName string 25 | FlagName string 26 | Shell shell 27 | Bash shell 28 | Zsh shell 29 | } 30 | 31 | func (co *cc) New(app *cli.App) cli.Command { 32 | co.Bash = bash 33 | co.Zsh = zsh 34 | co.AppName = app.Name 35 | co.FlagName = cli.BashCompletionFlag.Name 36 | 37 | return cli.Command{ 38 | Name: "complete", 39 | Usage: "generate autocomplete script", 40 | Description: `eval "$(zb complete)"`, 41 | Before: co.setup, 42 | Action: co.run, 43 | } 44 | } 45 | 46 | func (co *cc) setup(c *cli.Context) error { 47 | switch shell := filepath.Base(os.Getenv("SHELL")); shell { 48 | case "bash": 49 | co.Shell = bash 50 | case "zsh": 51 | co.Shell = zsh 52 | default: 53 | return errors.Errorf("unsupported shell: %s", shell) 54 | } 55 | return nil 56 | } 57 | 58 | func (co *cc) run(c *cli.Context) error { 59 | return tpl.Execute(c.App.Writer, co) 60 | } 61 | 62 | var tpl *template.Template 63 | 64 | func init() { 65 | tpl = template.Must(template.New("shellFunc").Parse(shellFunc)) 66 | } 67 | 68 | var shellFunc = `{{ if eq .Shell .Bash }}#!/bin/bash{{ end }}{{ if eq .Shell .Zsh }}autoload -U compinit && compinit 69 | autoload -U bashcompinit && bashcompinit{{ end }} 70 | 71 | _{{ .AppName }}_autocomplete() { 72 | local cur opts base 73 | COMPREPLY=() 74 | cur="${COMP_WORDS[COMP_CWORD]}" 75 | opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --{{ .FlagName }} ) 76 | COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) 77 | return 0 78 | } 79 | 80 | complete -o default -F _{{ .AppName }}_autocomplete {{ .AppName }} 81 | ` 82 | -------------------------------------------------------------------------------- /cmd/install/install.go: -------------------------------------------------------------------------------- 1 | package install 2 | 3 | import ( 4 | "github.com/urfave/cli" 5 | "jrubin.io/zb/cmd" 6 | "jrubin.io/zb/lib/buildflags" 7 | "jrubin.io/zb/lib/dependency" 8 | "jrubin.io/zb/lib/project" 9 | "jrubin.io/zb/lib/zbcontext" 10 | ) 11 | 12 | // Cmd is the install command 13 | var Cmd cmd.Constructor = &cc{} 14 | 15 | type cc struct { 16 | buildflags.Data 17 | } 18 | 19 | func (co *cc) New(_ *cli.App) cli.Command { 20 | return cli.Command{ 21 | Name: "install", 22 | Usage: "compile and install all of the packages in each of the projects", 23 | ArgsUsage: "[build flags] [packages]", 24 | Action: func(c *cli.Context) error { 25 | ctx := cmd.Context(c) 26 | ctx.BuildContext = co.Data.BuildContext() 27 | ctx.BuildArger = co 28 | return Run(ctx, dependency.TargetInstall, c.Args()...) 29 | }, 30 | Flags: co.BuildFlags(true), 31 | } 32 | } 33 | 34 | func Run(ctx zbcontext.Context, tt dependency.TargetType, args ...string) error { 35 | var err error 36 | var built int 37 | 38 | if ctx.Package { 39 | built, err = installPackage(ctx, tt, args...) 40 | } else { 41 | built, err = installProject(ctx, tt, args...) 42 | } 43 | 44 | if err != nil { 45 | return err 46 | } 47 | 48 | if built == 0 { 49 | ctx.Logger.Info("nothing to " + tt.String()) 50 | } 51 | 52 | return nil 53 | } 54 | 55 | func installPackage(ctx zbcontext.Context, tt dependency.TargetType, args ...string) (int, error) { 56 | pkgs, err := project.ListPackages(ctx, args...) 57 | if err != nil { 58 | return 0, err 59 | } 60 | 61 | return pkgs.Build(ctx, tt) 62 | } 63 | 64 | func installProject(ctx zbcontext.Context, tt dependency.TargetType, args ...string) (int, error) { 65 | projects, err := project.Projects(ctx, args...) 66 | if err != nil { 67 | return 0, err 68 | } 69 | 70 | return projects.Build(ctx, tt) 71 | } 72 | -------------------------------------------------------------------------------- /cmd/list/list.go: -------------------------------------------------------------------------------- 1 | package list 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | 7 | "github.com/urfave/cli" 8 | "jrubin.io/zb/cmd" 9 | "jrubin.io/zb/lib/buildflags" 10 | "jrubin.io/zb/lib/project" 11 | "jrubin.io/zb/lib/zbcontext" 12 | ) 13 | 14 | // Cmd is the list command 15 | var Cmd cmd.Constructor = &cc{} 16 | 17 | type cc struct { 18 | buildflags.Data 19 | ExcludeVendor bool 20 | } 21 | 22 | func (co *cc) New(*cli.App) cli.Command { 23 | return cli.Command{ 24 | Name: "list", 25 | Usage: "lists the packages in the repos of the packages named by the import paths, one per line.", 26 | ArgsUsage: "[-vendor] [build flags] [packages]", 27 | Action: func(c *cli.Context) error { 28 | ctx := cmd.Context(c) 29 | ctx.ExcludeVendor = co.ExcludeVendor 30 | ctx.BuildContext = co.Data.BuildContext() 31 | return co.run(ctx, c.App.Writer, c.Args()...) 32 | }, 33 | Flags: append(co.BuildFlags(false), 34 | cli.BoolFlag{ 35 | Name: "vendor", 36 | Usage: "exclude vendor directories", 37 | Destination: &co.ExcludeVendor, 38 | }, 39 | ), 40 | } 41 | } 42 | 43 | func (co *cc) run(ctx zbcontext.Context, w io.Writer, args ...string) error { 44 | if ctx.Package { 45 | return co.listPackage(ctx, w, args...) 46 | } 47 | 48 | return co.listProject(ctx, w, args...) 49 | } 50 | 51 | func (co *cc) listPackage(ctx zbcontext.Context, w io.Writer, args ...string) error { 52 | pkgs, err := project.ListPackages(ctx, args...) 53 | if err != nil { 54 | return err 55 | } 56 | 57 | for _, pkg := range pkgs { 58 | fmt.Fprintln(w, pkg.ImportPath) 59 | } 60 | 61 | return nil 62 | } 63 | 64 | func (co *cc) listProject(ctx zbcontext.Context, w io.Writer, args ...string) error { 65 | projects, err := project.Projects(ctx, args...) 66 | if err != nil { 67 | return err 68 | } 69 | 70 | for _, p := range projects { 71 | for _, pkg := range p.Packages { 72 | fmt.Fprintln(w, pkg.ImportPath) 73 | } 74 | } 75 | 76 | return nil 77 | } 78 | -------------------------------------------------------------------------------- /cmd/version/version.go: -------------------------------------------------------------------------------- 1 | package version 2 | 3 | import ( 4 | "fmt" 5 | "runtime" 6 | 7 | "github.com/urfave/cli" 8 | "jrubin.io/zb/cmd" 9 | ) 10 | 11 | // Cmd is the version command 12 | var Cmd cmd.Constructor = &cc{} 13 | 14 | type cc struct { 15 | Short bool 16 | } 17 | 18 | func (co *cc) New(app *cli.App) cli.Command { 19 | return cli.Command{ 20 | Name: "version", 21 | Usage: fmt.Sprintf("prints the version of %s", app.Name), 22 | Action: co.run, 23 | Flags: []cli.Flag{ 24 | cli.BoolFlag{ 25 | Name: "short, s", 26 | Destination: &co.Short, 27 | }, 28 | }, 29 | } 30 | } 31 | 32 | func (co *cc) run(c *cli.Context) error { 33 | if co.Short { 34 | fmt.Fprintf(c.App.Writer, "%s\n", c.App.Version) 35 | return nil 36 | } 37 | 38 | ctx := cmd.Context(c) 39 | 40 | var commit string 41 | if ctx.GitCommit != nil { 42 | commit = *ctx.GitCommit 43 | if len(commit) >= 7 { 44 | commit = commit[:7] 45 | } 46 | } 47 | 48 | var buildDate string 49 | if ctx.BuildDate != nil { 50 | buildDate = *ctx.BuildDate 51 | } 52 | 53 | fmt.Fprintf(c.App.Writer, "%s version %s (git: %s, date: %s, %s)\n", 54 | c.App.Name, 55 | c.App.Version, 56 | commit, 57 | buildDate, 58 | runtime.Version(), 59 | ) 60 | return nil 61 | } 62 | -------------------------------------------------------------------------------- /lib/buildflags/stringsflag.go: -------------------------------------------------------------------------------- 1 | package buildflags 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | // taken from go source src/cmd/go/build.go 9 | 10 | func isSpaceByte(c byte) bool { 11 | return c == ' ' || c == '\t' || c == '\n' || c == '\r' 12 | } 13 | 14 | func splitQuotedFields(s string) ([]string, error) { 15 | // Split fields allowing '' or "" around elements. 16 | // Quotes further inside the string do not count. 17 | var f []string 18 | for len(s) > 0 { 19 | for len(s) > 0 && isSpaceByte(s[0]) { 20 | s = s[1:] 21 | } 22 | if len(s) == 0 { 23 | break 24 | } 25 | // Accepted quoted string. No unescaping inside. 26 | if s[0] == '"' || s[0] == '\'' { 27 | quote := s[0] 28 | s = s[1:] 29 | i := 0 30 | for i < len(s) && s[i] != quote { 31 | i++ 32 | } 33 | if i >= len(s) { 34 | return nil, fmt.Errorf("unterminated %c string", quote) 35 | } 36 | f = append(f, s[:i]) 37 | s = s[i+1:] 38 | continue 39 | } 40 | i := 0 41 | for i < len(s) && !isSpaceByte(s[i]) { 42 | i++ 43 | } 44 | f = append(f, s[:i]) 45 | s = s[i:] 46 | } 47 | return f, nil 48 | } 49 | 50 | type stringsFlag []string 51 | 52 | func (v *stringsFlag) Set(s string) error { 53 | var err error 54 | *v, err = splitQuotedFields(s) 55 | if *v == nil { 56 | *v = []string{} 57 | } 58 | return err 59 | } 60 | 61 | func (v *stringsFlag) String() string { 62 | return strings.Join(*v, " ") 63 | } 64 | -------------------------------------------------------------------------------- /lib/dag/functions.go: -------------------------------------------------------------------------------- 1 | package dag 2 | 3 | const ( 4 | // dequeued = ^(1<<31 - 1) 5 | unseen = 0 6 | seen = 1 7 | ) 8 | 9 | // TopologicalSort topoligically sorts a directed acyclic graph. 10 | // If the graph is cyclic, the sort order will change 11 | // based on which node the sort starts on. 12 | // 13 | // The StronglyConnectedComponents function can be used to determine if a graph has cycles. 14 | func (g *Graph) TopologicalSort() []Node { 15 | // init states 16 | for i := range g.nodes { 17 | g.nodes[i].state = unseen 18 | } 19 | sorted := make([]Node, 0, len(g.nodes)) 20 | // sort preorder (first jacket, then shirt) 21 | for _, node := range g.nodes { 22 | if node.state == unseen { 23 | g.dfs(node, &sorted) 24 | } 25 | } 26 | // now make post order for correct sort (jacket follows shirt). O(V) 27 | length := len(sorted) 28 | for i := 0; i < length/2; i++ { 29 | sorted[i], sorted[length-i-1] = sorted[length-i-1], sorted[i] 30 | } 31 | return sorted 32 | } 33 | 34 | // O(V + E). It does not matter to traverse back 35 | // on a bidirectional edge, because any vertex dfs is 36 | // recursing on is marked as visited and won't be visited 37 | // again anyway. 38 | func (g *Graph) dfs(node *node, finishList *[]Node) { 39 | node.state = seen 40 | for _, edge := range node.edges { 41 | if edge.end.state == unseen { 42 | edge.end.parent = node 43 | g.dfs(edge.end, finishList) 44 | } 45 | } 46 | *finishList = append(*finishList, node.container) 47 | } 48 | -------------------------------------------------------------------------------- /lib/dag/graph_test.go: -------------------------------------------------------------------------------- 1 | package dag 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func (g *Graph) reversedEdgeBack(from, to *node) bool { 8 | for _, v := range to.reversedEdges { 9 | if v.end == from { 10 | return true 11 | } 12 | } 13 | return false 14 | } 15 | 16 | func (g *Graph) verify(t *testing.T) { 17 | // over all the nodes 18 | for i, node := range g.nodes { 19 | if node.index != i { 20 | t.Errorf("node's graph index %v != actual graph index %v", node.index, i) 21 | } 22 | // over each edge 23 | for _, edge := range node.edges { 24 | 25 | // check that the graph contains it in the correct position 26 | if edge.end.index >= len(g.nodes) { 27 | t.Errorf("adjacent node end graph index %v >= len(g.nodes)%v", edge.end.index, len(g.nodes)) 28 | } 29 | if g.nodes[edge.end.index] != edge.end { 30 | t.Errorf("adjacent node %p does not belong to the graph on edge %v: should be %p", edge.end, edge, g.nodes[edge.end.index]) 31 | } 32 | // if graph is undirected, check that the to node's reversed edges connects to the from edge 33 | if !g.reversedEdgeBack(node, edge.end) { 34 | t.Errorf("directed graph: node %v has edge to %v, reversedEdges start at end does not have edge back to node", node, edge.end) 35 | } 36 | } 37 | } 38 | } 39 | 40 | func TestMakeNode(t *testing.T) { 41 | graph := &Graph{} 42 | nodes := make(map[Node]int, 0) 43 | for i := 0; i < 10; i++ { 44 | nodes[graph.MakeNode(nil)] = i 45 | } 46 | graph.verify(t) 47 | } 48 | 49 | func TestMakeEdge(t *testing.T) { 50 | graph := &Graph{} 51 | mapped := make(map[int]Node, 0) 52 | for i := 0; i < 10; i++ { 53 | mapped[i] = graph.MakeNode(nil) 54 | } 55 | for j := 0; j < 5; j++ { 56 | for i := 0; i < 10; i++ { 57 | if err := graph.MakeEdge(mapped[i], mapped[(i+1+j)%10]); err != nil { 58 | panic(err) 59 | } 60 | } 61 | } 62 | graph.verify(t) 63 | for i, node := range graph.nodes { 64 | if mapped[i].node != node { 65 | t.Errorf("Node at index %v = %v, != %v, wrong!", i, mapped[i], node) 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /lib/dependency/dependency.go: -------------------------------------------------------------------------------- 1 | package dependency 2 | 3 | import ( 4 | "time" 5 | 6 | "jrubin.io/zb/lib/zbcontext" 7 | ) 8 | 9 | type Dependency interface { 10 | Name() string 11 | Build(ctx zbcontext.Context) error 12 | Install(ctx zbcontext.Context) error 13 | ModTime() time.Time 14 | Dependencies(ctx zbcontext.Context) ([]Dependency, error) 15 | Buildable() bool 16 | } 17 | -------------------------------------------------------------------------------- /lib/dependency/file.go: -------------------------------------------------------------------------------- 1 | package dependency 2 | 3 | import ( 4 | "os" 5 | "time" 6 | 7 | "jrubin.io/zb/lib/zbcontext" 8 | ) 9 | 10 | var _ Dependency = (*File)(nil) 11 | 12 | type File string 13 | 14 | func (f File) Name() string { 15 | return string(f) 16 | } 17 | 18 | func (f File) Build(zbcontext.Context) error { 19 | // noop 20 | return nil 21 | } 22 | 23 | func (f File) Install(zbcontext.Context) error { 24 | // noop 25 | return nil 26 | } 27 | 28 | func (f File) ModTime() time.Time { 29 | i, err := os.Stat(string(f)) 30 | if err != nil { 31 | return time.Time{} 32 | } 33 | return i.ModTime() 34 | } 35 | 36 | func (f File) Dependencies(zbcontext.Context) ([]Dependency, error) { 37 | // noop 38 | return nil, nil 39 | } 40 | 41 | func (f File) Buildable() bool { 42 | return false 43 | } 44 | -------------------------------------------------------------------------------- /lib/dependency/gogeneratefile.go: -------------------------------------------------------------------------------- 1 | package dependency 2 | 3 | import ( 4 | "os" 5 | "time" 6 | 7 | "jrubin.io/zb/lib/zbcontext" 8 | ) 9 | 10 | var _ Dependency = (*GoGenerateFile)(nil) 11 | 12 | type GoGenerateFile struct { 13 | GoFile *GoFile 14 | Depends File 15 | Path string 16 | } 17 | 18 | func (f GoGenerateFile) Name() string { 19 | return f.Path 20 | } 21 | 22 | func (f GoGenerateFile) Build(ctx zbcontext.Context) error { 23 | // with patsubst, multiple GoGenerateFiles may exist pointing to the same 24 | // GoFile. we want to ensure that go generate only runs once in these cases. 25 | // we lock the GoFile to ensure no concurrent go generates and once we have 26 | // a lock, we recheck that it even needs to be run at all. 27 | 28 | f.GoFile.mu.Lock() 29 | defer f.GoFile.mu.Unlock() 30 | 31 | if !ctx.RebuildAll() && !f.Depends.ModTime().After(f.ModTime()) { 32 | return nil 33 | } 34 | 35 | return f.GoFile.Generate(ctx) 36 | } 37 | 38 | func (f GoGenerateFile) Install(ctx zbcontext.Context) error { 39 | return f.Build(ctx) 40 | } 41 | 42 | func (f GoGenerateFile) ModTime() time.Time { 43 | i, err := os.Stat(f.Path) 44 | if err != nil { 45 | return time.Time{} 46 | } 47 | return i.ModTime() 48 | } 49 | 50 | func (f GoGenerateFile) Dependencies(zbcontext.Context) ([]Dependency, error) { 51 | return []Dependency{f.Depends}, nil 52 | } 53 | 54 | func (f GoGenerateFile) Buildable() bool { 55 | return true 56 | } 57 | -------------------------------------------------------------------------------- /lib/lintflags/sortkey.go: -------------------------------------------------------------------------------- 1 | package lintflags 2 | 3 | import "github.com/pkg/errors" 4 | 5 | type SortKey string 6 | 7 | const ( 8 | SortNone SortKey = "none" 9 | SortPath = "path" 10 | SortLine = "line" 11 | SortColumn = "column" 12 | SortSeverity = "severity" 13 | SortMessage = "message" 14 | SortLinter = "linter" 15 | ) 16 | 17 | var sortKeys = []SortKey{ 18 | SortNone, 19 | SortPath, 20 | SortLine, 21 | SortColumn, 22 | SortSeverity, 23 | SortMessage, 24 | SortLinter, 25 | } 26 | 27 | var sortKeysStr []string 28 | 29 | func init() { 30 | for _, key := range sortKeys { 31 | sortKeysStr = append(sortKeysStr, string(key)) 32 | } 33 | } 34 | 35 | func (k SortKey) String() string { 36 | return string(k) 37 | } 38 | 39 | func (k *SortKey) Set(value string) error { 40 | for _, key := range sortKeys { 41 | if string(key) == value { 42 | *k = key 43 | return nil 44 | } 45 | } 46 | 47 | return errors.Errorf("unknown") 48 | } 49 | -------------------------------------------------------------------------------- /lib/project/list.go: -------------------------------------------------------------------------------- 1 | package project 2 | 3 | import ( 4 | "sort" 5 | 6 | "golang.org/x/sync/errgroup" 7 | "jrubin.io/zb/lib/dependency" 8 | "jrubin.io/zb/lib/zbcontext" 9 | ) 10 | 11 | type List []*Project 12 | 13 | func (l *List) Len() int { 14 | return len(*l) 15 | } 16 | 17 | func (l *List) Search(dir string) int { 18 | return sort.Search(l.Len(), func(i int) bool { 19 | return (*l)[i].Dir >= dir 20 | }) 21 | } 22 | 23 | func (l *List) Insert(p *Project) bool { 24 | exists, i := l.Exists(p.Dir) 25 | if exists { 26 | return false 27 | } 28 | 29 | *l = append(*l, nil) 30 | copy((*l)[i+1:], (*l)[i:]) 31 | (*l)[i] = p 32 | 33 | return true 34 | } 35 | 36 | func (l List) Exists(dir string) (bool, int) { 37 | i := l.Search(dir) 38 | return (i < l.Len() && l[i].Dir == dir), i 39 | } 40 | 41 | func (l List) Targets(ctx zbcontext.Context, tt dependency.TargetType) ([]*dependency.Target, error) { 42 | unique := dependency.Targets{} 43 | 44 | var group errgroup.Group 45 | 46 | for _, p := range l { 47 | pp := p 48 | group.Go(func() error { 49 | targets, err := pp.Targets(ctx, tt) 50 | if err != nil { 51 | return err 52 | } 53 | 54 | unique.Append(targets) 55 | return nil 56 | }) 57 | } 58 | 59 | if err := group.Wait(); err != nil { 60 | return nil, err 61 | } 62 | 63 | targets := unique.TopologicalSort() 64 | 65 | // set up the waitgroup dependencies 66 | for i, t := range targets { 67 | target := t 68 | 69 | if ctx.RebuildAll() { 70 | // do a sequential build when -a is specified 71 | if i != len(targets)-1 { 72 | target.Add(1) 73 | targets[i+1].OnDone(target.WaitGroup.Done) 74 | } 75 | } else { 76 | target.RequiredBy.Range(func(r *dependency.Target) { 77 | r.Add(1) 78 | target.OnDone(r.WaitGroup.Done) 79 | }) 80 | } 81 | } 82 | 83 | return targets, nil 84 | } 85 | 86 | func (l List) Build(ctx zbcontext.Context, tt dependency.TargetType) (int, error) { 87 | targets, err := l.Targets(ctx, tt) 88 | if err != nil { 89 | return 0, err 90 | } 91 | return dependency.Build(ctx, tt, targets) 92 | } 93 | -------------------------------------------------------------------------------- /lib/project/projects.go: -------------------------------------------------------------------------------- 1 | package project 2 | 3 | import ( 4 | "go/build" 5 | 6 | "github.com/pkg/errors" 7 | 8 | "jrubin.io/zb/lib/zbcontext" 9 | ) 10 | 11 | // Projects lists the unique projects found by parsing the import paths in args 12 | func Projects(ctx zbcontext.Context, args ...string) (List, error) { 13 | if len(args) == 0 { 14 | args = append(args, ".") 15 | } 16 | 17 | importPaths := ctx.ExpandEllipsis(args...) 18 | 19 | var projects List 20 | 21 | // don't use range, using importPaths as a queue 22 | for len(importPaths) > 0 { 23 | // pop the queue 24 | importPath := ctx.NormalizeImportPath(importPaths[0]) 25 | importPaths = importPaths[1:] 26 | 27 | if dir := ctx.ImportPathToDir(importPath); dir != "" { 28 | if ok, _ := projects.Exists(dir); ok { 29 | continue 30 | } 31 | } 32 | 33 | p, err := project(ctx, importPath) 34 | 35 | if _, ok := err.(*build.NoGoError); ok && err != nil { 36 | // no buildable source files in the given dir 37 | // ok, as long as the project dir can still be found and at least 38 | // one subdir of the project dir has go files 39 | // 40 | // importPath may still be relative too, but it is guaranteed not to 41 | // have ellipsis 42 | 43 | newImportPaths := ctx.NoGoImportPathToProjectImportPaths(importPath) 44 | if len(newImportPaths) > 0 { 45 | // add the new paths to the queue and ignore the error 46 | importPaths = append(importPaths, newImportPaths...) 47 | continue 48 | } 49 | } 50 | 51 | if err != nil { 52 | return nil, err 53 | } 54 | 55 | if projects.Insert(p) { 56 | if err = p.fillPackages(ctx); err != nil { 57 | return nil, err 58 | } 59 | } 60 | } 61 | 62 | return projects, nil 63 | } 64 | 65 | func project(ctx zbcontext.Context, importPath string) (*Project, error) { 66 | p := &Project{ 67 | Packages: make([]*Package, 1), 68 | } 69 | 70 | pkg, err := NewPackage(ctx, importPath, zbcontext.CWD, true) 71 | if err != nil { 72 | return nil, err 73 | } 74 | 75 | p.Dir = zbcontext.GitDir(pkg.Package.Dir) 76 | if p.Dir == "" { 77 | return nil, errors.Errorf("could not find project directory for: %s", pkg.Package.Dir) 78 | } 79 | 80 | p.Packages[0] = pkg 81 | 82 | return p, nil 83 | } 84 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/errors/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Dave Cheney 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 met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/errors/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: build-{build}.{branch} 2 | 3 | clone_folder: C:\gopath\src\github.com\pkg\errors 4 | shallow_clone: true # for startup speed 5 | 6 | environment: 7 | GOPATH: C:\gopath 8 | 9 | platform: 10 | - x64 11 | 12 | # http://www.appveyor.com/docs/installed-software 13 | install: 14 | # some helpful output for debugging builds 15 | - go version 16 | - go env 17 | # pre-installed MinGW at C:\MinGW is 32bit only 18 | # but MSYS2 at C:\msys64 has mingw64 19 | - set PATH=C:\msys64\mingw64\bin;%PATH% 20 | - gcc --version 21 | - g++ --version 22 | 23 | build_script: 24 | - go install -v ./... 25 | 26 | test_script: 27 | - set PATH=C:\gopath\bin;%PATH% 28 | - go test -v ./... 29 | 30 | #artifacts: 31 | # - path: '%GOPATH%\bin\*.exe' 32 | deploy: off 33 | -------------------------------------------------------------------------------- /vendor/github.com/sergi/go-diff/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012-2016 The go-diff Authors. All rights reserved. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a 4 | copy of this software and associated documentation files (the "Software"), 5 | to deal in the Software without restriction, including without limitation 6 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | and/or sell copies of the Software, and to permit persons to whom the 8 | Software is furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included 11 | in all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | OR 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 18 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | DEALINGS IN THE SOFTWARE. 20 | 21 | -------------------------------------------------------------------------------- /vendor/github.com/sergi/go-diff/diffmatchpatch/diffmatchpatch.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2016 The go-diff authors. All rights reserved. 2 | // https://github.com/sergi/go-diff 3 | // See the included LICENSE file for license details. 4 | // 5 | // go-diff is a Go implementation of Google's Diff, Match, and Patch library 6 | // Original library is Copyright (c) 2006 Google Inc. 7 | // http://code.google.com/p/google-diff-match-patch/ 8 | 9 | // Package diffmatchpatch offers robust algorithms to perform the operations required for synchronizing plain text. 10 | package diffmatchpatch 11 | 12 | import ( 13 | "time" 14 | ) 15 | 16 | // DiffMatchPatch holds the configuration for diff-match-patch operations. 17 | type DiffMatchPatch struct { 18 | // Number of seconds to map a diff before giving up (0 for infinity). 19 | DiffTimeout time.Duration 20 | // Cost of an empty edit operation in terms of edit characters. 21 | DiffEditCost int 22 | // How far to search for a match (0 = exact location, 1000+ = broad match). A match this many characters away from the expected location will add 1.0 to the score (0.0 is a perfect match). 23 | MatchDistance int 24 | // When deleting a large block of text (over ~64 characters), how close do the contents have to be to match the expected contents. (0.0 = perfection, 1.0 = very loose). Note that MatchThreshold controls how closely the end points of a delete need to match. 25 | PatchDeleteThreshold float64 26 | // Chunk size for context length. 27 | PatchMargin int 28 | // The number of bits in an int. 29 | MatchMaxBits int 30 | // At what point is no match declared (0.0 = perfection, 1.0 = very loose). 31 | MatchThreshold float64 32 | } 33 | 34 | // New creates a new DiffMatchPatch object with default parameters. 35 | func New() *DiffMatchPatch { 36 | // Defaults. 37 | return &DiffMatchPatch{ 38 | DiffTimeout: time.Second, 39 | DiffEditCost: 4, 40 | MatchThreshold: 0.5, 41 | MatchDistance: 1000, 42 | PatchDeleteThreshold: 0.5, 43 | PatchMargin: 4, 44 | MatchMaxBits: 32, 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/sergi/go-diff/diffmatchpatch/mathutil.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2016 The go-diff authors. All rights reserved. 2 | // https://github.com/sergi/go-diff 3 | // See the included LICENSE file for license details. 4 | // 5 | // go-diff is a Go implementation of Google's Diff, Match, and Patch library 6 | // Original library is Copyright (c) 2006 Google Inc. 7 | // http://code.google.com/p/google-diff-match-patch/ 8 | 9 | package diffmatchpatch 10 | 11 | func min(x, y int) int { 12 | if x < y { 13 | return x 14 | } 15 | return y 16 | } 17 | 18 | func max(x, y int) int { 19 | if x > y { 20 | return x 21 | } 22 | return y 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/src-d/gcfg/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Péter Surányi. Portions Copyright (c) 2009 The Go 2 | Authors. 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 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /vendor/github.com/src-d/gcfg/README: -------------------------------------------------------------------------------- 1 | Gcfg reads INI-style configuration files into Go structs; 2 | supports user-defined types and subsections. 3 | 4 | Package docs: https://godoc.org/gopkg.in/gcfg.v1 5 | -------------------------------------------------------------------------------- /vendor/github.com/src-d/gcfg/errors.go: -------------------------------------------------------------------------------- 1 | package gcfg 2 | 3 | import ( 4 | "gopkg.in/warnings.v0" 5 | ) 6 | 7 | // FatalOnly filters the results of a Read*Into invocation and returns only 8 | // fatal errors. That is, errors (warnings) indicating data for unknown 9 | // sections / variables is ignored. Example invocation: 10 | // 11 | // err := gcfg.FatalOnly(gcfg.ReadFileInto(&cfg, configFile)) 12 | // if err != nil { 13 | // ... 14 | // 15 | func FatalOnly(err error) error { 16 | return warnings.FatalOnly(err) 17 | } 18 | 19 | func isFatal(err error) bool { 20 | _, ok := err.(extraData) 21 | return !ok 22 | } 23 | 24 | type extraData struct { 25 | section string 26 | subsection *string 27 | variable *string 28 | } 29 | 30 | func (e extraData) Error() string { 31 | s := "can't store data at section \"" + e.section + "\"" 32 | if e.subsection != nil { 33 | s += ", subsection \"" + *e.subsection + "\"" 34 | } 35 | if e.variable != nil { 36 | s += ", variable \"" + *e.variable + "\"" 37 | } 38 | return s 39 | } 40 | 41 | var _ error = extraData{} 42 | -------------------------------------------------------------------------------- /vendor/github.com/src-d/gcfg/go1_0.go: -------------------------------------------------------------------------------- 1 | // +build !go1.2 2 | 3 | package gcfg 4 | 5 | type textUnmarshaler interface { 6 | UnmarshalText(text []byte) error 7 | } 8 | -------------------------------------------------------------------------------- /vendor/github.com/src-d/gcfg/go1_2.go: -------------------------------------------------------------------------------- 1 | // +build go1.2 2 | 3 | package gcfg 4 | 5 | import ( 6 | "encoding" 7 | ) 8 | 9 | type textUnmarshaler encoding.TextUnmarshaler 10 | -------------------------------------------------------------------------------- /vendor/github.com/src-d/gcfg/token/serialize.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 | package token 6 | 7 | type serializedFile struct { 8 | // fields correspond 1:1 to fields with same (lower-case) name in File 9 | Name string 10 | Base int 11 | Size int 12 | Lines []int 13 | Infos []lineInfo 14 | } 15 | 16 | type serializedFileSet struct { 17 | Base int 18 | Files []serializedFile 19 | } 20 | 21 | // Read calls decode to deserialize a file set into s; s must not be nil. 22 | func (s *FileSet) Read(decode func(interface{}) error) error { 23 | var ss serializedFileSet 24 | if err := decode(&ss); err != nil { 25 | return err 26 | } 27 | 28 | s.mutex.Lock() 29 | s.base = ss.Base 30 | files := make([]*File, len(ss.Files)) 31 | for i := 0; i < len(ss.Files); i++ { 32 | f := &ss.Files[i] 33 | files[i] = &File{s, f.Name, f.Base, f.Size, f.Lines, f.Infos} 34 | } 35 | s.files = files 36 | s.last = nil 37 | s.mutex.Unlock() 38 | 39 | return nil 40 | } 41 | 42 | // Write calls encode to serialize the file set s. 43 | func (s *FileSet) Write(encode func(interface{}) error) error { 44 | var ss serializedFileSet 45 | 46 | s.mutex.Lock() 47 | ss.Base = s.base 48 | files := make([]serializedFile, len(s.files)) 49 | for i, f := range s.files { 50 | files[i] = serializedFile{f.name, f.base, f.size, f.lines, f.infos} 51 | } 52 | ss.Files = files 53 | s.mutex.Unlock() 54 | 55 | return encode(ss) 56 | } 57 | -------------------------------------------------------------------------------- /vendor/github.com/src-d/gcfg/types/bool.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // BoolValues defines the name and value mappings for ParseBool. 4 | var BoolValues = map[string]interface{}{ 5 | "true": true, "yes": true, "on": true, "1": true, 6 | "false": false, "no": false, "off": false, "0": false, 7 | } 8 | 9 | var boolParser = func() *EnumParser { 10 | ep := &EnumParser{} 11 | ep.AddVals(BoolValues) 12 | return ep 13 | }() 14 | 15 | // ParseBool parses bool values according to the definitions in BoolValues. 16 | // Parsing is case-insensitive. 17 | func ParseBool(s string) (bool, error) { 18 | v, err := boolParser.Parse(s) 19 | if err != nil { 20 | return false, err 21 | } 22 | return v.(bool), nil 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/src-d/gcfg/types/doc.go: -------------------------------------------------------------------------------- 1 | // Package types defines helpers for type conversions. 2 | // 3 | // The API for this package is not finalized yet. 4 | package types 5 | -------------------------------------------------------------------------------- /vendor/github.com/src-d/gcfg/types/enum.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | "strings" 7 | ) 8 | 9 | // EnumParser parses "enum" values; i.e. a predefined set of strings to 10 | // predefined values. 11 | type EnumParser struct { 12 | Type string // type name; if not set, use type of first value added 13 | CaseMatch bool // if true, matching of strings is case-sensitive 14 | // PrefixMatch bool 15 | vals map[string]interface{} 16 | } 17 | 18 | // AddVals adds strings and values to an EnumParser. 19 | func (ep *EnumParser) AddVals(vals map[string]interface{}) { 20 | if ep.vals == nil { 21 | ep.vals = make(map[string]interface{}) 22 | } 23 | for k, v := range vals { 24 | if ep.Type == "" { 25 | ep.Type = reflect.TypeOf(v).Name() 26 | } 27 | if !ep.CaseMatch { 28 | k = strings.ToLower(k) 29 | } 30 | ep.vals[k] = v 31 | } 32 | } 33 | 34 | // Parse parses the string and returns the value or an error. 35 | func (ep EnumParser) Parse(s string) (interface{}, error) { 36 | if !ep.CaseMatch { 37 | s = strings.ToLower(s) 38 | } 39 | v, ok := ep.vals[s] 40 | if !ok { 41 | return false, fmt.Errorf("failed to parse %s %#q", ep.Type, s) 42 | } 43 | return v, nil 44 | } 45 | -------------------------------------------------------------------------------- /vendor/github.com/src-d/gcfg/types/int.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | // An IntMode is a mode for parsing integer values, representing a set of 9 | // accepted bases. 10 | type IntMode uint8 11 | 12 | // IntMode values for ParseInt; can be combined using binary or. 13 | const ( 14 | Dec IntMode = 1 << iota 15 | Hex 16 | Oct 17 | ) 18 | 19 | // String returns a string representation of IntMode; e.g. `IntMode(Dec|Hex)`. 20 | func (m IntMode) String() string { 21 | var modes []string 22 | if m&Dec != 0 { 23 | modes = append(modes, "Dec") 24 | } 25 | if m&Hex != 0 { 26 | modes = append(modes, "Hex") 27 | } 28 | if m&Oct != 0 { 29 | modes = append(modes, "Oct") 30 | } 31 | return "IntMode(" + strings.Join(modes, "|") + ")" 32 | } 33 | 34 | var errIntAmbig = fmt.Errorf("ambiguous integer value; must include '0' prefix") 35 | 36 | func prefix0(val string) bool { 37 | return strings.HasPrefix(val, "0") || strings.HasPrefix(val, "-0") 38 | } 39 | 40 | func prefix0x(val string) bool { 41 | return strings.HasPrefix(val, "0x") || strings.HasPrefix(val, "-0x") 42 | } 43 | 44 | // ParseInt parses val using mode into intptr, which must be a pointer to an 45 | // integer kind type. Non-decimal value require prefix `0` or `0x` in the cases 46 | // when mode permits ambiguity of base; otherwise the prefix can be omitted. 47 | func ParseInt(intptr interface{}, val string, mode IntMode) error { 48 | val = strings.TrimSpace(val) 49 | verb := byte(0) 50 | switch mode { 51 | case Dec: 52 | verb = 'd' 53 | case Dec + Hex: 54 | if prefix0x(val) { 55 | verb = 'v' 56 | } else { 57 | verb = 'd' 58 | } 59 | case Dec + Oct: 60 | if prefix0(val) && !prefix0x(val) { 61 | verb = 'v' 62 | } else { 63 | verb = 'd' 64 | } 65 | case Dec + Hex + Oct: 66 | verb = 'v' 67 | case Hex: 68 | if prefix0x(val) { 69 | verb = 'v' 70 | } else { 71 | verb = 'x' 72 | } 73 | case Oct: 74 | verb = 'o' 75 | case Hex + Oct: 76 | if prefix0(val) { 77 | verb = 'v' 78 | } else { 79 | return errIntAmbig 80 | } 81 | } 82 | if verb == 0 { 83 | panic("unsupported mode") 84 | } 85 | return ScanFully(intptr, val, verb) 86 | } 87 | -------------------------------------------------------------------------------- /vendor/github.com/src-d/gcfg/types/scan.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "reflect" 7 | ) 8 | 9 | // ScanFully uses fmt.Sscanf with verb to fully scan val into ptr. 10 | func ScanFully(ptr interface{}, val string, verb byte) error { 11 | t := reflect.ValueOf(ptr).Elem().Type() 12 | // attempt to read extra bytes to make sure the value is consumed 13 | var b []byte 14 | n, err := fmt.Sscanf(val, "%"+string(verb)+"%s", ptr, &b) 15 | switch { 16 | case n < 1 || n == 1 && err != io.EOF: 17 | return fmt.Errorf("failed to parse %q as %v: %v", val, t, err) 18 | case n > 1: 19 | return fmt.Errorf("failed to parse %q as %v: extra characters %q", val, t, string(b)) 20 | } 21 | // n == 1 && err == io.EOF 22 | return nil 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/urfave/cli/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Jeremy Saenz & Contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/urfave/cli/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: "{build}" 2 | 3 | os: Windows Server 2012 R2 4 | 5 | clone_folder: c:\gopath\src\github.com\urfave\cli 6 | 7 | environment: 8 | GOPATH: C:\gopath 9 | GOVERSION: 1.6 10 | PYTHON: C:\Python27-x64 11 | PYTHON_VERSION: 2.7.x 12 | PYTHON_ARCH: 64 13 | 14 | install: 15 | - set PATH=%GOPATH%\bin;C:\go\bin;%PATH% 16 | - go version 17 | - go env 18 | - go get github.com/urfave/gfmrun/... 19 | - go get -v -t ./... 20 | 21 | build_script: 22 | - python runtests vet 23 | - python runtests test 24 | - python runtests gfmrun 25 | -------------------------------------------------------------------------------- /vendor/github.com/urfave/cli/category.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | // CommandCategories is a slice of *CommandCategory. 4 | type CommandCategories []*CommandCategory 5 | 6 | // CommandCategory is a category containing commands. 7 | type CommandCategory struct { 8 | Name string 9 | Commands Commands 10 | } 11 | 12 | func (c CommandCategories) Less(i, j int) bool { 13 | return c[i].Name < c[j].Name 14 | } 15 | 16 | func (c CommandCategories) Len() int { 17 | return len(c) 18 | } 19 | 20 | func (c CommandCategories) Swap(i, j int) { 21 | c[i], c[j] = c[j], c[i] 22 | } 23 | 24 | // AddCommand adds a command to a category. 25 | func (c CommandCategories) AddCommand(category string, command Command) CommandCategories { 26 | for _, commandCategory := range c { 27 | if commandCategory.Name == category { 28 | commandCategory.Commands = append(commandCategory.Commands, command) 29 | return c 30 | } 31 | } 32 | return append(c, &CommandCategory{Name: category, Commands: []Command{command}}) 33 | } 34 | 35 | // VisibleCommands returns a slice of the Commands with Hidden=false 36 | func (c *CommandCategory) VisibleCommands() []Command { 37 | ret := []Command{} 38 | for _, command := range c.Commands { 39 | if !command.Hidden { 40 | ret = append(ret, command) 41 | } 42 | } 43 | return ret 44 | } 45 | -------------------------------------------------------------------------------- /vendor/github.com/urfave/cli/cli.go: -------------------------------------------------------------------------------- 1 | // Package cli provides a minimal framework for creating and organizing command line 2 | // Go applications. cli is designed to be easy to understand and write, the most simple 3 | // cli application can be written as follows: 4 | // func main() { 5 | // cli.NewApp().Run(os.Args) 6 | // } 7 | // 8 | // Of course this application does not do much, so let's make this an actual application: 9 | // func main() { 10 | // app := cli.NewApp() 11 | // app.Name = "greet" 12 | // app.Usage = "say a greeting" 13 | // app.Action = func(c *cli.Context) error { 14 | // println("Greetings") 15 | // } 16 | // 17 | // app.Run(os.Args) 18 | // } 19 | package cli 20 | 21 | //go:generate python ./generate-flag-types cli -i flag-types.json -o flag_generated.go 22 | -------------------------------------------------------------------------------- /vendor/github.com/urfave/cli/funcs.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | // BashCompleteFunc is an action to execute when the bash-completion flag is set 4 | type BashCompleteFunc func(*Context) 5 | 6 | // BeforeFunc is an action to execute before any subcommands are run, but after 7 | // the context is ready if a non-nil error is returned, no subcommands are run 8 | type BeforeFunc func(*Context) error 9 | 10 | // AfterFunc is an action to execute after any subcommands are run, but after the 11 | // subcommand has finished it is run even if Action() panics 12 | type AfterFunc func(*Context) error 13 | 14 | // ActionFunc is the action to execute when no subcommands are specified 15 | type ActionFunc func(*Context) error 16 | 17 | // CommandNotFoundFunc is executed if the proper command cannot be found 18 | type CommandNotFoundFunc func(*Context, string) 19 | 20 | // OnUsageErrorFunc is executed if an usage error occurs. This is useful for displaying 21 | // customized usage error messages. This function is able to replace the 22 | // original error messages. If this function is not set, the "Incorrect usage" 23 | // is displayed and the execution is interrupted. 24 | type OnUsageErrorFunc func(context *Context, err error, isSubcommand bool) error 25 | 26 | // FlagStringFunc is used by the help generation to display a flag, which is 27 | // expected to be a single line. 28 | type FlagStringFunc func(Flag) string 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/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/crypto/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/crypto/curve25519/const_amd64.h: -------------------------------------------------------------------------------- 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 | // This code was translated into a form compatible with 6a from the public 6 | // domain sources in SUPERCOP: http://bench.cr.yp.to/supercop.html 7 | 8 | #define REDMASK51 0x0007FFFFFFFFFFFF 9 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/const_amd64.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 | // This code was translated into a form compatible with 6a from the public 6 | // domain sources in SUPERCOP: http://bench.cr.yp.to/supercop.html 7 | 8 | // +build amd64,!gccgo,!appengine 9 | 10 | // These constants cannot be encoded in non-MOVQ immediates. 11 | // We access them directly from memory instead. 12 | 13 | DATA ·_121666_213(SB)/8, $996687872 14 | GLOBL ·_121666_213(SB), 8, $8 15 | 16 | DATA ·_2P0(SB)/8, $0xFFFFFFFFFFFDA 17 | GLOBL ·_2P0(SB), 8, $8 18 | 19 | DATA ·_2P1234(SB)/8, $0xFFFFFFFFFFFFE 20 | GLOBL ·_2P1234(SB), 8, $8 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/cswap_amd64.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 amd64,!gccgo,!appengine 6 | 7 | // func cswap(inout *[4][5]uint64, v uint64) 8 | TEXT ·cswap(SB),7,$0 9 | MOVQ inout+0(FP),DI 10 | MOVQ v+8(FP),SI 11 | 12 | SUBQ $1, SI 13 | NOTQ SI 14 | MOVQ SI, X15 15 | PSHUFD $0x44, X15, X15 16 | 17 | MOVOU 0(DI), X0 18 | MOVOU 16(DI), X2 19 | MOVOU 32(DI), X4 20 | MOVOU 48(DI), X6 21 | MOVOU 64(DI), X8 22 | MOVOU 80(DI), X1 23 | MOVOU 96(DI), X3 24 | MOVOU 112(DI), X5 25 | MOVOU 128(DI), X7 26 | MOVOU 144(DI), X9 27 | 28 | MOVO X1, X10 29 | MOVO X3, X11 30 | MOVO X5, X12 31 | MOVO X7, X13 32 | MOVO X9, X14 33 | 34 | PXOR X0, X10 35 | PXOR X2, X11 36 | PXOR X4, X12 37 | PXOR X6, X13 38 | PXOR X8, X14 39 | PAND X15, X10 40 | PAND X15, X11 41 | PAND X15, X12 42 | PAND X15, X13 43 | PAND X15, X14 44 | PXOR X10, X0 45 | PXOR X10, X1 46 | PXOR X11, X2 47 | PXOR X11, X3 48 | PXOR X12, X4 49 | PXOR X12, X5 50 | PXOR X13, X6 51 | PXOR X13, X7 52 | PXOR X14, X8 53 | PXOR X14, X9 54 | 55 | MOVOU X0, 0(DI) 56 | MOVOU X2, 16(DI) 57 | MOVOU X4, 32(DI) 58 | MOVOU X6, 48(DI) 59 | MOVOU X8, 64(DI) 60 | MOVOU X1, 80(DI) 61 | MOVOU X3, 96(DI) 62 | MOVOU X5, 112(DI) 63 | MOVOU X7, 128(DI) 64 | MOVOU X9, 144(DI) 65 | RET 66 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/doc.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 | // Package curve25519 provides an implementation of scalar multiplication on 6 | // the elliptic curve known as curve25519. See http://cr.yp.to/ecdh.html 7 | package curve25519 // import "golang.org/x/crypto/curve25519" 8 | 9 | // basePoint is the x coordinate of the generator of the curve. 10 | var basePoint = [32]byte{9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} 11 | 12 | // ScalarMult sets dst to the product in*base where dst and base are the x 13 | // coordinates of group points and all values are in little-endian form. 14 | func ScalarMult(dst, in, base *[32]byte) { 15 | scalarMult(dst, in, base) 16 | } 17 | 18 | // ScalarBaseMult sets dst to the product in*base where dst and base are the x 19 | // coordinates of group points, base is the standard generator and all values 20 | // are in little-endian form. 21 | func ScalarBaseMult(dst, in *[32]byte) { 22 | ScalarMult(dst, in, &basePoint) 23 | } 24 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/freeze_amd64.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 | // This code was translated into a form compatible with 6a from the public 6 | // domain sources in SUPERCOP: http://bench.cr.yp.to/supercop.html 7 | 8 | // +build amd64,!gccgo,!appengine 9 | 10 | #include "const_amd64.h" 11 | 12 | // func freeze(inout *[5]uint64) 13 | TEXT ·freeze(SB),7,$0-8 14 | MOVQ inout+0(FP), DI 15 | 16 | MOVQ 0(DI),SI 17 | MOVQ 8(DI),DX 18 | MOVQ 16(DI),CX 19 | MOVQ 24(DI),R8 20 | MOVQ 32(DI),R9 21 | MOVQ $REDMASK51,AX 22 | MOVQ AX,R10 23 | SUBQ $18,R10 24 | MOVQ $3,R11 25 | REDUCELOOP: 26 | MOVQ SI,R12 27 | SHRQ $51,R12 28 | ANDQ AX,SI 29 | ADDQ R12,DX 30 | MOVQ DX,R12 31 | SHRQ $51,R12 32 | ANDQ AX,DX 33 | ADDQ R12,CX 34 | MOVQ CX,R12 35 | SHRQ $51,R12 36 | ANDQ AX,CX 37 | ADDQ R12,R8 38 | MOVQ R8,R12 39 | SHRQ $51,R12 40 | ANDQ AX,R8 41 | ADDQ R12,R9 42 | MOVQ R9,R12 43 | SHRQ $51,R12 44 | ANDQ AX,R9 45 | IMUL3Q $19,R12,R12 46 | ADDQ R12,SI 47 | SUBQ $1,R11 48 | JA REDUCELOOP 49 | MOVQ $1,R12 50 | CMPQ R10,SI 51 | CMOVQLT R11,R12 52 | CMPQ AX,DX 53 | CMOVQNE R11,R12 54 | CMPQ AX,CX 55 | CMOVQNE R11,R12 56 | CMPQ AX,R8 57 | CMOVQNE R11,R12 58 | CMPQ AX,R9 59 | CMOVQNE R11,R12 60 | NEGQ R12 61 | ANDQ R12,AX 62 | ANDQ R12,R10 63 | SUBQ R10,SI 64 | SUBQ AX,DX 65 | SUBQ AX,CX 66 | SUBQ AX,R8 67 | SUBQ AX,R9 68 | MOVQ SI,0(DI) 69 | MOVQ DX,8(DI) 70 | MOVQ CX,16(DI) 71 | MOVQ R8,24(DI) 72 | MOVQ R9,32(DI) 73 | RET 74 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/doc.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 | /* 6 | Package ssh implements an SSH client and server. 7 | 8 | SSH is a transport security protocol, an authentication protocol and a 9 | family of application protocols. The most typical application level 10 | protocol is a remote shell and this is specifically implemented. However, 11 | the multiplexed nature of SSH is exposed to users that wish to support 12 | others. 13 | 14 | References: 15 | [PROTOCOL.certkeys]: http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/PROTOCOL.certkeys?rev=HEAD 16 | [SSH-PARAMETERS]: http://www.iana.org/assignments/ssh-parameters/ssh-parameters.xml#ssh-parameters-1 17 | 18 | This package does not fall under the stability promise of the Go language itself, 19 | so its API may be changed when pressing needs arise. 20 | */ 21 | package ssh // import "golang.org/x/crypto/ssh" 22 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/mac.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 | package ssh 6 | 7 | // Message authentication support 8 | 9 | import ( 10 | "crypto/hmac" 11 | "crypto/sha1" 12 | "crypto/sha256" 13 | "hash" 14 | ) 15 | 16 | type macMode struct { 17 | keySize int 18 | etm bool 19 | new func(key []byte) hash.Hash 20 | } 21 | 22 | // truncatingMAC wraps around a hash.Hash and truncates the output digest to 23 | // a given size. 24 | type truncatingMAC struct { 25 | length int 26 | hmac hash.Hash 27 | } 28 | 29 | func (t truncatingMAC) Write(data []byte) (int, error) { 30 | return t.hmac.Write(data) 31 | } 32 | 33 | func (t truncatingMAC) Sum(in []byte) []byte { 34 | out := t.hmac.Sum(in) 35 | return out[:len(in)+t.length] 36 | } 37 | 38 | func (t truncatingMAC) Reset() { 39 | t.hmac.Reset() 40 | } 41 | 42 | func (t truncatingMAC) Size() int { 43 | return t.length 44 | } 45 | 46 | func (t truncatingMAC) BlockSize() int { return t.hmac.BlockSize() } 47 | 48 | var macModes = map[string]*macMode{ 49 | "hmac-sha2-256-etm@openssh.com": {32, true, func(key []byte) hash.Hash { 50 | return hmac.New(sha256.New, key) 51 | }}, 52 | "hmac-sha2-256": {32, false, func(key []byte) hash.Hash { 53 | return hmac.New(sha256.New, key) 54 | }}, 55 | "hmac-sha1": {20, false, func(key []byte) hash.Hash { 56 | return hmac.New(sha1.New, key) 57 | }}, 58 | "hmac-sha1-96": {20, false, func(key []byte) hash.Hash { 59 | return truncatingMAC{12, hmac.New(sha1.New, key)} 60 | }}, 61 | } 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/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/net/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/sync/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/sync/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/sync/errgroup/errgroup.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package errgroup provides synchronization, error propagation, and Context 6 | // cancelation for groups of goroutines working on subtasks of a common task. 7 | package errgroup 8 | 9 | import ( 10 | "sync" 11 | 12 | "golang.org/x/net/context" 13 | ) 14 | 15 | // A Group is a collection of goroutines working on subtasks that are part of 16 | // the same overall task. 17 | // 18 | // A zero Group is valid and does not cancel on error. 19 | type Group struct { 20 | cancel func() 21 | 22 | wg sync.WaitGroup 23 | 24 | errOnce sync.Once 25 | err error 26 | } 27 | 28 | // WithContext returns a new Group and an associated Context derived from ctx. 29 | // 30 | // The derived Context is canceled the first time a function passed to Go 31 | // returns a non-nil error or the first time Wait returns, whichever occurs 32 | // first. 33 | func WithContext(ctx context.Context) (*Group, context.Context) { 34 | ctx, cancel := context.WithCancel(ctx) 35 | return &Group{cancel: cancel}, ctx 36 | } 37 | 38 | // Wait blocks until all function calls from the Go method have returned, then 39 | // returns the first non-nil error (if any) from them. 40 | func (g *Group) Wait() error { 41 | g.wg.Wait() 42 | if g.cancel != nil { 43 | g.cancel() 44 | } 45 | return g.err 46 | } 47 | 48 | // Go calls the given function in a new goroutine. 49 | // 50 | // The first call to return a non-nil error cancels the group; its error will be 51 | // returned by Wait. 52 | func (g *Group) Go(f func() error) { 53 | g.wg.Add(1) 54 | 55 | go func() { 56 | defer g.wg.Done() 57 | 58 | if err := f(); err != nil { 59 | g.errOnce.Do(func() { 60 | g.err = err 61 | if g.cancel != nil { 62 | g.cancel() 63 | } 64 | }) 65 | } 66 | }() 67 | } 68 | -------------------------------------------------------------------------------- /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/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_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_mipsx.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips mipsle 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips, 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-28 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 25 | JMP syscall·Syscall9(SB) 26 | 27 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 28 | JMP syscall·RawSyscall(SB) 29 | 30 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 31 | JMP syscall·RawSyscall6(SB) 32 | -------------------------------------------------------------------------------- /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_linux_s390x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build s390x 6 | // +build linux 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for s390x, 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-88 14 | JMP syscall·sysvicall6(SB) 15 | 16 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-88 17 | JMP syscall·rawSysvicall6(SB) 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/bluetooth_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Bluetooth sockets and messages 6 | 7 | package unix 8 | 9 | // Bluetooth Protocols 10 | const ( 11 | BTPROTO_L2CAP = 0 12 | BTPROTO_HCI = 1 13 | BTPROTO_SCO = 2 14 | BTPROTO_RFCOMM = 3 15 | BTPROTO_BNEP = 4 16 | BTPROTO_CMTP = 5 17 | BTPROTO_HIDP = 6 18 | BTPROTO_AVDTP = 7 19 | ) 20 | 21 | const ( 22 | HCI_CHANNEL_RAW = 0 23 | HCI_CHANNEL_USER = 1 24 | HCI_CHANNEL_MONITOR = 2 25 | HCI_CHANNEL_CONTROL = 3 26 | ) 27 | 28 | // Socketoption Level 29 | const ( 30 | SOL_BLUETOOTH = 0x112 31 | SOL_HCI = 0x0 32 | SOL_L2CAP = 0x6 33 | SOL_RFCOMM = 0x12 34 | SOL_SCO = 0x11 35 | ) 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/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/endian_big.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | // +build ppc64 s390x mips mips64 6 | 7 | package unix 8 | 9 | const isBigEndian = true 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_little.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | // +build 386 amd64 amd64p32 arm arm64 ppc64le mipsle mips64le 6 | 7 | package unix 8 | 9 | const isBigEndian = false 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/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 linux,mips linux,mipsle 2 | 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | package unix 8 | 9 | func init() { 10 | // On 32-bit Linux systems, the fcntl syscall that matches Go's 11 | // Flock_t type is SYS_FCNTL64, not SYS_FCNTL. 12 | fcntl64Syscall = SYS_FCNTL64 13 | } 14 | -------------------------------------------------------------------------------- /vendor/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/gccgo_linux_sparc64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo,linux,sparc64 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //extern sysconf 12 | func realSysconf(name int) int64 13 | 14 | func sysconf(name int) (n int64, err syscall.Errno) { 15 | r := realSysconf(name) 16 | if r < 0 { 17 | return 0, syscall.GetErrno() 18 | } 19 | return r, 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 <){ 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 <= 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_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_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_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,linux 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | //go:noescape 13 | func gettimeofday(tv *Timeval) (err syscall.Errno) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/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/syscall_unix_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 13 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 14 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 15 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/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 | -------------------------------------------------------------------------------- /vendor/gopkg.in/warnings.v0/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Péter Surányi. 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 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 18 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /vendor/jrubin.io/slog/LICENSE: -------------------------------------------------------------------------------- 1 | (The MIT License) 2 | 3 | Copyright (c) 2016 Joshua Rubin 4 | Copyright (c) 2015 TJ Holowaychuk 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | 'Software'), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /vendor/jrubin.io/slog/Readme.md: -------------------------------------------------------------------------------- 1 | # slog 2 | 3 | slog implements a simple structured logging API inspired by [apex/log](https://github.com/apex/log), [Logrus](https://github.com/Sirupsen/logrus) and [go-playground/log](https://github.com/go-playground/log). 4 | -------------------------------------------------------------------------------- /vendor/jrubin.io/slog/handlers/text/terminal_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd openbsd netbsd dragonfly 2 | 3 | package text 4 | 5 | import "syscall" 6 | 7 | const ioctlReadTermios = syscall.TIOCGETA 8 | 9 | // Termios is syscall.Termios 10 | type Termios syscall.Termios 11 | -------------------------------------------------------------------------------- /vendor/jrubin.io/slog/handlers/text/terminal_linux.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2013 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 | package text 7 | 8 | import "syscall" 9 | 10 | const ioctlReadTermios = syscall.TCGETS 11 | 12 | // Termios is syscall.Termios 13 | type Termios syscall.Termios 14 | -------------------------------------------------------------------------------- /vendor/jrubin.io/slog/handlers/text/terminal_notwindows.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2011 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 | // +build linux darwin freebsd openbsd netbsd dragonfly 7 | 8 | package text 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | // IsTerminal returns true if stderr's file descriptor is a terminal. 16 | func IsTerminal() bool { 17 | fd := syscall.Stderr 18 | var termios Termios 19 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 20 | return err == 0 21 | } 22 | -------------------------------------------------------------------------------- /vendor/jrubin.io/slog/handlers/text/terminal_solaris.go: -------------------------------------------------------------------------------- 1 | // +build solaris 2 | 3 | package text 4 | 5 | import ( 6 | "os" 7 | 8 | "golang.org/x/sys/unix" 9 | ) 10 | 11 | // IsTerminal returns true if the given file descriptor is a terminal. 12 | func IsTerminal() bool { 13 | _, err := unix.IoctlGetTermios(int(os.Stdout.Fd()), unix.TCGETA) 14 | return err == nil 15 | } 16 | -------------------------------------------------------------------------------- /vendor/jrubin.io/slog/handlers/text/terminal_windows.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2011 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 | // +build windows 7 | 8 | package text 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | var kernel32 = syscall.NewLazyDLL("kernel32.dll") 16 | 17 | var ( 18 | procGetConsoleMode = kernel32.NewProc("GetConsoleMode") 19 | ) 20 | 21 | // IsTerminal returns true if stderr's file descriptor is a terminal. 22 | func IsTerminal() bool { 23 | fd := syscall.Stderr 24 | var st uint32 25 | r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0) 26 | return r != 0 && e == 0 27 | } 28 | -------------------------------------------------------------------------------- /vendor/jrubin.io/slog/import.go: -------------------------------------------------------------------------------- 1 | package slog // import "jrubin.io/slog" 2 | -------------------------------------------------------------------------------- /vendor/jrubin.io/slog/interface.go: -------------------------------------------------------------------------------- 1 | package slog 2 | 3 | import "io" 4 | 5 | // PrefixWriteCloser is an io.WriteCloser that can be prefixed for every line 6 | // it writes 7 | type PrefixWriteCloser interface { 8 | io.WriteCloser 9 | Prefix(prefix string) PrefixWriteCloser 10 | } 11 | 12 | // Interface represents the API of both Logger and Entry. 13 | type Interface interface { 14 | WithFields(fields Fielder) *Entry 15 | WithField(key string, value interface{}) *Entry 16 | WithError(err error) *Entry 17 | Debug(msg string) 18 | Info(msg string) 19 | Warn(msg string) 20 | Error(msg string) 21 | Fatal(msg string) 22 | Panic(msg string) 23 | IfError(error) Interface 24 | Trace(level Level, msg string) *Entry 25 | Writer(level Level) PrefixWriteCloser 26 | } 27 | -------------------------------------------------------------------------------- /vendor/jrubin.io/slog/levels.go: -------------------------------------------------------------------------------- 1 | package slog 2 | 3 | import ( 4 | "strconv" 5 | "unicode" 6 | "unicode/utf8" 7 | ) 8 | 9 | // Level of severity. 10 | type Level int 11 | 12 | // Log levels. 13 | const ( 14 | PanicLevel Level = iota 15 | FatalLevel 16 | ErrorLevel 17 | WarnLevel 18 | InfoLevel 19 | DebugLevel 20 | ) 21 | 22 | var levelNames = [...]string{ 23 | PanicLevel: "panic", 24 | FatalLevel: "fatal", 25 | ErrorLevel: "error", 26 | WarnLevel: "warn", 27 | InfoLevel: "info", 28 | DebugLevel: "debug", 29 | } 30 | 31 | // Set implements cli.Generic 32 | func (l *Level) Set(value string) error { 33 | *l = ParseLevel(value, WarnLevel) 34 | return nil 35 | } 36 | 37 | // String implements io.Stringer. 38 | func (l Level) String() string { 39 | if l < PanicLevel { 40 | l = PanicLevel 41 | } 42 | 43 | if l > DebugLevel { 44 | l = DebugLevel 45 | } 46 | 47 | return levelNames[l] 48 | } 49 | 50 | // MarshalJSON returns the level string. 51 | func (l Level) MarshalJSON() ([]byte, error) { 52 | return []byte(`"` + l.String() + `"`), nil 53 | } 54 | 55 | // MarshalText implements encoding.TextMarshaler 56 | func (l Level) MarshalText() ([]byte, error) { 57 | return []byte(l.String()), nil 58 | } 59 | 60 | // UnmarshalText implements encoding.TextUnmarshaler 61 | func (l *Level) UnmarshalText(text []byte) error { 62 | *l = ParseLevel(string(text), WarnLevel) 63 | return nil 64 | } 65 | 66 | // ParseLevel parses level string. 67 | func ParseLevel(s string, defaultLevel Level) Level { 68 | if len(s) == 0 { 69 | return defaultLevel 70 | } 71 | 72 | if i, err := strconv.Atoi(s); err == nil { 73 | l := Level(i) 74 | 75 | if l < PanicLevel { 76 | l = PanicLevel 77 | } 78 | 79 | if l > DebugLevel { 80 | l = DebugLevel 81 | } 82 | 83 | return l 84 | } 85 | 86 | r, _ := utf8.DecodeRuneInString(s) 87 | r = unicode.ToLower(r) 88 | 89 | switch r { 90 | case 'd': 91 | return DebugLevel 92 | case 'i': 93 | return InfoLevel 94 | case 'w': 95 | return WarnLevel 96 | case 'e': 97 | return ErrorLevel 98 | case 'f': 99 | return FatalLevel 100 | case 'p': 101 | return PanicLevel 102 | } 103 | 104 | return defaultLevel 105 | } 106 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-billy.v1/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Sourced Technologies S.L. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do 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 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-billy.v1/README.md: -------------------------------------------------------------------------------- 1 | # go-billy [![GoDoc](https://godoc.org/srcd.works/go-billy.v1?status.svg)](https://godoc.org/srcd.works/go-billy.v1) [![Build Status](https://travis-ci.org/src-d/go-billy.svg)](https://travis-ci.org/src-d/go-billy) [![codebeat badge](https://codebeat.co/badges/03bdec03-b477-4472-bbe3-b552e3799174)](https://codebeat.co/projects/github-com-src-d-go-billy) 2 | 3 | An interface to abstract several storages. 4 | 5 | This library was extracted from 6 | [src-d/go-git](https://github.com/src-d/go-git). 7 | 8 | ## Installation 9 | 10 | ```go 11 | go get -u srcd.works/go-billy.v1/... 12 | ``` 13 | 14 | ## Why billy? 15 | 16 | The library billy deals with storage systems and Billy is the name of a well-known, IKEA 17 | bookcase. That's it. 18 | 19 | ## Usage 20 | 21 | Billy exposes filesystems using the 22 | [`Filesystem` interface](https://godoc.org/github.com/src-d/go-billy#Filesystem). 23 | Each filesystem implementation gives you a `New` method, whose arguments depend on 24 | the implementation itself, that returns a new `Filesystem`. 25 | 26 | The following example caches in memory all readable files in a directory from any 27 | billy's filesystem implementation. 28 | 29 | ```go 30 | func LoadToMemory(fs billy.Filesystem, path string) (*memory.Memory, error) { 31 | memory := memory.New() 32 | 33 | files, err := fs.ReadDir("/") 34 | if err != nil { 35 | return nil, err 36 | } 37 | 38 | for _, file := range files { 39 | if !file.IsDir() { 40 | orig, err := fs.Open(file.Name()) 41 | if err != nil { 42 | continue 43 | } 44 | 45 | dest, err := memory.Create(file.Name()) 46 | if err != nil { 47 | continue 48 | } 49 | 50 | if _, err = io.Copy(dest, orig); err != nil { 51 | return nil, err 52 | } 53 | } 54 | } 55 | 56 | return memory, nil 57 | } 58 | ``` 59 | 60 | ## License 61 | 62 | MIT, see [LICENSE](LICENSE) 63 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-billy.v1/fs.go: -------------------------------------------------------------------------------- 1 | package billy 2 | 3 | import ( 4 | "errors" 5 | "io" 6 | "os" 7 | ) 8 | 9 | var ( 10 | ErrClosed = errors.New("file: Writing on closed file.") 11 | ErrReadOnly = errors.New("this is a read-only filesystem") 12 | ErrNotSupported = errors.New("feature not supported") 13 | ) 14 | 15 | // Filesystem abstract the operations in a storage-agnostic interface. 16 | // It allows you to: 17 | // * Create files. 18 | // * Open existing files. 19 | // * Get info about files. 20 | // * List files in a directory. 21 | // * Get a temporal file. 22 | // * Rename files. 23 | // * Remove files. 24 | // * Join parts of path. 25 | // * Obtain a filesystem starting on a subdirectory in the current filesystem. 26 | // * Get the base path for the filesystem. 27 | // Each method implementation varies from implementation to implementation. Refer to 28 | // the specific documentation for more info. 29 | type Filesystem interface { 30 | Create(filename string) (File, error) 31 | Open(filename string) (File, error) 32 | OpenFile(filename string, flag int, perm os.FileMode) (File, error) 33 | Stat(filename string) (FileInfo, error) 34 | ReadDir(path string) ([]FileInfo, error) 35 | TempFile(dir, prefix string) (File, error) 36 | Rename(from, to string) error 37 | Remove(filename string) error 38 | Join(elem ...string) string 39 | Dir(path string) Filesystem 40 | Base() string 41 | } 42 | 43 | // File implements io.Closer, io.Reader, io.Seeker, and io.Writer> 44 | // Provides method to obtain the file name and the state of the file (open or closed). 45 | type File interface { 46 | Filename() string 47 | IsClosed() bool 48 | io.Writer 49 | io.Reader 50 | io.Seeker 51 | io.Closer 52 | } 53 | 54 | type FileInfo os.FileInfo 55 | 56 | type BaseFile struct { 57 | BaseFilename string 58 | Closed bool 59 | } 60 | 61 | func (f *BaseFile) Filename() string { 62 | return f.BaseFilename 63 | } 64 | 65 | func (f *BaseFile) IsClosed() bool { 66 | return f.Closed 67 | } 68 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Sourced Technologies S.L. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do 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 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/Makefile: -------------------------------------------------------------------------------- 1 | # General 2 | WORKDIR = $(PWD) 3 | 4 | # Go parameters 5 | GOCMD = go 6 | GOTEST = $(GOCMD) test -v 7 | 8 | # Git config 9 | GIT_VERSION ?= 10 | GIT_DIST_PATH ?= $(PWD)/.git-dist 11 | GIT_REPOSITORY = http://github.com/git/git.git 12 | 13 | # Coverage 14 | COVERAGE_REPORT = coverage.txt 15 | COVERAGE_PROFILE = profile.out 16 | COVERAGE_MODE = atomic 17 | 18 | ifneq ($(origin CI), undefined) 19 | WORKDIR := $(GOPATH)/src/srcd.works/go-git.v4 20 | endif 21 | 22 | build-git: 23 | @if [ -f $(GIT_DIST_PATH)/git ]; then \ 24 | echo "nothing to do, using cache $(GIT_DIST_PATH)"; \ 25 | else \ 26 | git clone $(GIT_REPOSITORY) -b $(GIT_VERSION) --depth 1 --single-branch $(GIT_DIST_PATH); \ 27 | cd $(GIT_DIST_PATH); \ 28 | make configure; \ 29 | ./configure; \ 30 | make all; \ 31 | fi 32 | 33 | test: 34 | cd $(WORKDIR); \ 35 | $(GOTEST) ./... 36 | 37 | test-coverage: 38 | cd $(WORKDIR); \ 39 | echo "" > $(COVERAGE_REPORT); \ 40 | for dir in `find . -name "*.go" | grep -o '.*/' | sort | uniq`; do \ 41 | $(GOTEST) $$dir -coverprofile=$(COVERAGE_PROFILE) -covermode=$(COVERAGE_MODE); \ 42 | if [ $$? != 0 ]; then \ 43 | exit 2; \ 44 | fi; \ 45 | if [ -f $(COVERAGE_PROFILE) ]; then \ 46 | cat $(COVERAGE_PROFILE) >> $(COVERAGE_REPORT); \ 47 | rm $(COVERAGE_PROFILE); \ 48 | fi; \ 49 | done; \ 50 | 51 | clean: 52 | rm -rf $(GIT_DIST_PATH) -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/cache/common.go: -------------------------------------------------------------------------------- 1 | package cache 2 | 3 | import "srcd.works/go-git.v4/plumbing" 4 | 5 | const ( 6 | Byte = 1 << (iota * 10) 7 | KiByte 8 | MiByte 9 | GiByte 10 | ) 11 | 12 | type Object interface { 13 | Add(o plumbing.EncodedObject) 14 | Get(k plumbing.Hash) plumbing.EncodedObject 15 | Clear() 16 | } 17 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/cache/object.go: -------------------------------------------------------------------------------- 1 | package cache 2 | 3 | import "srcd.works/go-git.v4/plumbing" 4 | 5 | const ( 6 | initialQueueSize = 20 7 | MaxSize = 10 * MiByte 8 | ) 9 | 10 | type ObjectFIFO struct { 11 | objects map[plumbing.Hash]plumbing.EncodedObject 12 | order *queue 13 | 14 | maxSize int64 15 | actualSize int64 16 | } 17 | 18 | // NewObjectFIFO returns an Object cache that keeps the newest objects that fit 19 | // into the specific memory size 20 | func NewObjectFIFO(size int64) *ObjectFIFO { 21 | return &ObjectFIFO{ 22 | objects: make(map[plumbing.Hash]plumbing.EncodedObject), 23 | order: newQueue(initialQueueSize), 24 | maxSize: size, 25 | } 26 | } 27 | 28 | // Add adds a new object to the cache. If the object size is greater than the 29 | // cache size, the object is not added. 30 | func (c *ObjectFIFO) Add(o plumbing.EncodedObject) { 31 | // if the size of the object is bigger or equal than the cache size, 32 | // skip it 33 | if o.Size() >= c.maxSize { 34 | return 35 | } 36 | 37 | // if the object is into the cache, do not add it again 38 | if _, ok := c.objects[o.Hash()]; ok { 39 | return 40 | } 41 | 42 | // delete the oldest object if cache is full 43 | if c.actualSize >= c.maxSize { 44 | h := c.order.Pop() 45 | o := c.objects[h] 46 | if o != nil { 47 | c.actualSize -= o.Size() 48 | delete(c.objects, h) 49 | } 50 | } 51 | 52 | c.objects[o.Hash()] = o 53 | c.order.Push(o.Hash()) 54 | c.actualSize += o.Size() 55 | } 56 | 57 | // Get returns an object by his hash. If the object is not found in the cache, it 58 | // returns nil 59 | func (c *ObjectFIFO) Get(k plumbing.Hash) plumbing.EncodedObject { 60 | return c.objects[k] 61 | } 62 | 63 | // Clear the content of this object cache 64 | func (c *ObjectFIFO) Clear() { 65 | c.objects = make(map[plumbing.Hash]plumbing.EncodedObject) 66 | c.order = newQueue(initialQueueSize) 67 | c.actualSize = 0 68 | } 69 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/cache/queue.go: -------------------------------------------------------------------------------- 1 | package cache 2 | 3 | import "srcd.works/go-git.v4/plumbing" 4 | 5 | // queue is a basic FIFO queue based on a circular list that resize as needed. 6 | type queue struct { 7 | elements []plumbing.Hash 8 | size int 9 | head int 10 | tail int 11 | count int 12 | } 13 | 14 | // newQueue returns a queue with the specified initial size 15 | func newQueue(size int) *queue { 16 | return &queue{ 17 | elements: make([]plumbing.Hash, size), 18 | size: size, 19 | } 20 | } 21 | 22 | // Push adds a node to the queue. 23 | func (q *queue) Push(h plumbing.Hash) { 24 | if q.head == q.tail && q.count > 0 { 25 | elements := make([]plumbing.Hash, len(q.elements)+q.size) 26 | copy(elements, q.elements[q.head:]) 27 | copy(elements[len(q.elements)-q.head:], q.elements[:q.head]) 28 | q.head = 0 29 | q.tail = len(q.elements) 30 | q.elements = elements 31 | } 32 | q.elements[q.tail] = h 33 | q.tail = (q.tail + 1) % len(q.elements) 34 | q.count++ 35 | } 36 | 37 | // Pop removes and returns a Hash from the queue in first to last order. 38 | func (q *queue) Pop() plumbing.Hash { 39 | if q.count == 0 { 40 | return plumbing.ZeroHash 41 | } 42 | node := q.elements[q.head] 43 | q.head = (q.head + 1) % len(q.elements) 44 | q.count-- 45 | return node 46 | } 47 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/common.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | import ( 4 | "strings" 5 | 6 | "srcd.works/go-git.v4/config" 7 | "srcd.works/go-git.v4/plumbing/storer" 8 | ) 9 | 10 | // Storer is a generic storage of objects, references and any information 11 | // related to a particular repository. Some Storer implementations persist the 12 | // information in a system directory (such as `.git`) and others 13 | // implementations are in memory being ephemeral 14 | type Storer interface { 15 | storer.EncodedObjectStorer 16 | storer.ReferenceStorer 17 | storer.ShallowStorer 18 | storer.IndexStorer 19 | config.ConfigStorer 20 | } 21 | 22 | // countLines returns the number of lines in a string à la git, this is 23 | // The newline character is assumed to be '\n'. The empty string 24 | // contains 0 lines. If the last line of the string doesn't end with a 25 | // newline, it will still be considered a line. 26 | func countLines(s string) int { 27 | if s == "" { 28 | return 0 29 | } 30 | 31 | nEOL := strings.Count(s, "\n") 32 | if strings.HasSuffix(s, "\n") { 33 | return nEOL 34 | } 35 | 36 | return nEOL + 1 37 | } 38 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/doc.go: -------------------------------------------------------------------------------- 1 | // Package git is a low level and highly extensible git client library for 2 | // reading repositories from git servers. It is written in Go from scratch, 3 | // without any C dependencies. 4 | // 5 | // We have been following the open/close principle in its design to facilitate 6 | // extensions. 7 | // 8 | // Small example extracting the commits from a repository: 9 | // 10 | // func ExampleBasic_printCommits() { 11 | // r := git.NewMemoryRepository() 12 | // o := &git.CloneOptions{ 13 | // URL: "https://github.com/src-d/go-git", 14 | // } 15 | // if err := r.Clone(o); err != nil { 16 | // panic(err) 17 | // } 18 | // 19 | // iter, err := r.Commits() 20 | // if err != nil { 21 | // panic(err) 22 | // } 23 | // defer iter.Close() 24 | // 25 | // for { 26 | // commit, err := iter.Next() 27 | // if err != nil { 28 | // if err == io.EOF { 29 | // break 30 | // } 31 | // panic(err) 32 | // } 33 | // 34 | // fmt.Println(commit) 35 | // } 36 | // } 37 | package git // import "srcd.works/go-git.v4" 38 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/plumbing/error.go: -------------------------------------------------------------------------------- 1 | package plumbing 2 | 3 | import "fmt" 4 | 5 | type PermanentError struct { 6 | Err error 7 | } 8 | 9 | func NewPermanentError(err error) *PermanentError { 10 | if err == nil { 11 | return nil 12 | } 13 | 14 | return &PermanentError{Err: err} 15 | } 16 | 17 | func (e *PermanentError) Error() string { 18 | return fmt.Sprintf("permanent client error: %s", e.Err.Error()) 19 | } 20 | 21 | type UnexpectedError struct { 22 | Err error 23 | } 24 | 25 | func NewUnexpectedError(err error) *UnexpectedError { 26 | if err == nil { 27 | return nil 28 | } 29 | 30 | return &UnexpectedError{Err: err} 31 | } 32 | 33 | func (e *UnexpectedError) Error() string { 34 | return fmt.Sprintf("unexpected client error: %s", e.Err.Error()) 35 | } 36 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/plumbing/format/config/decoder.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "io" 5 | 6 | "github.com/src-d/gcfg" 7 | ) 8 | 9 | // A Decoder reads and decodes config files from an input stream. 10 | type Decoder struct { 11 | io.Reader 12 | } 13 | 14 | // NewDecoder returns a new decoder that reads from r. 15 | func NewDecoder(r io.Reader) *Decoder { 16 | return &Decoder{r} 17 | } 18 | 19 | // Decode reads the whole config from its input and stores it in the 20 | // value pointed to by config. 21 | func (d *Decoder) Decode(config *Config) error { 22 | cb := func(s string, ss string, k string, v string, bv bool) error { 23 | if ss == "" && k == "" { 24 | config.Section(s) 25 | return nil 26 | } 27 | 28 | if ss != "" && k == "" { 29 | config.Section(s).Subsection(ss) 30 | return nil 31 | } 32 | 33 | config.AddOption(s, ss, k, v) 34 | return nil 35 | } 36 | return gcfg.ReadWithCallback(d, cb) 37 | } 38 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/plumbing/format/config/encoder.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | ) 7 | 8 | // An Encoder writes config files to an output stream. 9 | type Encoder struct { 10 | w io.Writer 11 | } 12 | 13 | // NewEncoder returns a new encoder that writes to w. 14 | func NewEncoder(w io.Writer) *Encoder { 15 | return &Encoder{w} 16 | } 17 | 18 | // Encode writes the config in git config format to the stream of the encoder. 19 | func (e *Encoder) Encode(cfg *Config) error { 20 | for _, s := range cfg.Sections { 21 | if err := e.encodeSection(s); err != nil { 22 | return err 23 | } 24 | } 25 | 26 | return nil 27 | } 28 | 29 | func (e *Encoder) encodeSection(s *Section) error { 30 | if len(s.Options) > 0 { 31 | if err := e.printf("[%s]\n", s.Name); err != nil { 32 | return err 33 | } 34 | 35 | if err := e.encodeOptions(s.Options); err != nil { 36 | return err 37 | } 38 | } 39 | 40 | for _, ss := range s.Subsections { 41 | if err := e.encodeSubsection(s.Name, ss); err != nil { 42 | return err 43 | } 44 | } 45 | 46 | return nil 47 | } 48 | 49 | func (e *Encoder) encodeSubsection(sectionName string, s *Subsection) error { 50 | //TODO: escape 51 | if err := e.printf("[%s \"%s\"]\n", sectionName, s.Name); err != nil { 52 | return err 53 | } 54 | 55 | if err := e.encodeOptions(s.Options); err != nil { 56 | return err 57 | } 58 | 59 | return nil 60 | } 61 | 62 | func (e *Encoder) encodeOptions(opts Options) error { 63 | for _, o := range opts { 64 | if err := e.printf("\t%s = %s\n", o.Key, o.Value); err != nil { 65 | return err 66 | } 67 | } 68 | 69 | return nil 70 | } 71 | 72 | func (e *Encoder) printf(msg string, args ...interface{}) error { 73 | _, err := fmt.Fprintf(e.w, msg, args...) 74 | return err 75 | } 76 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/plumbing/format/config/option.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "strings" 5 | ) 6 | 7 | type Option struct { 8 | // Key preserving original caseness. 9 | // Use IsKey instead to compare key regardless of caseness. 10 | Key string 11 | // Original value as string, could be not normalized. 12 | Value string 13 | } 14 | 15 | type Options []*Option 16 | 17 | // IsKey returns true if the given key matches 18 | // this option's key in a case-insensitive comparison. 19 | func (o *Option) IsKey(key string) bool { 20 | return strings.ToLower(o.Key) == strings.ToLower(key) 21 | } 22 | 23 | // Get gets the value for the given key if set, 24 | // otherwise it returns the empty string. 25 | // 26 | // Note that there is no difference 27 | // 28 | // This matches git behaviour since git v1.8.1-rc1, 29 | // if there are multiple definitions of a key, the 30 | // last one wins. 31 | // 32 | // See: http://article.gmane.org/gmane.linux.kernel/1407184 33 | // 34 | // In order to get all possible values for the same key, 35 | // use GetAll. 36 | func (opts Options) Get(key string) string { 37 | for i := len(opts) - 1; i >= 0; i-- { 38 | o := opts[i] 39 | if o.IsKey(key) { 40 | return o.Value 41 | } 42 | } 43 | return "" 44 | } 45 | 46 | // GetAll returns all possible values for the same key. 47 | func (opts Options) GetAll(key string) []string { 48 | result := []string{} 49 | for _, o := range opts { 50 | if o.IsKey(key) { 51 | result = append(result, o.Value) 52 | } 53 | } 54 | return result 55 | } 56 | 57 | func (opts Options) withoutOption(key string) Options { 58 | result := Options{} 59 | for _, o := range opts { 60 | if !o.IsKey(key) { 61 | result = append(result, o) 62 | } 63 | } 64 | return result 65 | } 66 | 67 | func (opts Options) withAddedOption(key string, value string) Options { 68 | return append(opts, &Option{key, value}) 69 | } 70 | 71 | func (opts Options) withSettedOption(key string, value string) Options { 72 | for i := len(opts) - 1; i >= 0; i-- { 73 | o := opts[i] 74 | if o.IsKey(key) { 75 | result := make(Options, len(opts)) 76 | copy(result, opts) 77 | result[i] = &Option{key, value} 78 | return result 79 | } 80 | } 81 | 82 | return opts.withAddedOption(key, value) 83 | } 84 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/plumbing/format/config/section.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import "strings" 4 | 5 | type Section struct { 6 | Name string 7 | Options Options 8 | Subsections Subsections 9 | } 10 | 11 | type Subsection struct { 12 | Name string 13 | Options Options 14 | } 15 | 16 | type Sections []*Section 17 | 18 | type Subsections []*Subsection 19 | 20 | func (s *Section) IsName(name string) bool { 21 | return strings.ToLower(s.Name) == strings.ToLower(name) 22 | } 23 | 24 | func (s *Section) Option(key string) string { 25 | return s.Options.Get(key) 26 | } 27 | 28 | func (s *Section) AddOption(key string, value string) *Section { 29 | s.Options = s.Options.withAddedOption(key, value) 30 | return s 31 | } 32 | 33 | func (s *Section) SetOption(key string, value string) *Section { 34 | s.Options = s.Options.withSettedOption(key, value) 35 | return s 36 | } 37 | 38 | func (s *Section) RemoveOption(key string) *Section { 39 | s.Options = s.Options.withoutOption(key) 40 | return s 41 | } 42 | 43 | func (s *Section) Subsection(name string) *Subsection { 44 | for i := len(s.Subsections) - 1; i >= 0; i-- { 45 | ss := s.Subsections[i] 46 | if ss.IsName(name) { 47 | return ss 48 | } 49 | } 50 | 51 | ss := &Subsection{Name: name} 52 | s.Subsections = append(s.Subsections, ss) 53 | return ss 54 | } 55 | 56 | func (s *Section) HasSubsection(name string) bool { 57 | for _, ss := range s.Subsections { 58 | if ss.IsName(name) { 59 | return true 60 | } 61 | } 62 | 63 | return false 64 | } 65 | 66 | func (s *Subsection) IsName(name string) bool { 67 | return s.Name == name 68 | } 69 | 70 | func (s *Subsection) Option(key string) string { 71 | return s.Options.Get(key) 72 | } 73 | 74 | func (s *Subsection) AddOption(key string, value string) *Subsection { 75 | s.Options = s.Options.withAddedOption(key, value) 76 | return s 77 | } 78 | 79 | func (s *Subsection) SetOption(key string, value string) *Subsection { 80 | s.Options = s.Options.withSettedOption(key, value) 81 | return s 82 | } 83 | 84 | func (s *Subsection) RemoveOption(key string) *Subsection { 85 | s.Options = s.Options.withoutOption(key) 86 | return s 87 | } 88 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/plumbing/format/idxfile/idxfile.go: -------------------------------------------------------------------------------- 1 | package idxfile 2 | 3 | import "srcd.works/go-git.v4/plumbing" 4 | 5 | const ( 6 | // VersionSupported is the only idx version supported. 7 | VersionSupported = 2 8 | ) 9 | 10 | var ( 11 | idxHeader = []byte{255, 't', 'O', 'c'} 12 | ) 13 | 14 | // An Idxfile represents an idx file in memory. 15 | type Idxfile struct { 16 | Version uint32 17 | Fanout [255]uint32 18 | ObjectCount uint32 19 | Entries EntryList 20 | PackfileChecksum [20]byte 21 | IdxChecksum [20]byte 22 | } 23 | 24 | // An Entry represents data about an object in the packfile: its hash, 25 | // offset and CRC32 checksum. 26 | type Entry struct { 27 | Hash plumbing.Hash 28 | CRC32 uint32 29 | Offset uint64 30 | } 31 | 32 | func (idx *Idxfile) Add(h plumbing.Hash, offset uint64, crc32 uint32) { 33 | idx.Entries = append(idx.Entries, Entry{ 34 | Hash: h, 35 | Offset: offset, 36 | CRC32: crc32, 37 | }) 38 | } 39 | 40 | func (idx *Idxfile) isValid() bool { 41 | fanout := idx.calculateFanout() 42 | for k, c := range idx.Fanout { 43 | if fanout[k] != c { 44 | return false 45 | } 46 | } 47 | 48 | return true 49 | } 50 | 51 | func (idx *Idxfile) calculateFanout() [256]uint32 { 52 | fanout := [256]uint32{} 53 | for _, e := range idx.Entries { 54 | fanout[e.Hash[0]]++ 55 | } 56 | 57 | for i := 1; i < 256; i++ { 58 | fanout[i] += fanout[i-1] 59 | } 60 | 61 | return fanout 62 | } 63 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/plumbing/format/packfile/common.go: -------------------------------------------------------------------------------- 1 | package packfile 2 | 3 | import ( 4 | "io" 5 | 6 | "srcd.works/go-git.v4/plumbing/storer" 7 | ) 8 | 9 | var signature = []byte{'P', 'A', 'C', 'K'} 10 | 11 | const ( 12 | // VersionSupported is the packfile version supported by this package 13 | VersionSupported uint32 = 2 14 | 15 | firstLengthBits = uint8(4) // the first byte into object header has 4 bits to store the length 16 | lengthBits = uint8(7) // subsequent bytes has 7 bits to store the length 17 | maskFirstLength = 15 // 0000 1111 18 | maskContinue = 0x80 // 1000 0000 19 | maskLength = uint8(127) // 0111 1111 20 | maskType = uint8(112) // 0111 0000 21 | ) 22 | 23 | // UpdateObjectStorage updates the given storer.EncodedObjectStorer with the contents of the 24 | // packfile. 25 | func UpdateObjectStorage(s storer.EncodedObjectStorer, packfile io.Reader) error { 26 | if sw, ok := s.(storer.PackfileWriter); ok { 27 | w, err := sw.PackfileWriter() 28 | if err != nil { 29 | return err 30 | } 31 | 32 | defer w.Close() 33 | _, err = io.Copy(w, packfile) 34 | return err 35 | } 36 | 37 | stream := NewScanner(packfile) 38 | d, err := NewDecoder(stream, s) 39 | if err != nil { 40 | return err 41 | } 42 | 43 | _, err = d.Decode() 44 | return err 45 | } 46 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/plumbing/format/packfile/error.go: -------------------------------------------------------------------------------- 1 | package packfile 2 | 3 | import "fmt" 4 | 5 | // Error specifies errors returned during packfile parsing. 6 | type Error struct { 7 | reason, details string 8 | } 9 | 10 | // NewError returns a new error. 11 | func NewError(reason string) *Error { 12 | return &Error{reason: reason} 13 | } 14 | 15 | // Error returns a text representation of the error. 16 | func (e *Error) Error() string { 17 | if e.details == "" { 18 | return e.reason 19 | } 20 | 21 | return fmt.Sprintf("%s: %s", e.reason, e.details) 22 | } 23 | 24 | // AddDetails adds details to an error, with additional text. 25 | func (e *Error) AddDetails(format string, args ...interface{}) *Error { 26 | return &Error{ 27 | reason: e.reason, 28 | details: fmt.Sprintf(format, args...), 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/plumbing/format/packfile/object_pack.go: -------------------------------------------------------------------------------- 1 | package packfile 2 | 3 | import "srcd.works/go-git.v4/plumbing" 4 | 5 | // ObjectToPack is a representation of an object that is going to be into a 6 | // pack file. 7 | type ObjectToPack struct { 8 | // The main object to pack, it could be any object, including deltas 9 | Object plumbing.EncodedObject 10 | // Base is the object that a delta is based on (it could be also another delta). 11 | // If the main object is not a delta, Base will be null 12 | Base *ObjectToPack 13 | // Original is the object that we can generate applying the delta to 14 | // Base, or the same object as EncodedObject in the case of a non-delta 15 | // object. 16 | Original plumbing.EncodedObject 17 | // Depth is the amount of deltas needed to resolve to obtain Original 18 | // (delta based on delta based on ...) 19 | Depth int 20 | } 21 | 22 | // newObjectToPack creates a correct ObjectToPack based on a non-delta object 23 | func newObjectToPack(o plumbing.EncodedObject) *ObjectToPack { 24 | return &ObjectToPack{ 25 | Object: o, 26 | Original: o, 27 | } 28 | } 29 | 30 | // newDeltaObjectToPack creates a correct ObjectToPack for a delta object, based on 31 | // his base (could be another delta), the delta target (in this case called original), 32 | // and the delta Object itself 33 | func newDeltaObjectToPack(base *ObjectToPack, original, delta plumbing.EncodedObject) *ObjectToPack { 34 | return &ObjectToPack{ 35 | Object: delta, 36 | Base: base, 37 | Original: original, 38 | Depth: base.Depth + 1, 39 | } 40 | } 41 | 42 | func (o *ObjectToPack) IsDelta() bool { 43 | if o.Base != nil { 44 | return true 45 | } 46 | 47 | return false 48 | } 49 | 50 | func (o *ObjectToPack) SetDelta(base *ObjectToPack, delta plumbing.EncodedObject) { 51 | o.Object = delta 52 | o.Base = base 53 | o.Depth = base.Depth + 1 54 | } 55 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/plumbing/hash.go: -------------------------------------------------------------------------------- 1 | package plumbing 2 | 3 | import ( 4 | "bytes" 5 | "crypto/sha1" 6 | "encoding/hex" 7 | "hash" 8 | "sort" 9 | "strconv" 10 | ) 11 | 12 | // Hash SHA1 hased content 13 | type Hash [20]byte 14 | 15 | // ZeroHash is Hash with value zero 16 | var ZeroHash Hash 17 | 18 | // ComputeHash compute the hash for a given ObjectType and content 19 | func ComputeHash(t ObjectType, content []byte) Hash { 20 | h := NewHasher(t, int64(len(content))) 21 | h.Write(content) 22 | return h.Sum() 23 | } 24 | 25 | // NewHash return a new Hash from a hexadecimal hash representation 26 | func NewHash(s string) Hash { 27 | b, _ := hex.DecodeString(s) 28 | 29 | var h Hash 30 | copy(h[:], b) 31 | 32 | return h 33 | } 34 | 35 | func (h Hash) IsZero() bool { 36 | var empty Hash 37 | return h == empty 38 | } 39 | 40 | func (h Hash) String() string { 41 | return hex.EncodeToString(h[:]) 42 | } 43 | 44 | type Hasher struct { 45 | hash.Hash 46 | } 47 | 48 | func NewHasher(t ObjectType, size int64) Hasher { 49 | h := Hasher{sha1.New()} 50 | h.Write(t.Bytes()) 51 | h.Write([]byte(" ")) 52 | h.Write([]byte(strconv.FormatInt(size, 10))) 53 | h.Write([]byte{0}) 54 | return h 55 | } 56 | 57 | func (h Hasher) Sum() (hash Hash) { 58 | copy(hash[:], h.Hash.Sum(nil)) 59 | return 60 | } 61 | 62 | // HashesSort sorts a slice of Hashes in increasing order. 63 | func HashesSort(a []Hash) { 64 | sort.Sort(HashSlice(a)) 65 | } 66 | 67 | // HashSlice attaches the methods of sort.Interface to []Hash, sorting in 68 | // increasing order. 69 | type HashSlice []Hash 70 | 71 | func (p HashSlice) Len() int { return len(p) } 72 | func (p HashSlice) Less(i, j int) bool { return bytes.Compare(p[i][:], p[j][:]) < 0 } 73 | func (p HashSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } 74 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/plumbing/memory.go: -------------------------------------------------------------------------------- 1 | package plumbing 2 | 3 | import ( 4 | "bytes" 5 | "io" 6 | "io/ioutil" 7 | ) 8 | 9 | // MemoryObject on memory Object implementation 10 | type MemoryObject struct { 11 | t ObjectType 12 | h Hash 13 | cont []byte 14 | sz int64 15 | } 16 | 17 | // Hash return the object Hash, the hash is calculated on-the-fly the first 18 | // time is called, the subsequent calls the same Hash is returned even if the 19 | // type or the content has changed. The Hash is only generated if the size of 20 | // the content is exactly the Object.Size 21 | func (o *MemoryObject) Hash() Hash { 22 | if o.h == ZeroHash && int64(len(o.cont)) == o.sz { 23 | o.h = ComputeHash(o.t, o.cont) 24 | } 25 | 26 | return o.h 27 | } 28 | 29 | // Type return the ObjectType 30 | func (o *MemoryObject) Type() ObjectType { return o.t } 31 | 32 | // SetType sets the ObjectType 33 | func (o *MemoryObject) SetType(t ObjectType) { o.t = t } 34 | 35 | // Size return the size of the object 36 | func (o *MemoryObject) Size() int64 { return o.sz } 37 | 38 | // SetSize set the object size, a content of the given size should be written 39 | // afterwards 40 | func (o *MemoryObject) SetSize(s int64) { o.sz = s } 41 | 42 | // Reader returns a ObjectReader used to read the object's content. 43 | func (o *MemoryObject) Reader() (io.ReadCloser, error) { 44 | return ioutil.NopCloser(bytes.NewBuffer(o.cont)), nil 45 | } 46 | 47 | // Writer returns a ObjectWriter used to write the object's content. 48 | func (o *MemoryObject) Writer() (io.WriteCloser, error) { 49 | return o, nil 50 | } 51 | 52 | func (o *MemoryObject) Write(p []byte) (n int, err error) { 53 | o.cont = append(o.cont, p...) 54 | return len(p), nil 55 | } 56 | 57 | // Close releases any resources consumed by the object when it is acting as a 58 | // ObjectWriter. 59 | func (o *MemoryObject) Close() error { return nil } 60 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/plumbing/object/commit_walker.go: -------------------------------------------------------------------------------- 1 | package object 2 | 3 | import ( 4 | "io" 5 | 6 | "srcd.works/go-git.v4/plumbing" 7 | ) 8 | 9 | type commitWalker struct { 10 | seen map[plumbing.Hash]bool 11 | stack []*CommitIter 12 | start *Commit 13 | cb func(*Commit) error 14 | } 15 | 16 | // WalkCommitHistory walks the commit history 17 | func WalkCommitHistory(c *Commit, cb func(*Commit) error) error { 18 | w := &commitWalker{ 19 | seen: make(map[plumbing.Hash]bool), 20 | stack: make([]*CommitIter, 0), 21 | start: c, 22 | cb: cb, 23 | } 24 | 25 | return w.walk() 26 | } 27 | 28 | func (w *commitWalker) walk() error { 29 | var commit *Commit 30 | 31 | if w.start != nil { 32 | commit = w.start 33 | w.start = nil 34 | } else { 35 | current := len(w.stack) - 1 36 | if current < 0 { 37 | return nil 38 | } 39 | 40 | var err error 41 | commit, err = w.stack[current].Next() 42 | if err == io.EOF { 43 | w.stack = w.stack[:current] 44 | return w.walk() 45 | } 46 | 47 | if err != nil { 48 | return err 49 | } 50 | } 51 | 52 | // check and update seen 53 | if w.seen[commit.Hash] { 54 | return w.walk() 55 | } 56 | 57 | w.seen[commit.Hash] = true 58 | if commit.NumParents() > 0 { 59 | w.stack = append(w.stack, commit.Parents()) 60 | } 61 | 62 | if err := w.cb(commit); err != nil { 63 | return err 64 | } 65 | 66 | return w.walk() 67 | } 68 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/plumbing/protocol/packp/common.go: -------------------------------------------------------------------------------- 1 | package packp 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | type stateFn func() stateFn 8 | 9 | const ( 10 | // common 11 | hashSize = 40 12 | 13 | // advrefs 14 | head = "HEAD" 15 | noHead = "capabilities^{}" 16 | ) 17 | 18 | var ( 19 | // common 20 | sp = []byte(" ") 21 | eol = []byte("\n") 22 | eq = []byte{'='} 23 | 24 | // advertised-refs 25 | null = []byte("\x00") 26 | peeled = []byte("^{}") 27 | noHeadMark = []byte(" capabilities^{}\x00") 28 | 29 | // upload-request 30 | want = []byte("want ") 31 | shallow = []byte("shallow ") 32 | deepen = []byte("deepen") 33 | deepenCommits = []byte("deepen ") 34 | deepenSince = []byte("deepen-since ") 35 | deepenReference = []byte("deepen-not ") 36 | 37 | // shallow-update 38 | unshallow = []byte("unshallow ") 39 | 40 | // server-response 41 | ack = []byte("ACK") 42 | nak = []byte("NAK") 43 | 44 | // updreq 45 | shallowNoSp = []byte("shallow") 46 | ) 47 | 48 | func isFlush(payload []byte) bool { 49 | return len(payload) == 0 50 | } 51 | 52 | // ErrUnexpectedData represents an unexpected data decoding a message 53 | type ErrUnexpectedData struct { 54 | Msg string 55 | Data []byte 56 | } 57 | 58 | // NewErrUnexpectedData returns a new ErrUnexpectedData containing the data and 59 | // the message given 60 | func NewErrUnexpectedData(msg string, data []byte) error { 61 | return &ErrUnexpectedData{Msg: msg, Data: data} 62 | } 63 | 64 | func (err *ErrUnexpectedData) Error() string { 65 | if len(err.Data) == 0 { 66 | return err.Msg 67 | } 68 | 69 | return fmt.Sprintf("%s (%s)", err.Msg, err.Data) 70 | } 71 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/plumbing/protocol/packp/shallowupd.go: -------------------------------------------------------------------------------- 1 | package packp 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "io" 7 | 8 | "srcd.works/go-git.v4/plumbing" 9 | "srcd.works/go-git.v4/plumbing/format/pktline" 10 | ) 11 | 12 | const ( 13 | shallowLineLen = 48 14 | unshallowLineLen = 50 15 | ) 16 | 17 | type ShallowUpdate struct { 18 | Shallows []plumbing.Hash 19 | Unshallows []plumbing.Hash 20 | } 21 | 22 | func (r *ShallowUpdate) Decode(reader io.Reader) error { 23 | s := pktline.NewScanner(reader) 24 | 25 | for s.Scan() { 26 | line := s.Bytes() 27 | line = bytes.TrimSpace(line) 28 | 29 | var err error 30 | switch { 31 | case bytes.HasPrefix(line, shallow): 32 | err = r.decodeShallowLine(line) 33 | case bytes.HasPrefix(line, unshallow): 34 | err = r.decodeUnshallowLine(line) 35 | case bytes.Compare(line, pktline.Flush) == 0: 36 | return nil 37 | } 38 | 39 | if err != nil { 40 | return err 41 | } 42 | } 43 | 44 | return s.Err() 45 | } 46 | 47 | func (r *ShallowUpdate) decodeShallowLine(line []byte) error { 48 | hash, err := r.decodeLine(line, shallow, shallowLineLen) 49 | if err != nil { 50 | return err 51 | } 52 | 53 | r.Shallows = append(r.Shallows, hash) 54 | return nil 55 | } 56 | 57 | func (r *ShallowUpdate) decodeUnshallowLine(line []byte) error { 58 | hash, err := r.decodeLine(line, unshallow, unshallowLineLen) 59 | if err != nil { 60 | return err 61 | } 62 | 63 | r.Unshallows = append(r.Unshallows, hash) 64 | return nil 65 | } 66 | 67 | func (r *ShallowUpdate) decodeLine(line, prefix []byte, expLen int) (plumbing.Hash, error) { 68 | if len(line) != expLen { 69 | return plumbing.ZeroHash, fmt.Errorf("malformed %s%q", prefix, line) 70 | } 71 | 72 | raw := string(line[expLen-40 : expLen]) 73 | return plumbing.NewHash(raw), nil 74 | } 75 | 76 | func (r *ShallowUpdate) Encode(w io.Writer) error { 77 | e := pktline.NewEncoder(w) 78 | 79 | for _, h := range r.Shallows { 80 | if err := e.Encodef("%s%s\n", shallow, h.String()); err != nil { 81 | return err 82 | } 83 | } 84 | 85 | for _, h := range r.Unshallows { 86 | if err := e.Encodef("%s%s\n", unshallow, h.String()); err != nil { 87 | return err 88 | } 89 | } 90 | 91 | return e.Flush() 92 | } 93 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/plumbing/protocol/packp/sideband/common.go: -------------------------------------------------------------------------------- 1 | package sideband 2 | 3 | // Type sideband type "side-band" or "side-band-64k" 4 | type Type int8 5 | 6 | const ( 7 | // Sideband legacy sideband type up to 1000-byte messages 8 | Sideband Type = iota 9 | // Sideband64k sideband type up to 65519-byte messages 10 | Sideband64k Type = iota 11 | 12 | // MaxPackedSize for Sideband type 13 | MaxPackedSize = 1000 14 | // MaxPackedSize64k for Sideband64k type 15 | MaxPackedSize64k = 65520 16 | ) 17 | 18 | // Channel sideband channel 19 | type Channel byte 20 | 21 | // WithPayload encode the payload as a message 22 | func (ch Channel) WithPayload(payload []byte) []byte { 23 | return append([]byte{byte(ch)}, payload...) 24 | } 25 | 26 | const ( 27 | // PackData packfile content 28 | PackData Channel = 1 29 | // ProgressMessage progress messages 30 | ProgressMessage Channel = 2 31 | // ErrorMessage fatal error message just before stream aborts 32 | ErrorMessage Channel = 3 33 | ) 34 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/plumbing/protocol/packp/sideband/doc.go: -------------------------------------------------------------------------------- 1 | // Package sideband implements a sideband mutiplex/demultiplexer 2 | package sideband 3 | 4 | // If 'side-band' or 'side-band-64k' capabilities have been specified by 5 | // the client, the server will send the packfile data multiplexed. 6 | // 7 | // Either mode indicates that the packfile data will be streamed broken 8 | // up into packets of up to either 1000 bytes in the case of 'side_band', 9 | // or 65520 bytes in the case of 'side_band_64k'. Each packet is made up 10 | // of a leading 4-byte pkt-line length of how much data is in the packet, 11 | // followed by a 1-byte stream code, followed by the actual data. 12 | // 13 | // The stream code can be one of: 14 | // 15 | // 1 - pack data 16 | // 2 - progress messages 17 | // 3 - fatal error message just before stream aborts 18 | // 19 | // The "side-band-64k" capability came about as a way for newer clients 20 | // that can handle much larger packets to request packets that are 21 | // actually crammed nearly full, while maintaining backward compatibility 22 | // for the older clients. 23 | // 24 | // Further, with side-band and its up to 1000-byte messages, it's actually 25 | // 999 bytes of payload and 1 byte for the stream code. With side-band-64k, 26 | // same deal, you have up to 65519 bytes of data and 1 byte for the stream 27 | // code. 28 | // 29 | // The client MUST send only maximum of one of "side-band" and "side- 30 | // band-64k". Server MUST diagnose it as an error if client requests 31 | // both. 32 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/plumbing/protocol/packp/sideband/muxer.go: -------------------------------------------------------------------------------- 1 | package sideband 2 | 3 | import ( 4 | "io" 5 | 6 | "srcd.works/go-git.v4/plumbing/format/pktline" 7 | ) 8 | 9 | // Muxer multiplex the packfile along with the progress messages and the error 10 | // information. The multiplex is perform using pktline format. 11 | type Muxer struct { 12 | max int 13 | e *pktline.Encoder 14 | } 15 | 16 | const chLen = 1 17 | 18 | // NewMuxer returns a new Muxer for the given t that writes on w. 19 | // 20 | // If t is equal to `Sideband` the max pack size is set to MaxPackedSize, in any 21 | // other value is given, max pack is set to MaxPackedSize64k, that is the 22 | // maximum length of a line in pktline format. 23 | func NewMuxer(t Type, w io.Writer) *Muxer { 24 | max := MaxPackedSize64k 25 | if t == Sideband { 26 | max = MaxPackedSize 27 | } 28 | 29 | return &Muxer{ 30 | max: max - chLen, 31 | e: pktline.NewEncoder(w), 32 | } 33 | } 34 | 35 | // Write writes p in the PackData channel 36 | func (m *Muxer) Write(p []byte) (int, error) { 37 | return m.WriteChannel(PackData, p) 38 | } 39 | 40 | // WriteChannel writes p in the given channel. This method can be used with any 41 | // channel, but is recommend use it only for the ProgressMessage and 42 | // ErrorMessage channels and use Write for the PackData channel 43 | func (m *Muxer) WriteChannel(t Channel, p []byte) (int, error) { 44 | wrote := 0 45 | size := len(p) 46 | for wrote < size { 47 | n, err := m.doWrite(t, p[wrote:]) 48 | wrote += n 49 | 50 | if err != nil { 51 | return wrote, err 52 | } 53 | } 54 | 55 | return wrote, nil 56 | } 57 | 58 | func (m *Muxer) doWrite(ch Channel, p []byte) (int, error) { 59 | sz := len(p) 60 | if sz > m.max { 61 | sz = m.max 62 | } 63 | 64 | return sz, m.e.Encode(ch.WithPayload(p[:sz])) 65 | } 66 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/plumbing/protocol/packp/srvresp.go: -------------------------------------------------------------------------------- 1 | package packp 2 | 3 | import ( 4 | "bytes" 5 | "errors" 6 | "fmt" 7 | "io" 8 | 9 | "srcd.works/go-git.v4/plumbing" 10 | "srcd.works/go-git.v4/plumbing/format/pktline" 11 | ) 12 | 13 | const ackLineLen = 44 14 | 15 | // ServerResponse object acknowledgement from upload-pack service 16 | // TODO: implement support for multi_ack or multi_ack_detailed responses 17 | type ServerResponse struct { 18 | ACKs []plumbing.Hash 19 | } 20 | 21 | // Decode decodes the response into the struct, isMultiACK should be true, if 22 | // the request was done with multi_ack or multi_ack_detailed capabilities 23 | func (r *ServerResponse) Decode(reader io.Reader, isMultiACK bool) error { 24 | if isMultiACK { 25 | return errors.New("multi_ack and multi_ack_detailed are not supported") 26 | } 27 | 28 | s := pktline.NewScanner(reader) 29 | 30 | for s.Scan() { 31 | line := s.Bytes() 32 | 33 | if err := r.decodeLine(line); err != nil { 34 | return err 35 | } 36 | 37 | if !isMultiACK { 38 | break 39 | } 40 | } 41 | 42 | return s.Err() 43 | } 44 | 45 | func (r *ServerResponse) decodeLine(line []byte) error { 46 | if len(line) == 0 { 47 | return fmt.Errorf("unexpected flush") 48 | } 49 | 50 | if bytes.Compare(line[0:3], ack) == 0 { 51 | return r.decodeACKLine(line) 52 | } 53 | 54 | if bytes.Compare(line[0:3], nak) == 0 { 55 | return nil 56 | } 57 | 58 | return fmt.Errorf("unexpected content %q", string(line)) 59 | } 60 | 61 | func (r *ServerResponse) decodeACKLine(line []byte) error { 62 | if len(line) < ackLineLen { 63 | return fmt.Errorf("malformed ACK %q", line) 64 | } 65 | 66 | sp := bytes.Index(line, []byte(" ")) 67 | h := plumbing.NewHash(string(line[sp+1 : sp+41])) 68 | r.ACKs = append(r.ACKs, h) 69 | return nil 70 | } 71 | 72 | // Encode encodes the ServerResponse into a writer. 73 | func (r *ServerResponse) Encode(w io.Writer) error { 74 | if len(r.ACKs) > 1 { 75 | return errors.New("multi_ack and multi_ack_detailed are not supported") 76 | } 77 | 78 | e := pktline.NewEncoder(w) 79 | if len(r.ACKs) == 0 { 80 | return e.Encodef("%s\n", nak) 81 | } 82 | 83 | return e.Encodef("%s %s\n", ack, r.ACKs[0].String()) 84 | } 85 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/plumbing/protocol/packp/updreq_encode.go: -------------------------------------------------------------------------------- 1 | package packp 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | 7 | "srcd.works/go-git.v4/plumbing" 8 | "srcd.works/go-git.v4/plumbing/format/pktline" 9 | "srcd.works/go-git.v4/plumbing/protocol/packp/capability" 10 | ) 11 | 12 | var ( 13 | zeroHashString = plumbing.ZeroHash.String() 14 | ) 15 | 16 | // Encode writes the ReferenceUpdateRequest encoding to the stream. 17 | func (r *ReferenceUpdateRequest) Encode(w io.Writer) error { 18 | if err := r.validate(); err != nil { 19 | return err 20 | } 21 | 22 | e := pktline.NewEncoder(w) 23 | 24 | if err := r.encodeShallow(e, r.Shallow); err != nil { 25 | return err 26 | } 27 | 28 | if err := r.encodeCommands(e, r.Commands, r.Capabilities); err != nil { 29 | return err 30 | } 31 | 32 | if r.Packfile != nil { 33 | if _, err := io.Copy(w, r.Packfile); err != nil { 34 | return err 35 | } 36 | 37 | return r.Packfile.Close() 38 | } 39 | 40 | return nil 41 | } 42 | 43 | func (r *ReferenceUpdateRequest) encodeShallow(e *pktline.Encoder, 44 | h *plumbing.Hash) error { 45 | 46 | if h == nil { 47 | return nil 48 | } 49 | 50 | objId := []byte(h.String()) 51 | return e.Encodef("%s%s", shallow, objId) 52 | } 53 | 54 | func (r *ReferenceUpdateRequest) encodeCommands(e *pktline.Encoder, 55 | cmds []*Command, cap *capability.List) error { 56 | 57 | if err := e.Encodef("%s\x00%s", 58 | formatCommand(cmds[0]), cap.String()); err != nil { 59 | return err 60 | } 61 | 62 | for _, cmd := range cmds[1:] { 63 | if err := e.Encodef(formatCommand(cmd)); err != nil { 64 | return err 65 | } 66 | } 67 | 68 | return e.Flush() 69 | } 70 | 71 | func formatCommand(cmd *Command) string { 72 | o := cmd.Old.String() 73 | n := cmd.New.String() 74 | return fmt.Sprintf("%s %s %s", o, n, cmd.Name) 75 | } 76 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/plumbing/storer/index.go: -------------------------------------------------------------------------------- 1 | package storer 2 | 3 | import "srcd.works/go-git.v4/plumbing/format/index" 4 | 5 | // IndexStorer generic storage of index.Index 6 | type IndexStorer interface { 7 | SetIndex(*index.Index) error 8 | Index() (*index.Index, error) 9 | } 10 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/plumbing/storer/shallow.go: -------------------------------------------------------------------------------- 1 | package storer 2 | 3 | import "srcd.works/go-git.v4/plumbing" 4 | 5 | // ShallowStorer storage of references to shallow commits by hash, meaning that 6 | // these commits have missing parents because of a shallow fetch. 7 | type ShallowStorer interface { 8 | SetShallow([]plumbing.Hash) error 9 | Shallow() ([]plumbing.Hash, error) 10 | } 11 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/plumbing/storer/storer.go: -------------------------------------------------------------------------------- 1 | package storer 2 | 3 | // Storer is a basic storer for encoded objects and references. 4 | type Storer interface { 5 | EncodedObjectStorer 6 | ReferenceStorer 7 | } 8 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/plumbing/transport/client/client.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "fmt" 5 | 6 | "srcd.works/go-git.v4/plumbing/transport" 7 | "srcd.works/go-git.v4/plumbing/transport/file" 8 | "srcd.works/go-git.v4/plumbing/transport/git" 9 | "srcd.works/go-git.v4/plumbing/transport/http" 10 | "srcd.works/go-git.v4/plumbing/transport/ssh" 11 | ) 12 | 13 | // Protocols are the protocols supported by default. 14 | var Protocols = map[string]transport.Transport{ 15 | "http": http.DefaultClient, 16 | "https": http.DefaultClient, 17 | "ssh": ssh.DefaultClient, 18 | "git": git.DefaultClient, 19 | "file": file.DefaultClient, 20 | } 21 | 22 | // InstallProtocol adds or modifies an existing protocol. 23 | func InstallProtocol(scheme string, c transport.Transport) { 24 | Protocols[scheme] = c 25 | } 26 | 27 | // NewClient returns the appropriate client among of the set of known protocols: 28 | // http://, https://, ssh:// and file://. 29 | // See `InstallProtocol` to add or modify protocols. 30 | func NewClient(endpoint transport.Endpoint) (transport.Transport, error) { 31 | f, ok := Protocols[endpoint.Scheme] 32 | if !ok { 33 | return nil, fmt.Errorf("unsupported scheme %q", endpoint.Scheme) 34 | } 35 | 36 | return f, nil 37 | } 38 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/plumbing/transport/file/client.go: -------------------------------------------------------------------------------- 1 | package file 2 | 3 | import ( 4 | "io" 5 | "os/exec" 6 | 7 | "srcd.works/go-git.v4/plumbing/transport" 8 | "srcd.works/go-git.v4/plumbing/transport/internal/common" 9 | ) 10 | 11 | // DefaultClient is the default local client. 12 | var DefaultClient = NewClient( 13 | transport.UploadPackServiceName, 14 | transport.ReceivePackServiceName, 15 | ) 16 | 17 | type runner struct { 18 | UploadPackBin string 19 | ReceivePackBin string 20 | } 21 | 22 | // NewClient returns a new local client using the given git-upload-pack and 23 | // git-receive-pack binaries. 24 | func NewClient(uploadPackBin, receivePackBin string) transport.Transport { 25 | return common.NewClient(&runner{ 26 | UploadPackBin: uploadPackBin, 27 | ReceivePackBin: receivePackBin, 28 | }) 29 | } 30 | 31 | func (r *runner) Command(cmd string, ep transport.Endpoint, auth transport.AuthMethod) (common.Command, error) { 32 | switch cmd { 33 | case transport.UploadPackServiceName: 34 | cmd = r.UploadPackBin 35 | case transport.ReceivePackServiceName: 36 | cmd = r.ReceivePackBin 37 | } 38 | 39 | if _, err := exec.LookPath(cmd); err != nil { 40 | return nil, err 41 | } 42 | 43 | return &command{cmd: exec.Command(cmd, ep.Path)}, nil 44 | } 45 | 46 | type command struct { 47 | cmd *exec.Cmd 48 | closed bool 49 | } 50 | 51 | func (c *command) Start() error { 52 | return c.cmd.Start() 53 | } 54 | 55 | func (c *command) StderrPipe() (io.Reader, error) { 56 | return c.cmd.StderrPipe() 57 | } 58 | 59 | func (c *command) StdinPipe() (io.WriteCloser, error) { 60 | return c.cmd.StdinPipe() 61 | } 62 | 63 | func (c *command) StdoutPipe() (io.Reader, error) { 64 | return c.cmd.StdoutPipe() 65 | } 66 | 67 | // Close waits for the command to exit. 68 | func (c *command) Close() error { 69 | if c.closed { 70 | return nil 71 | } 72 | 73 | return c.cmd.Process.Kill() 74 | } 75 | 76 | func (c *command) Wait() error { 77 | defer func() { c.closed = true }() 78 | return c.cmd.Wait() 79 | } 80 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/plumbing/transport/file/server.go: -------------------------------------------------------------------------------- 1 | package file 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "srcd.works/go-git.v4/plumbing/transport" 8 | "srcd.works/go-git.v4/plumbing/transport/internal/common" 9 | "srcd.works/go-git.v4/plumbing/transport/server" 10 | "srcd.works/go-git.v4/utils/ioutil" 11 | ) 12 | 13 | // ServeUploadPack serves a git-upload-pack request using standard output, input 14 | // and error. This is meant to be used when implementing a git-upload-pack 15 | // command. 16 | func ServeUploadPack(path string) error { 17 | ep, err := transport.NewEndpoint(fmt.Sprintf("file://%s", path)) 18 | if err != nil { 19 | return err 20 | } 21 | 22 | // TODO: define and implement a server-side AuthMethod 23 | s, err := server.DefaultServer.NewUploadPackSession(ep, nil) 24 | if err != nil { 25 | return fmt.Errorf("error creating session: %s", err) 26 | } 27 | 28 | return common.ServeUploadPack(srvCmd, s) 29 | } 30 | 31 | // ServeReceivePack serves a git-receive-pack request using standard output, 32 | // input and error. This is meant to be used when implementing a 33 | // git-receive-pack command. 34 | func ServeReceivePack(path string) error { 35 | ep, err := transport.NewEndpoint(fmt.Sprintf("file://%s", path)) 36 | if err != nil { 37 | return err 38 | } 39 | 40 | // TODO: define and implement a server-side AuthMethod 41 | s, err := server.DefaultServer.NewReceivePackSession(ep, nil) 42 | if err != nil { 43 | return fmt.Errorf("error creating session: %s", err) 44 | } 45 | 46 | return common.ServeReceivePack(srvCmd, s) 47 | } 48 | 49 | var srvCmd = common.ServerCommand{ 50 | Stdin: os.Stdin, 51 | Stdout: ioutil.WriteNopCloser(os.Stdout), 52 | Stderr: os.Stderr, 53 | } 54 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/plumbing/transport/http/receive_pack.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | import ( 4 | "errors" 5 | "net/http" 6 | 7 | "srcd.works/go-git.v4/plumbing/protocol/packp" 8 | "srcd.works/go-git.v4/plumbing/transport" 9 | ) 10 | 11 | var errReceivePackNotSupported = errors.New("receive-pack not supported yet") 12 | 13 | type rpSession struct { 14 | *session 15 | } 16 | 17 | func newReceivePackSession(c *http.Client, ep transport.Endpoint, auth transport.AuthMethod) (transport.ReceivePackSession, error) { 18 | return &rpSession{&session{}}, nil 19 | } 20 | 21 | func (s *rpSession) AdvertisedReferences() (*packp.AdvRefs, error) { 22 | 23 | return nil, errReceivePackNotSupported 24 | } 25 | 26 | func (s *rpSession) ReceivePack(*packp.ReferenceUpdateRequest) ( 27 | *packp.ReportStatus, error) { 28 | 29 | return nil, errReceivePackNotSupported 30 | } 31 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/plumbing/transport/internal/common/server.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | 7 | "srcd.works/go-git.v4/plumbing/protocol/packp" 8 | "srcd.works/go-git.v4/plumbing/transport" 9 | "srcd.works/go-git.v4/utils/ioutil" 10 | ) 11 | 12 | // ServerCommand is used for a single server command execution. 13 | type ServerCommand struct { 14 | Stderr io.Writer 15 | Stdout io.WriteCloser 16 | Stdin io.Reader 17 | } 18 | 19 | func ServeUploadPack(cmd ServerCommand, s transport.UploadPackSession) (err error) { 20 | ioutil.CheckClose(cmd.Stdout, &err) 21 | 22 | ar, err := s.AdvertisedReferences() 23 | if err != nil { 24 | return err 25 | } 26 | 27 | if err := ar.Encode(cmd.Stdout); err != nil { 28 | return err 29 | } 30 | 31 | req := packp.NewUploadPackRequest() 32 | if err := req.Decode(cmd.Stdin); err != nil { 33 | return err 34 | } 35 | 36 | var resp *packp.UploadPackResponse 37 | resp, err = s.UploadPack(req) 38 | if err != nil { 39 | return err 40 | } 41 | 42 | return resp.Encode(cmd.Stdout) 43 | } 44 | 45 | func ServeReceivePack(cmd ServerCommand, s transport.ReceivePackSession) error { 46 | ar, err := s.AdvertisedReferences() 47 | if err != nil { 48 | return fmt.Errorf("internal error in advertised references: %s", err) 49 | } 50 | 51 | if err := ar.Encode(cmd.Stdout); err != nil { 52 | return fmt.Errorf("error in advertised references encoding: %s", err) 53 | } 54 | 55 | req := packp.NewReferenceUpdateRequest() 56 | if err := req.Decode(cmd.Stdin); err != nil { 57 | return fmt.Errorf("error decoding: %s", err) 58 | } 59 | 60 | rs, err := s.ReceivePack(req) 61 | if rs != nil { 62 | if err := rs.Encode(cmd.Stdout); err != nil { 63 | return fmt.Errorf("error in encoding report status %s", err) 64 | } 65 | } 66 | 67 | if err != nil { 68 | return fmt.Errorf("error in receive pack: %s", err) 69 | } 70 | 71 | return nil 72 | } 73 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/plumbing/transport/server/loader.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "srcd.works/go-git.v4/plumbing/storer" 5 | "srcd.works/go-git.v4/plumbing/transport" 6 | "srcd.works/go-git.v4/storage/filesystem" 7 | 8 | "srcd.works/go-billy.v1" 9 | "srcd.works/go-billy.v1/osfs" 10 | ) 11 | 12 | // DefaultLoader is a filesystem loader ignoring host and resolving paths to /. 13 | var DefaultLoader = NewFilesystemLoader(osfs.New("/")) 14 | 15 | // Loader loads repository's storer.Storer based on an optional host and a path. 16 | type Loader interface { 17 | // Load loads a storer.Storer given a transport.Endpoint. 18 | // Returns transport.ErrRepositoryNotFound if the repository does not 19 | // exist. 20 | Load(ep transport.Endpoint) (storer.Storer, error) 21 | } 22 | 23 | type fsLoader struct { 24 | base billy.Filesystem 25 | } 26 | 27 | // NewFilesystemLoader creates a Loader that ignores host and resolves paths 28 | // with a given base filesystem. 29 | func NewFilesystemLoader(base billy.Filesystem) Loader { 30 | return &fsLoader{base} 31 | } 32 | 33 | // Load looks up the endpoint's path in the base file system and returns a 34 | // storer for it. Returns transport.ErrRepositoryNotFound if a repository does 35 | // not exist in the given path. 36 | func (l *fsLoader) Load(ep transport.Endpoint) (storer.Storer, error) { 37 | fs := l.base.Dir(ep.Path) 38 | if _, err := fs.Stat("config"); err != nil { 39 | return nil, transport.ErrRepositoryNotFound 40 | } 41 | 42 | return filesystem.NewStorage(fs) 43 | } 44 | 45 | // MapLoader is a Loader that uses a lookup map of storer.Storer by 46 | // transport.Endpoint. 47 | type MapLoader map[transport.Endpoint]storer.Storer 48 | 49 | // Load returns a storer.Storer for given a transport.Endpoint by looking it up 50 | // in the map. Returns transport.ErrRepositoryNotFound if the endpoint does not 51 | // exist. 52 | func (l MapLoader) Load(ep transport.Endpoint) (storer.Storer, error) { 53 | s, ok := l[ep] 54 | if !ok { 55 | return nil, transport.ErrRepositoryNotFound 56 | } 57 | 58 | return s, nil 59 | } 60 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/storage/filesystem/config.go: -------------------------------------------------------------------------------- 1 | package filesystem 2 | 3 | import ( 4 | "io/ioutil" 5 | "os" 6 | 7 | "srcd.works/go-git.v4/config" 8 | "srcd.works/go-git.v4/storage/filesystem/internal/dotgit" 9 | ) 10 | 11 | type ConfigStorage struct { 12 | dir *dotgit.DotGit 13 | } 14 | 15 | func (c *ConfigStorage) Config() (*config.Config, error) { 16 | cfg := config.NewConfig() 17 | 18 | f, err := c.dir.Config() 19 | if err != nil { 20 | if os.IsNotExist(err) { 21 | return cfg, nil 22 | } 23 | 24 | return nil, err 25 | } 26 | 27 | defer f.Close() 28 | 29 | b, err := ioutil.ReadAll(f) 30 | if err != nil { 31 | return nil, err 32 | } 33 | 34 | if err := cfg.Unmarshal(b); err != nil { 35 | return nil, err 36 | } 37 | 38 | return cfg, nil 39 | } 40 | 41 | func (c *ConfigStorage) SetConfig(cfg *config.Config) error { 42 | if err := cfg.Validate(); err != nil { 43 | return err 44 | } 45 | 46 | f, err := c.dir.ConfigWriter() 47 | if err != nil { 48 | return err 49 | } 50 | 51 | defer f.Close() 52 | 53 | b, err := cfg.Marshal() 54 | if err != nil { 55 | return err 56 | } 57 | 58 | _, err = f.Write(b) 59 | return err 60 | } 61 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/storage/filesystem/index.go: -------------------------------------------------------------------------------- 1 | package filesystem 2 | 3 | import ( 4 | "os" 5 | 6 | "srcd.works/go-git.v4/plumbing/format/index" 7 | "srcd.works/go-git.v4/storage/filesystem/internal/dotgit" 8 | ) 9 | 10 | type IndexStorage struct { 11 | dir *dotgit.DotGit 12 | } 13 | 14 | func (s *IndexStorage) SetIndex(idx *index.Index) error { 15 | f, err := s.dir.IndexWriter() 16 | if err != nil { 17 | return err 18 | } 19 | 20 | defer f.Close() 21 | 22 | e := index.NewEncoder(f) 23 | return e.Encode(idx) 24 | } 25 | 26 | func (s *IndexStorage) Index() (*index.Index, error) { 27 | idx := &index.Index{ 28 | Version: 2, 29 | } 30 | 31 | f, err := s.dir.Index() 32 | if err != nil { 33 | if os.IsNotExist(err) { 34 | return idx, nil 35 | } 36 | 37 | return nil, err 38 | } 39 | 40 | defer f.Close() 41 | 42 | d := index.NewDecoder(f) 43 | return idx, d.Decode(idx) 44 | } 45 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/storage/filesystem/reference.go: -------------------------------------------------------------------------------- 1 | package filesystem 2 | 3 | import ( 4 | "srcd.works/go-git.v4/plumbing" 5 | "srcd.works/go-git.v4/plumbing/storer" 6 | "srcd.works/go-git.v4/storage/filesystem/internal/dotgit" 7 | ) 8 | 9 | type ReferenceStorage struct { 10 | dir *dotgit.DotGit 11 | } 12 | 13 | func (r *ReferenceStorage) SetReference(ref *plumbing.Reference) error { 14 | return r.dir.SetRef(ref) 15 | } 16 | 17 | func (r *ReferenceStorage) Reference(n plumbing.ReferenceName) (*plumbing.Reference, error) { 18 | return r.dir.Ref(n) 19 | } 20 | 21 | func (r *ReferenceStorage) IterReferences() (storer.ReferenceIter, error) { 22 | refs, err := r.dir.Refs() 23 | if err != nil { 24 | return nil, err 25 | } 26 | 27 | return storer.NewReferenceSliceIter(refs), nil 28 | } 29 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/storage/filesystem/shallow.go: -------------------------------------------------------------------------------- 1 | package filesystem 2 | 3 | import ( 4 | "bufio" 5 | "fmt" 6 | 7 | "srcd.works/go-git.v4/plumbing" 8 | "srcd.works/go-git.v4/storage/filesystem/internal/dotgit" 9 | ) 10 | 11 | // ShallowStorage where the shallow commits are stored, an internal to 12 | // manipulate the shallow file 13 | type ShallowStorage struct { 14 | dir *dotgit.DotGit 15 | } 16 | 17 | // SetShallow save the shallows in the shallow file in the .git folder as one 18 | // commit per line represented by 40-byte hexadecimal object terminated by a 19 | // newline. 20 | func (s *ShallowStorage) SetShallow(commits []plumbing.Hash) error { 21 | f, err := s.dir.ShallowWriter() 22 | if err != nil { 23 | return err 24 | } 25 | 26 | defer f.Close() 27 | for _, h := range commits { 28 | if _, err := fmt.Fprintf(f, "%s\n", h); err != err { 29 | return err 30 | } 31 | } 32 | 33 | return nil 34 | } 35 | 36 | // Shallow return the shallow commits reading from shallo file from .git 37 | func (s *ShallowStorage) Shallow() ([]plumbing.Hash, error) { 38 | f, err := s.dir.Shallow() 39 | if err != nil { 40 | return nil, err 41 | } 42 | 43 | var hash []plumbing.Hash 44 | 45 | scn := bufio.NewScanner(f) 46 | for scn.Scan() { 47 | hash = append(hash, plumbing.NewHash(scn.Text())) 48 | } 49 | 50 | return hash, scn.Err() 51 | } 52 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/storage/filesystem/storage.go: -------------------------------------------------------------------------------- 1 | // Package filesystem is a storage backend base on filesystems 2 | package filesystem 3 | 4 | import ( 5 | "srcd.works/go-git.v4/storage/filesystem/internal/dotgit" 6 | 7 | "srcd.works/go-billy.v1" 8 | ) 9 | 10 | // Storage is an implementation of git.Storer that stores data on disk in the 11 | // standard git format (this is, the .git directory). Zero values of this type 12 | // are not safe to use, see the NewStorage function below. 13 | type Storage struct { 14 | ObjectStorage 15 | ReferenceStorage 16 | IndexStorage 17 | ShallowStorage 18 | ConfigStorage 19 | } 20 | 21 | // NewStorage returns a new Storage backed by a given `fs.Filesystem` 22 | func NewStorage(fs billy.Filesystem) (*Storage, error) { 23 | dir := dotgit.New(fs) 24 | o, err := newObjectStorage(dir) 25 | if err != nil { 26 | return nil, err 27 | } 28 | 29 | return &Storage{ 30 | ObjectStorage: o, 31 | ReferenceStorage: ReferenceStorage{dir: dir}, 32 | IndexStorage: IndexStorage{dir: dir}, 33 | ShallowStorage: ShallowStorage{dir: dir}, 34 | ConfigStorage: ConfigStorage{dir: dir}, 35 | }, nil 36 | } 37 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/utils/binary/write.go: -------------------------------------------------------------------------------- 1 | package binary 2 | 3 | import ( 4 | "encoding/binary" 5 | "io" 6 | ) 7 | 8 | // Write writes the binary representation of data into w, using BigEndian order 9 | // https://golang.org/pkg/encoding/binary/#Write 10 | func Write(w io.Writer, data ...interface{}) error { 11 | for _, v := range data { 12 | if err := binary.Write(w, binary.BigEndian, v); err != nil { 13 | return err 14 | } 15 | } 16 | 17 | return nil 18 | } 19 | 20 | func WriteVariableWidthInt(w io.Writer, n int64) error { 21 | buf := []byte{byte(n & 0x7f)} 22 | n >>= 7 23 | for n != 0 { 24 | n-- 25 | buf = append([]byte{0x80 | (byte(n & 0x7f))}, buf...) 26 | n >>= 7 27 | } 28 | 29 | _, err := w.Write(buf) 30 | 31 | return err 32 | } 33 | 34 | // WriteUint32 writes the binary representation of a uint32 into w, in BigEndian 35 | // order 36 | func WriteUint32(w io.Writer, value uint32) error { 37 | return binary.Write(w, binary.BigEndian, value) 38 | } 39 | 40 | // WriteUint16 writes the binary representation of a uint16 into w, in BigEndian 41 | // order 42 | func WriteUint16(w io.Writer, value uint16) error { 43 | return binary.Write(w, binary.BigEndian, value) 44 | } 45 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/utils/diff/diff.go: -------------------------------------------------------------------------------- 1 | // Package diff implements line oriented diffs, similar to the ancient 2 | // Unix diff command. 3 | // 4 | // The current implementation is just a wrapper around Sergi's 5 | // go-diff/diffmatchpatch library, which is a go port of Neil 6 | // Fraser's google-diff-match-patch code 7 | package diff 8 | 9 | import ( 10 | "bytes" 11 | 12 | "github.com/sergi/go-diff/diffmatchpatch" 13 | ) 14 | 15 | // Do computes the (line oriented) modifications needed to turn the src 16 | // string into the dst string. 17 | func Do(src, dst string) (diffs []diffmatchpatch.Diff) { 18 | dmp := diffmatchpatch.New() 19 | wSrc, wDst, warray := dmp.DiffLinesToChars(src, dst) 20 | diffs = dmp.DiffMain(wSrc, wDst, false) 21 | diffs = dmp.DiffCharsToLines(diffs, warray) 22 | return diffs 23 | } 24 | 25 | // Dst computes and returns the destination text. 26 | func Dst(diffs []diffmatchpatch.Diff) string { 27 | var text bytes.Buffer 28 | for _, d := range diffs { 29 | if d.Type != diffmatchpatch.DiffDelete { 30 | text.WriteString(d.Text) 31 | } 32 | } 33 | return text.String() 34 | } 35 | 36 | // Src computes and returns the source text 37 | func Src(diffs []diffmatchpatch.Diff) string { 38 | var text bytes.Buffer 39 | for _, d := range diffs { 40 | if d.Type != diffmatchpatch.DiffInsert { 41 | text.WriteString(d.Text) 42 | } 43 | } 44 | return text.String() 45 | } 46 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/utils/ioutil/common.go: -------------------------------------------------------------------------------- 1 | package ioutil 2 | 3 | import ( 4 | "bufio" 5 | "errors" 6 | "io" 7 | ) 8 | 9 | type readPeeker interface { 10 | io.Reader 11 | Peek(int) ([]byte, error) 12 | } 13 | 14 | var ( 15 | ErrEmptyReader = errors.New("reader is empty") 16 | ) 17 | 18 | // NonEmptyReader takes a reader and returns it if it is not empty, or 19 | // `ErrEmptyReader` if it is empty. If there is an error when reading the first 20 | // byte of the given reader, it will be propagated. 21 | func NonEmptyReader(r io.Reader) (io.Reader, error) { 22 | pr, ok := r.(readPeeker) 23 | if !ok { 24 | pr = bufio.NewReader(r) 25 | } 26 | 27 | _, err := pr.Peek(1) 28 | if err == io.EOF { 29 | return nil, ErrEmptyReader 30 | } 31 | 32 | if err != nil { 33 | return nil, err 34 | } 35 | 36 | return pr, nil 37 | } 38 | 39 | type readCloser struct { 40 | io.Reader 41 | closer io.Closer 42 | } 43 | 44 | func (r *readCloser) Close() error { 45 | return r.closer.Close() 46 | } 47 | 48 | // NewReadCloser creates an `io.ReadCloser` with the given `io.Reader` and 49 | // `io.Closer`. 50 | func NewReadCloser(r io.Reader, c io.Closer) io.ReadCloser { 51 | return &readCloser{Reader: r, closer: c} 52 | } 53 | 54 | type writeNopCloser struct { 55 | io.Writer 56 | } 57 | 58 | func (writeNopCloser) Close() error { return nil } 59 | 60 | // WriteNopCloser returns a WriteCloser with a no-op Close method wrapping 61 | // the provided Writer w. 62 | func WriteNopCloser(w io.Writer) io.WriteCloser { 63 | return writeNopCloser{w} 64 | } 65 | 66 | // CheckClose is used with defer to close the given io.Closer and check its 67 | // returned error value. If Close returns an error and the given *error 68 | // is not nil, *error is set to the error returned by Close. 69 | // 70 | // CheckClose is typically used with named return values like so: 71 | // 72 | // func do(obj *Object) (err error) { 73 | // w, err := obj.Writer() 74 | // if err != nil { 75 | // return nil 76 | // } 77 | // defer CheckClose(w, &err) 78 | // // work with w 79 | // } 80 | func CheckClose(c io.Closer, err *error) { 81 | if cerr := c.Close(); cerr != nil && *err == nil { 82 | *err = cerr 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/worktree_darwin.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd netbsd openbsd 2 | 3 | package git 4 | 5 | import ( 6 | "syscall" 7 | "time" 8 | 9 | "srcd.works/go-git.v4/plumbing/format/index" 10 | ) 11 | 12 | func init() { 13 | fillSystemInfo = func(e *index.Entry, os *syscall.Stat_t) { 14 | e.CreatedAt = time.Unix(int64(os.Atimespec.Sec), int64(os.Atimespec.Nsec)) 15 | e.Dev = uint32(os.Dev) 16 | e.Inode = uint32(os.Ino) 17 | e.GID = os.Gid 18 | e.UID = os.Uid 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /vendor/srcd.works/go-git.v4/worktree_linux.go: -------------------------------------------------------------------------------- 1 | // +build linux 2 | 3 | package git 4 | 5 | import ( 6 | "syscall" 7 | "time" 8 | 9 | "srcd.works/go-git.v4/plumbing/format/index" 10 | ) 11 | 12 | func init() { 13 | fillSystemInfo = func(e *index.Entry, os *syscall.Stat_t) { 14 | e.CreatedAt = time.Unix(int64(os.Ctim.Sec), int64(os.Ctim.Nsec)) 15 | e.Dev = uint32(os.Dev) 16 | e.Inode = uint32(os.Ino) 17 | e.GID = os.Gid 18 | e.UID = os.Uid 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /wrap.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/pkg/errors" 5 | "github.com/urfave/cli" 6 | ) 7 | 8 | type stackTracer interface { 9 | StackTrace() errors.StackTrace 10 | } 11 | 12 | func wrapFn(fn interface{}) func(*cli.Context) error { 13 | var do func(*cli.Context) error 14 | 15 | switch sig := fn.(type) { 16 | case func(*cli.Context) error: 17 | do = sig 18 | case cli.BeforeFunc: 19 | do = sig 20 | case cli.ActionFunc: 21 | do = sig 22 | case cli.AfterFunc: 23 | do = sig 24 | default: 25 | panic(errors.New("can't wrap invalid function signature")) 26 | } 27 | 28 | if do == nil { 29 | return nil 30 | } 31 | 32 | return func(c *cli.Context) error { 33 | err := do(c) 34 | if serr, ok := err.(stackTracer); ok && serr != nil { 35 | ctx.Logger. 36 | WithError(err). 37 | WithField("command", c.Command.Name). 38 | Error("error") 39 | return errors.New("emitted stack trace") 40 | } 41 | return err 42 | } 43 | } 44 | --------------------------------------------------------------------------------