diff options
| author | Christine Dodrill <me@christine.website> | 2018-10-04 18:04:48 -0700 |
|---|---|---|
| committer | Christine Dodrill <me@christine.website> | 2018-10-04 18:04:48 -0700 |
| commit | fbedf4acda9ff659a69fe577465db9617ec94ba1 (patch) | |
| tree | 74c0e72a1380a431813c78eb688b5b93db72800a /irc/kcpd/vendor/github.com | |
| parent | 51b60f36ac286c973dd258571b77db24e9ace031 (diff) | |
| download | x-fbedf4acda9ff659a69fe577465db9617ec94ba1.tar.xz x-fbedf4acda9ff659a69fe577465db9617ec94ba1.zip | |
remove vendored dependencies for some things, vgo is coming
Diffstat (limited to 'irc/kcpd/vendor/github.com')
42 files changed, 0 insertions, 8980 deletions
diff --git a/irc/kcpd/vendor/github.com/Xe/gopreload/doc.go b/irc/kcpd/vendor/github.com/Xe/gopreload/doc.go deleted file mode 100644 index 720c5c1..0000000 --- a/irc/kcpd/vendor/github.com/Xe/gopreload/doc.go +++ /dev/null @@ -1,7 +0,0 @@ -/* -Package gopreload is a bit of a hack to emulate the behavior of LD_PRELOAD [ld-preload]. -This allows you to have automatically starting instrumentation, etc. - -[ld-preload]: http://man7.org/linux/man-pages/man8/ld.so.8.html (see LD_PRELOAD section) -*/ -package gopreload diff --git a/irc/kcpd/vendor/github.com/Xe/gopreload/preload.go b/irc/kcpd/vendor/github.com/Xe/gopreload/preload.go deleted file mode 100644 index 1b5a0c9..0000000 --- a/irc/kcpd/vendor/github.com/Xe/gopreload/preload.go +++ /dev/null @@ -1,26 +0,0 @@ -//+build linux,go1.8 - -package gopreload - -import ( - "log" - "os" - "plugin" - "strings" -) - -func init() { - gpv := os.Getenv("GO_PRELOAD") - if gpv == "" { - return - } - - for _, elem := range strings.Split(gpv, ",") { - log.Printf("gopreload: trying to open: %s", elem) - _, err := plugin.Open(elem) - if err != nil { - log.Printf("%v from GO_PRELOAD cannot be loaded: %v", elem, err) - continue - } - } -} diff --git a/irc/kcpd/vendor/github.com/caarlos0/env/env.go b/irc/kcpd/vendor/github.com/caarlos0/env/env.go deleted file mode 100644 index 25e5117..0000000 --- a/irc/kcpd/vendor/github.com/caarlos0/env/env.go +++ /dev/null @@ -1,275 +0,0 @@ -package env - -import ( - "errors" - "os" - "reflect" - "strconv" - "strings" - "time" -) - -var ( - // ErrNotAStructPtr is returned if you pass something that is not a pointer to a - // Struct to Parse - ErrNotAStructPtr = errors.New("Expected a pointer to a Struct") - // ErrUnsupportedType if the struct field type is not supported by env - ErrUnsupportedType = errors.New("Type is not supported") - // ErrUnsupportedSliceType if the slice element type is not supported by env - ErrUnsupportedSliceType = errors.New("Unsupported slice type") - // Friendly names for reflect types - sliceOfInts = reflect.TypeOf([]int(nil)) - sliceOfInt64s = reflect.TypeOf([]int64(nil)) - sliceOfStrings = reflect.TypeOf([]string(nil)) - sliceOfBools = reflect.TypeOf([]bool(nil)) - sliceOfFloat32s = reflect.TypeOf([]float32(nil)) - sliceOfFloat64s = reflect.TypeOf([]float64(nil)) -) - -// Parse parses a struct containing `env` tags and loads its values from -// environment variables. -func Parse(v interface{}) error { - ptrRef := reflect.ValueOf(v) - if ptrRef.Kind() != reflect.Ptr { - return ErrNotAStructPtr - } - ref := ptrRef.Elem() - if ref.Kind() != reflect.Struct { - return ErrNotAStructPtr - } - return doParse(ref) -} - -func doParse(ref reflect.Value) error { - refType := ref.Type() - for i := 0; i < refType.NumField(); i++ { - value, err := get(refType.Field(i)) - if err != nil { - return err - } - if value == "" { - continue - } - if err := set(ref.Field(i), refType.Field(i), value); err != nil { - return err - } - } - return nil -} - -func get(field reflect.StructField) (string, error) { - var ( - val string - err error - ) - - key, opts := parseKeyForOption(field.Tag.Get("env")) - - defaultValue := field.Tag.Get("envDefault") - val = getOr(key, defaultValue) - - if len(opts) > 0 { - for _, opt := range opts { - // The only option supported is "required". - switch opt { - case "": - break - case "required": - val, err = getRequired(key) - default: - err = errors.New("Env tag option " + opt + " not supported.") - } - } - } - - return val, err -} - -// split the env tag's key into the expected key and desired option, if any. -func parseKeyForOption(key string) (string, []string) { - opts := strings.Split(key, ",") - return opts[0], opts[1:] -} - -func getRequired(key string) (string, error) { - if value := os.Getenv(key); value != "" { - return value, nil - } - // We do not use fmt.Errorf to avoid another import. - return "", errors.New("Required environment variable " + key + " is not set") -} - -func getOr(key, defaultValue string) string { - value := os.Getenv(key) - if value != "" { - return value - } - return defaultValue -} - -func set(field reflect.Value, refType reflect.StructField, value string) error { - switch field.Kind() { - case reflect.Slice: - separator := refType.Tag.Get("envSeparator") - return handleSlice(field, value, separator) - case reflect.String: - field.SetString(value) - case reflect.Bool: - bvalue, err := strconv.ParseBool(value) - if err != nil { - return err - } - field.SetBool(bvalue) - case reflect.Int: - intValue, err := strconv.ParseInt(value, 10, 32) - if err != nil { - return err - } - field.SetInt(intValue) - case reflect.Float32: - v, err := strconv.ParseFloat(value, 32) - if err != nil { - return err - } - field.SetFloat(v) - case reflect.Float64: - v, err := strconv.ParseFloat(value, 64) - if err != nil { - return err - } - field.Set(reflect.ValueOf(v)) - case reflect.Int64: - if refType.Type.String() == "time.Duration" { - dValue, err := time.ParseDuration(value) - if err != nil { - return err - } - field.Set(reflect.ValueOf(dValue)) - } else { - intValue, err := strconv.ParseInt(value, 10, 64) - if err != nil { - return err - } - field.SetInt(intValue) - } - default: - return ErrUnsupportedType - } - return nil -} - -func handleSlice(field reflect.Value, value, separator string) error { - if separator == "" { - separator = "," - } - - splitData := strings.Split(value, separator) - - switch field.Type() { - case sliceOfStrings: - field.Set(reflect.ValueOf(splitData)) - case sliceOfInts: - intData, err := parseInts(splitData) - if err != nil { - return err - } - field.Set(reflect.ValueOf(intData)) - case sliceOfInt64s: - int64Data, err := parseInt64s(splitData) - if err != nil { - return err - } - field.Set(reflect.ValueOf(int64Data)) - - case sliceOfFloat32s: - data, err := parseFloat32s(splitData) - if err != nil { - return err - } - field.Set(reflect.ValueOf(data)) - case sliceOfFloat64s: - data, err := parseFloat64s(splitData) - if err != nil { - return err - } - field.Set(reflect.ValueOf(data)) - case sliceOfBools: - boolData, err := parseBools(splitData) - if err != nil { - return err - } - field.Set(reflect.ValueOf(boolData)) - default: - return ErrUnsupportedSliceType - } - return nil -} - -func parseInts(data []string) ([]int, error) { - var intSlice []int - - for _, v := range data { - intValue, err := strconv.ParseInt(v, 10, 32) - if err != nil { - return nil, err - } - intSlice = append(intSlice, int(intValue)) - } - return intSlice, nil -} - - -func parseInt64s(data []string) ([]int64, error) { - var intSlice []int64 - - for _, v := range data { - intValue, err := strconv.ParseInt(v, 10, 64) - if err != nil { - return nil, err - } - intSlice = append(intSlice, int64(intValue)) - } - return intSlice, nil -} - - - -func parseFloat32s(data []string) ([]float32, error) { - var float32Slice []float32 - - for _, v := range data { - data, err := strconv.ParseFloat(v, 32) - if err != nil { - return nil, err - } - float32Slice = append(float32Slice, float32(data)) - } - return float32Slice, nil -} - -func parseFloat64s(data []string) ([]float64, error) { - var float64Slice []float64 - - for _, v := range data { - data, err := strconv.ParseFloat(v, 64) - if err != nil { - return nil, err - } - float64Slice = append(float64Slice, float64(data)) - } - return float64Slice, nil -} - -func parseBools(data []string) ([]bool, error) { - var boolSlice []bool - - for _, v := range data { - bvalue, err := strconv.ParseBool(v) - if err != nil { - return nil, err - } - - boolSlice = append(boolSlice, bvalue) - } - return boolSlice, nil -} diff --git a/irc/kcpd/vendor/github.com/google/gops/agent/agent.go b/irc/kcpd/vendor/github.com/google/gops/agent/agent.go deleted file mode 100644 index 5708391..0000000 --- a/irc/kcpd/vendor/github.com/google/gops/agent/agent.go +++ /dev/null @@ -1,237 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package agent provides hooks programs can register to retrieve -// diagnostics data by using gops. -package agent - -import ( - "fmt" - "io" - "io/ioutil" - "net" - "os" - gosignal "os/signal" - "runtime" - "runtime/pprof" - "runtime/trace" - "strconv" - "sync" - "time" - - "bufio" - - "github.com/google/gops/internal" - "github.com/google/gops/signal" - "github.com/kardianos/osext" -) - -const defaultAddr = "127.0.0.1:0" - -var ( - mu sync.Mutex - portfile string - listener net.Listener - - units = []string{" bytes", "KB", "MB", "GB", "TB", "PB"} -) - -// Options allows configuring the started agent. -type Options struct { - // Addr is the host:port the agent will be listening at. - // Optional. - Addr string - - // NoShutdownCleanup tells the agent not to automatically cleanup - // resources if the running process receives an interrupt. - // Optional. - NoShutdownCleanup bool -} - -// Listen starts the gops agent on a host process. Once agent started, users -// can use the advanced gops features. The agent will listen to Interrupt -// signals and exit the process, if you need to perform further work on the -// Interrupt signal use the options parameter to configure the agent -// accordingly. -// -// Note: The agent exposes an endpoint via a TCP connection that can be used by -// any program on the system. Review your security requirements before starting -// the agent. -func Listen(opts *Options) error { - mu.Lock() - defer mu.Unlock() - - if opts == nil { - opts = &Options{} - } - if portfile != "" { - return fmt.Errorf("gops: agent already listening at: %v", listener.Addr()) - } - - gopsdir, err := internal.ConfigDir() - if err != nil { - return err - } - err = os.MkdirAll(gopsdir, os.ModePerm) - if err != nil { - return err - } - if !opts.NoShutdownCleanup { - gracefulShutdown() - } - - addr := opts.Addr - if addr == "" { - addr = defaultAddr - } - ln, err := net.Listen("tcp", addr) - if err != nil { - return err - } - listener = ln - port := listener.Addr().(*net.TCPAddr).Port - portfile = fmt.Sprintf("%s/%d", gopsdir, os.Getpid()) - err = ioutil.WriteFile(portfile, []byte(strconv.Itoa(port)), os.ModePerm) - if err != nil { - return err - } - - go listen() - return nil -} - -func listen() { - buf := make([]byte, 1) - for { - fd, err := listener.Accept() - if err != nil { - fmt.Fprintf(os.Stderr, "gops: %v", err) - if netErr, ok := err.(net.Error); ok && !netErr.Temporary() { - break - } - continue - } - if _, err := fd.Read(buf); err != nil { - fmt.Fprintf(os.Stderr, "gops: %v", err) - continue - } - if err := handle(fd, buf); err != nil { - fmt.Fprintf(os.Stderr, "gops: %v", err) - continue - } - fd.Close() - } -} - -func gracefulShutdown() { - c := make(chan os.Signal, 1) - gosignal.Notify(c, os.Interrupt) - go func() { - // cleanup the socket on shutdown. - <-c - Close() - os.Exit(1) - }() -} - -// Close closes the agent, removing temporary files and closing the TCP listener. -// If no agent is listening, Close does nothing. -func Close() { - mu.Lock() - defer mu.Unlock() - - if portfile != "" { - os.Remove(portfile) - portfile = "" - } - if listener != nil { - listener.Close() - } -} - -func formatBytes(val uint64) string { - var i int - var target uint64 - for i = range units { - target = 1 << uint(10*(i+1)) - if val < target { - break - } - } - if i > 0 { - return fmt.Sprintf("%0.2f%s (%d bytes)", float64(val)/(float64(target)/1024), units[i], val) - } - return fmt.Sprintf("%d bytes", val) -} - -func handle(conn io.Writer, msg []byte) error { - switch msg[0] { - case signal.StackTrace: - return pprof.Lookup("goroutine").WriteTo(conn, 2) - case signal.GC: - runtime.GC() - _, err := conn.Write([]byte("ok")) - return err - case signal.MemStats: - var s runtime.MemStats - runtime.ReadMemStats(&s) - fmt.Fprintf(conn, "alloc: %v\n", formatBytes(s.Alloc)) - fmt.Fprintf(conn, "total-alloc: %v\n", formatBytes(s.TotalAlloc)) - fmt.Fprintf(conn, "sys: %v\n", formatBytes(s.Sys)) - fmt.Fprintf(conn, "lookups: %v\n", s.Lookups) - fmt.Fprintf(conn, "mallocs: %v\n", s.Mallocs) - fmt.Fprintf(conn, "frees: %v\n", s.Frees) - fmt.Fprintf(conn, "heap-alloc: %v\n", formatBytes(s.HeapAlloc)) - fmt.Fprintf(conn, "heap-sys: %v\n", formatBytes(s.HeapSys)) - fmt.Fprintf(conn, "heap-idle: %v\n", formatBytes(s.HeapIdle)) - fmt.Fprintf(conn, "heap-in-use: %v\n", formatBytes(s.HeapInuse)) - fmt.Fprintf(conn, "heap-released: %v\n", formatBytes(s.HeapReleased)) - fmt.Fprintf(conn, "heap-objects: %v\n", s.HeapObjects) - fmt.Fprintf(conn, "stack-in-use: %v\n", formatBytes(s.StackInuse)) - fmt.Fprintf(conn, "stack-sys: %v\n", formatBytes(s.StackSys)) - fmt.Fprintf(conn, "next-gc: when heap-alloc >= %v\n", formatBytes(s.NextGC)) - lastGC := "-" - if s.LastGC != 0 { - lastGC = fmt.Sprint(time.Unix(0, int64(s.LastGC))) - } - fmt.Fprintf(conn, "last-gc: %v\n", lastGC) - fmt.Fprintf(conn, "gc-pause: %v\n", time.Duration(s.PauseTotalNs)) - fmt.Fprintf(conn, "num-gc: %v\n", s.NumGC) - fmt.Fprintf(conn, "enable-gc: %v\n", s.EnableGC) - fmt.Fprintf(conn, "debug-gc: %v\n", s.DebugGC) - case signal.Version: - fmt.Fprintf(conn, "%v\n", runtime.Version()) - case signal.HeapProfile: - pprof.WriteHeapProfile(conn) - case signal.CPUProfile: - if err := pprof.StartCPUProfile(conn); err != nil { - return err - } - time.Sleep(30 * time.Second) - pprof.StopCPUProfile() - case signal.Stats: - fmt.Fprintf(conn, "goroutines: %v\n", runtime.NumGoroutine()) - fmt.Fprintf(conn, "OS threads: %v\n", pprof.Lookup("threadcreate").Count()) - fmt.Fprintf(conn, "GOMAXPROCS: %v\n", runtime.GOMAXPROCS(0)) - fmt.Fprintf(conn, "num CPU: %v\n", runtime.NumCPU()) - case signal.BinaryDump: - path, err := osext.Executable() - if err != nil { - return err - } - f, err := os.Open(path) - if err != nil { - return err - } - defer f.Close() - - _, err = bufio.NewReader(f).WriteTo(conn) - return err - case signal.Trace: - trace.Start(conn) - time.Sleep(5 * time.Second) - trace.Stop() - } - return nil -} diff --git a/irc/kcpd/vendor/github.com/google/gops/internal/internal.go b/irc/kcpd/vendor/github.com/google/gops/internal/internal.go deleted file mode 100644 index 1382822..0000000 --- a/irc/kcpd/vendor/github.com/google/gops/internal/internal.go +++ /dev/null @@ -1,52 +0,0 @@ -package internal - -import ( - "errors" - "fmt" - "io/ioutil" - "os" - "os/user" - "path/filepath" - "runtime" - "strings" -) - -func ConfigDir() (string, error) { - if runtime.GOOS == "windows" { - return filepath.Join(os.Getenv("APPDATA"), "gops"), nil - } - homeDir := guessUnixHomeDir() - if homeDir == "" { - return "", errors.New("unable to get current user home directory: os/user lookup failed; $HOME is empty") - } - return filepath.Join(homeDir, ".config", "gops"), nil -} - -func guessUnixHomeDir() string { - usr, err := user.Current() - if err == nil { - return usr.HomeDir - } - return os.Getenv("HOME") -} - -func PIDFile(pid int) (string, error) { - gopsdir, err := ConfigDir() - if err != nil { - return "", err - } - return fmt.Sprintf("%s/%d", gopsdir, pid), nil -} - -func GetPort(pid int) (string, error) { - portfile, err := PIDFile(pid) - if err != nil { - return "", err - } - b, err := ioutil.ReadFile(portfile) - if err != nil { - return "", err - } - port := strings.TrimSpace(string(b)) - return port, nil -} diff --git a/irc/kcpd/vendor/github.com/google/gops/signal/signal.go b/irc/kcpd/vendor/github.com/google/gops/signal/signal.go deleted file mode 100644 index b2bfbe1..0000000 --- a/irc/kcpd/vendor/github.com/google/gops/signal/signal.go +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package signal contains signals used to communicate to the gops agents. -package signal - -const ( - // StackTrace represents a command to print stack trace. - StackTrace = byte(0x1) - - // GC runs the garbage collector. - GC = byte(0x2) - - // MemStats reports memory stats. - MemStats = byte(0x3) - - // Version prints the Go version. - Version = byte(0x4) - - // HeapProfile starts `go tool pprof` with the current memory profile. - HeapProfile = byte(0x5) - - // CPUProfile starts `go tool pprof` with the current CPU profile - CPUProfile = byte(0x6) - - // Stats returns Go runtime statistics such as number of goroutines, GOMAXPROCS, and NumCPU. - Stats = byte(0x7) - - // Trace starts the Go execution tracer, waits 5 seconds and launches the trace tool. - Trace = byte(0x8) - - // BinaryDump returns running binary file. - BinaryDump = byte(0x9) -) diff --git a/irc/kcpd/vendor/github.com/joho/godotenv/autoload/autoload.go b/irc/kcpd/vendor/github.com/joho/godotenv/autoload/autoload.go deleted file mode 100644 index fbcd2bd..0000000 --- a/irc/kcpd/vendor/github.com/joho/godotenv/autoload/autoload.go +++ /dev/null @@ -1,15 +0,0 @@ -package autoload - -/* - You can just read the .env file on import just by doing - - import _ "github.com/joho/godotenv/autoload" - - And bob's your mother's brother -*/ - -import "github.com/joho/godotenv" - -func init() { - godotenv.Load() -} diff --git a/irc/kcpd/vendor/github.com/joho/godotenv/godotenv.go b/irc/kcpd/vendor/github.com/joho/godotenv/godotenv.go deleted file mode 100644 index 94b2676..0000000 --- a/irc/kcpd/vendor/github.com/joho/godotenv/godotenv.go +++ /dev/null @@ -1,229 +0,0 @@ -// Package godotenv is a go port of the ruby dotenv library (https://github.com/bkeepers/dotenv) -// -// Examples/readme can be found on the github page at https://github.com/joho/godotenv -// -// The TL;DR is that you make a .env file that looks something like -// -// SOME_ENV_VAR=somevalue -// -// and then in your go code you can call -// -// godotenv.Load() -// -// and all the env vars declared in .env will be avaiable through os.Getenv("SOME_ENV_VAR") -package godotenv - -import ( - "bufio" - "errors" - "os" - "os/exec" - "strings" -) - -// Load will read your env file(s) and load them into ENV for this process. -// -// Call this function as close as possible to the start of your program (ideally in main) -// -// If you call Load without any args it will default to loading .env in the current path -// -// You can otherwise tell it which files to load (there can be more than one) like -// -// godotenv.Load("fileone", "filetwo") -// -// It's important to note that it WILL NOT OVERRIDE an env variable that already exists - consider the .env file to set dev vars or sensible defaults -func Load(filenames ...string) (err error) { - filenames = filenamesOrDefault(filenames) - - for _, filename := range filenames { - err = loadFile(filename, false) - if err != nil { - return // return early on a spazout - } - } - return -} - -// Overload will read your env file(s) and load them into ENV for this process. -// -// Call this function as close as possible to the start of your program (ideally in main) -// -// If you call Overload without any args it will default to loading .env in the current path -// -// You can otherwise tell it which files to load (there can be more than one) like -// -// godotenv.Overload("fileone", "filetwo") -// -// It's important to note this WILL OVERRIDE an env variable that already exists - consider the .env file to forcefilly set all vars. -func Overload(filenames ...string) (err error) { - filenames = filenamesOrDefault(filenames) - - for _, filename := range filenames { - err = loadFile(filename, true) - if err != nil { - return // return early on a spazout - } - } - return -} - -// Read all env (with same file loading semantics as Load) but return values as -// a map rather than automatically writing values into env -func Read(filenames ...string) (envMap map[string]string, err error) { - filenames = filenamesOrDefault(filenames) - envMap = make(map[string]string) - - for _, filename := range filenames { - individualEnvMap, individualErr := readFile(filename) - - if individualErr != nil { - err = individualErr - return // return early on a spazout - } - - for key, value := range individualEnvMap { - envMap[key] = value - } - } - - return -} - -// Exec loads env vars from the specified filenames (empty map falls back to default) -// then executes the cmd specified. -// -// Simply hooks up os.Stdin/err/out to the command and calls Run() -// -// If you want more fine grained control over your command it's recommended -// that you use `Load()` or `Read()` and the `os/exec` package yourself. -func Exec(filenames []string, cmd string, cmdArgs []string) error { - Load(filenames...) - - command := exec.Command(cmd, cmdArgs...) - command.Stdin = os.Stdin - command.Stdout = os.Stdout - command.Stderr = os.Stderr - return command.Run() -} - -func filenamesOrDefault(filenames []string) []string { - if len(filenames) |
