diff options
| author | Christine Dodrill <me@christine.website> | 2018-10-19 06:58:02 -0700 |
|---|---|---|
| committer | Christine Dodrill <me@christine.website> | 2018-10-19 06:58:35 -0700 |
| commit | d2ff4407993e4511e0225c12964bc07cd8d02be6 (patch) | |
| tree | 1ca621c635b568054bf8808306cf4b6baa9cfedf /vendor/github.com/google | |
| parent | f363c7e7eb6ca43e92624365ceab66a78d99b376 (diff) | |
| download | xesite-d2ff4407993e4511e0225c12964bc07cd8d02be6.tar.xz xesite-d2ff4407993e4511e0225c12964bc07cd8d02be6.zip | |
use GOPROXY
Diffstat (limited to 'vendor/github.com/google')
| -rw-r--r-- | vendor/github.com/google/gops/LICENSE | 27 | ||||
| -rw-r--r-- | vendor/github.com/google/gops/agent/agent.go | 237 | ||||
| -rw-r--r-- | vendor/github.com/google/gops/internal/internal.go | 52 | ||||
| -rw-r--r-- | vendor/github.com/google/gops/signal/signal.go | 35 |
4 files changed, 0 insertions, 351 deletions
diff --git a/vendor/github.com/google/gops/LICENSE b/vendor/github.com/google/gops/LICENSE deleted file mode 100644 index 55e52a0..0000000 --- a/vendor/github.com/google/gops/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2016 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/google/gops/agent/agent.go b/vendor/github.com/google/gops/agent/agent.go deleted file mode 100644 index 5708391..0000000 --- a/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/vendor/github.com/google/gops/internal/internal.go b/vendor/github.com/google/gops/internal/internal.go deleted file mode 100644 index 1382822..0000000 --- a/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/vendor/github.com/google/gops/signal/signal.go b/vendor/github.com/google/gops/signal/signal.go deleted file mode 100644 index b2bfbe1..0000000 --- a/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) -) |
