summaryrefslogtreecommitdiff
path: root/vendor/codeberg.org/gruf/go-debug
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/codeberg.org/gruf/go-debug')
-rw-r--r--vendor/codeberg.org/gruf/go-debug/LICENSE9
-rw-r--r--vendor/codeberg.org/gruf/go-debug/README.md37
-rw-r--r--vendor/codeberg.org/gruf/go-debug/debug.go53
-rw-r--r--vendor/codeberg.org/gruf/go-debug/debug_env.go9
-rw-r--r--vendor/codeberg.org/gruf/go-debug/debug_off.go7
-rw-r--r--vendor/codeberg.org/gruf/go-debug/debug_on.go7
-rw-r--r--vendor/codeberg.org/gruf/go-debug/pprof_off.go16
-rw-r--r--vendor/codeberg.org/gruf/go-debug/pprof_on.go63
-rw-r--r--vendor/codeberg.org/gruf/go-debug/run_tests.sh17
9 files changed, 0 insertions, 218 deletions
diff --git a/vendor/codeberg.org/gruf/go-debug/LICENSE b/vendor/codeberg.org/gruf/go-debug/LICENSE
deleted file mode 100644
index e4163ae35..000000000
--- a/vendor/codeberg.org/gruf/go-debug/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) 2022 gruf
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/codeberg.org/gruf/go-debug/README.md b/vendor/codeberg.org/gruf/go-debug/README.md
deleted file mode 100644
index 44cbc9d5f..000000000
--- a/vendor/codeberg.org/gruf/go-debug/README.md
+++ /dev/null
@@ -1,37 +0,0 @@
-# go-debug
-
-This library provides a very simple method for compile-time or runtime determined debug checks, set using build tags.
-
-The compile-time checks use Go constants, so when disabled your debug code will not be compiled.
-
-The possible build tags are:
-
-- "debug" || "" = debug determined at compile-time
-
-- "debugenv" = debug determined at runtime using the $DEBUG environment variable
-
-An example for how this works in practice can be seen by the following code:
-
-```
-func main() {
- println("debug.DEBUG() =", debug.DEBUG())
-}
-```
-
-```
-# Debug determined at compile-time, it is disabled
-$ go run .
-debug.DEBUG() = false
-
-# Debug determined at compile-time, it is enabled
-$ go run -tags=debug .
-debug.DEBUG() = true
-
-# Debug determined at runtime, $DEBUG is not set
-$ go run -tags=debugenv .
-debug.DEBUG() = false
-
-# Debug determined at runtime, $DEBUG is set
-$ DEBUG=y go run -tags=debugenv .
-debug.DEBUG() = true
-``` \ No newline at end of file
diff --git a/vendor/codeberg.org/gruf/go-debug/debug.go b/vendor/codeberg.org/gruf/go-debug/debug.go
deleted file mode 100644
index e7121390d..000000000
--- a/vendor/codeberg.org/gruf/go-debug/debug.go
+++ /dev/null
@@ -1,53 +0,0 @@
-package debug
-
-import (
- _debug "runtime/debug"
-)
-
-// Run will only call fn if DEBUG is enabled.
-func Run(fn func()) {
- if DEBUG {
- fn()
- }
-}
-
-// BuildInfo will return a useful new-line separated build info string for current binary, setting name as given value.
-func BuildInfo(name string) string {
- // Read build info from current binary
- build, ok := _debug.ReadBuildInfo()
- if !ok {
- return "name=" + name + "\n"
- }
-
- var flags, vcs, commit, time string
-
- // Parse build information from BuildInfo.Settings
- for i := 0; i < len(build.Settings); i++ {
- switch build.Settings[i].Key {
- case "-gcflags":
- flags += ` -gcflags="` + build.Settings[i].Value + `"`
- case "-ldflags":
- flags += ` -ldflags="` + build.Settings[i].Value + `"`
- case "-tags":
- flags += ` -tags="` + build.Settings[i].Value + `"`
- case "vcs":
- vcs = build.Settings[i].Value
- case "vcs.revision":
- commit = build.Settings[i].Value
- if len(commit) > 8 {
- commit = commit[:8]
- }
- case "vcs.time":
- time = build.Settings[i].Value
- }
- }
-
- return "" +
- "name=" + name + "\n" +
- "vcs=" + vcs + "\n" +
- "commit=" + commit + "\n" +
- "version=" + build.Main.Version + "\n" +
- "path=" + build.Path + "\n" +
- "build=" + build.GoVersion + flags + "\n" +
- "time=" + time + "\n"
-}
diff --git a/vendor/codeberg.org/gruf/go-debug/debug_env.go b/vendor/codeberg.org/gruf/go-debug/debug_env.go
deleted file mode 100644
index 4401b9725..000000000
--- a/vendor/codeberg.org/gruf/go-debug/debug_env.go
+++ /dev/null
@@ -1,9 +0,0 @@
-//go:build debugenv
-// +build debugenv
-
-package debug
-
-import "os"
-
-// DEBUG returns whether debugging is enabled.
-var DEBUG = (os.Getenv("DEBUG") != "")
diff --git a/vendor/codeberg.org/gruf/go-debug/debug_off.go b/vendor/codeberg.org/gruf/go-debug/debug_off.go
deleted file mode 100644
index 82ef7263e..000000000
--- a/vendor/codeberg.org/gruf/go-debug/debug_off.go
+++ /dev/null
@@ -1,7 +0,0 @@
-//go:build !debug && !debugenv
-// +build !debug,!debugenv
-
-package debug
-
-// DEBUG returns whether debugging is enabled.
-const DEBUG = false
diff --git a/vendor/codeberg.org/gruf/go-debug/debug_on.go b/vendor/codeberg.org/gruf/go-debug/debug_on.go
deleted file mode 100644
index 91edd5fe5..000000000
--- a/vendor/codeberg.org/gruf/go-debug/debug_on.go
+++ /dev/null
@@ -1,7 +0,0 @@
-//go:build debug && !debugenv
-// +build debug,!debugenv
-
-package debug
-
-// DEBUG returns whether debugging is enabled.
-const DEBUG = true
diff --git a/vendor/codeberg.org/gruf/go-debug/pprof_off.go b/vendor/codeberg.org/gruf/go-debug/pprof_off.go
deleted file mode 100644
index 5ad77ce0d..000000000
--- a/vendor/codeberg.org/gruf/go-debug/pprof_off.go
+++ /dev/null
@@ -1,16 +0,0 @@
-//go:build !debug && !debugenv
-// +build !debug,!debugenv
-
-package debug
-
-import "net/http"
-
-// ServePprof will start an HTTP server serving /debug/pprof only if debug enabled.
-func ServePprof(addr string) error {
- return nil
-}
-
-// WithPprof will add /debug/pprof handling (provided by "net/http/pprof") only if debug enabled.
-func WithPprof(handler http.Handler) http.Handler {
- return handler
-}
diff --git a/vendor/codeberg.org/gruf/go-debug/pprof_on.go b/vendor/codeberg.org/gruf/go-debug/pprof_on.go
deleted file mode 100644
index 4f91aa092..000000000
--- a/vendor/codeberg.org/gruf/go-debug/pprof_on.go
+++ /dev/null
@@ -1,63 +0,0 @@
-//go:build debug || debugenv
-// +build debug debugenv
-
-package debug
-
-import (
- "net/http"
- "net/http/pprof"
- "strings"
-)
-
-// ServePprof will start an HTTP server serving /debug/pprof only if debug enabled.
-func ServePprof(addr string) error {
- if !DEBUG {
- // debug disabled in env
- return nil
- }
- handler := WithPprof(nil)
- return http.ListenAndServe(addr, handler)
-}
-
-// WithPprof will add /debug/pprof handling (provided by "net/http/pprof") only if debug enabled.
-func WithPprof(handler http.Handler) http.Handler {
- if !DEBUG {
- // debug disabled in env
- return handler
- }
-
- // Default serve mux is setup with pprof
- pprofmux := http.DefaultServeMux
-
- if pprofmux == nil {
- // Someone nil'ed the default mux
- pprofmux = &http.ServeMux{}
- pprofmux.HandleFunc("/debug/pprof/", pprof.Index)
- pprofmux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
- pprofmux.HandleFunc("/debug/pprof/profile", pprof.Profile)
- pprofmux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
- pprofmux.HandleFunc("/debug/pprof/trace", pprof.Trace)
- }
-
- if handler == nil {
- // Ensure handler is non-nil
- handler = http.NotFoundHandler()
- }
-
- // Debug enabled, return wrapped handler func
- return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
- const prefix = "/debug/pprof"
-
- // /debug/pprof(/.*)? -> pass to pprofmux
- if strings.HasPrefix(r.URL.Path, prefix) {
- path := r.URL.Path[len(prefix):]
- if path == "" || path[0] == '/' {
- pprofmux.ServeHTTP(rw, r)
- return
- }
- }
-
- // .* -> pass to handler
- handler.ServeHTTP(rw, r)
- })
-}
diff --git a/vendor/codeberg.org/gruf/go-debug/run_tests.sh b/vendor/codeberg.org/gruf/go-debug/run_tests.sh
deleted file mode 100644
index f7ef1d60d..000000000
--- a/vendor/codeberg.org/gruf/go-debug/run_tests.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/sh
-
-(
- # Run in subshell with cmd echo
- set -ex
-
- # Run debug tests
- DEBUG= go test -tags= -v
- DEBUG= go test -tags=debug -v
- DEBUG= go test -tags=debugenv -v
- DEBUG=y go test -tags=debugenv -v
- DEBUG=1 go test -tags=debugenv -v
- DEBUG=y go test -tags=debugenv,debug -v
- DEBUG=y go test -tags= -v
-)
-
-echo 'success!' \ No newline at end of file