### Install go-colorable Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/mattn/go-colorable/README.md Install the go-colorable package using the go get command. ```bash $ go get github.com/mattn/go-colorable ``` -------------------------------- ### Install GoVultr V2 Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/vultr/govultr/v2/README.md Install the GoVultr V2 package using go get. ```sh go get -u github.com/vultr/govultr/v2 ``` -------------------------------- ### Install go-isatty Package Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/mattn/go-isatty/README.md Use the go get command to install the go-isatty package. ```bash go get github.com/mattn/go-isatty ``` -------------------------------- ### Install linodego Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/linode/linodego/README.md Install the linodego package using go get. ```sh go get -u github.com/linodego ``` -------------------------------- ### Install Golang Color Library Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/fatih/color/README.md Use 'go get' to install the color library. This command fetches and installs the specified package. ```bash go get github.com/fatih/color ``` -------------------------------- ### Install go-version Library Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/hashicorp/go-version/README.md Install the go-version library using the go get command. This is the standard method for obtaining Go packages. ```bash $ go get github.com/hashicorp/go-version ``` -------------------------------- ### Install ULID Go Package Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/oklog/ulid/README.md Use `go get` to install the ULID library. ```shell go get github.com/oklog/ulid ``` -------------------------------- ### Install go-ini/ini Package Source: https://github.com/jacksontj/promxy/blob/master/vendor/gopkg.in/ini.v1/README.md Install the go-ini/ini package using the go get command. Use the -u flag for updates. ```shell go get gopkg.in/ini.v1 ``` -------------------------------- ### Define a WebService with Routes Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/emicklei/go-restful/v3/README.md Example of setting up a WebService, defining its path, supported content types, and a GET route for retrieving a user by ID. This snippet illustrates basic route configuration and parameter definition. ```go ws := new(restful.WebService) ws. Path("/users"). Consumes(restful.MIME_XML, restful.MIME_JSON). Produces(restful.MIME_JSON, restful.MIME_XML) ws.Route(ws.GET("/{user-id}").To(u.findUser). Doc("get a user"). Param(ws.PathParameter("user-id", "identifier of the user").DataType("string")). Writes(User{})) ... func (u UserResource) findUser(request *restful.Request, response *restful.Response) { id := request.PathParameter("user-id") ... } ``` -------------------------------- ### Example Client Setup with OAuth2 Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/vultr/govultr/v2/README.md Instantiate a GoVultr client using a Personal Access Token (PAT) for authentication. Optional parameters allow customization of the base URL, UserAgent, and rate limiting. ```go package main import ( "context" "os" "github.com/vultr/govultr/v2" "golang.org/x/oauth2" ) func main() { apiKey := os.Getenv("VultrAPIKey") config := &oauth2.Config{} ctx := context.Background() ts := config.TokenSource(ctx, &oauth2.Token{AccessToken: apiKey}) vultrClient := govultr.NewClient(oauth2.NewClient(ctx, ts)) // Optional changes _ = vultrClient.SetBaseURL("https://api.vultr.com") vultrClient.SetUserAgent("mycool-app") vultrClient.SetRateLimit(500) } ``` -------------------------------- ### Install json-iterator/go Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/json-iterator/go/README.md Use go get to install the json-iterator/go library. ```go go get github.com/json-iterator/go ``` -------------------------------- ### Install mapstructure Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/go-viper/mapstructure/v2/README.md Install the mapstructure library using the go get command. ```shell go get github.com/go-viper/mapstructure/v2 ``` -------------------------------- ### Install cronexpr Library Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/hashicorp/cronexpr/README.md Use go get to install the cronexpr library. This command fetches and installs the package and its dependencies. ```go go get github.com/gorhill/cronexpr ``` -------------------------------- ### Install copystructure Go Library Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/mitchellh/copystructure/README.md Install the copystructure library using the standard Go get command. ```bash go get github.com/mitchellh/copystructure ``` -------------------------------- ### Install Godo Go Client Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/digitalocean/godo/README.md Install the Godo Go client library using go get. Specify a version for stable releases or omit for the latest. ```sh go get github.com/digitalocean/godo@vX.Y.Z ``` ```sh go get github.com/digitalocean/godo ``` -------------------------------- ### Install go-autorest/autorest/adal Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/Azure/go-autorest/autorest/adal/README.md Use this command to install the authentication library. ```bash go get -u github.com/Azure/go-autorest/autorest/adal ``` -------------------------------- ### Install and Run Local Go Doc Site Source: https://github.com/jacksontj/promxy/blob/master/vendor/go.opentelemetry.io/otel/CONTRIBUTING.md Installs the pkgsite tool and runs a local Go documentation site. This is useful for previewing package documentation. ```sh go install golang.org/x/pkgsite/cmd/pkgsite@latest pkgsite ``` -------------------------------- ### Install Compute API Metadata Client Source: https://github.com/jacksontj/promxy/blob/master/vendor/cloud.google.com/go/compute/metadata/README.md Use this command to install the compute metadata client library. ```bash go get cloud.google.com/go/compute/metadata ``` -------------------------------- ### Install Backoff Package Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/jpillora/backoff/README.md Install the backoff package using the go get command. ```bash $ go get -v github.com/jpillora/backoff ``` -------------------------------- ### Install yaml.v2 Package Source: https://github.com/jacksontj/promxy/blob/master/vendor/gopkg.in/yaml.v2/README.md Use 'go get' to install the yaml.v2 package for use in your Go projects. ```bash go get gopkg.in/yaml.v2 ``` -------------------------------- ### Install go-autorest Packages Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/Azure/go-autorest/README.md Provides the go get commands to install the core go-autorest packages, including autorest, azure, date, and to. ```bash go get github.com/Azure/go-autorest/autorest go get github.com/Azure/go-autorest/autorest/azure go get github.com/Azure/go-autorest/autorest/date go get github.com/Azure/go-autorest/autorest/to ``` -------------------------------- ### Install Azure Network Module Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4/README.md Use 'go get' to install the Azure Network module for Go. This command fetches and installs the specified package and its dependencies. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v2 ``` -------------------------------- ### Install Google Auth Library for Go Source: https://github.com/jacksontj/promxy/blob/master/vendor/cloud.google.com/go/auth/README.md Use this command to install the latest version of the Google Auth library for Go. ```bash go get cloud.google.com/go/auth@latest ``` -------------------------------- ### Example Load Command with Series and Points Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/prometheus/prometheus/promql/promqltest/README.md An example demonstrating the 'load' command with a specific series and a complex point specification, including regular points, range-based points, and stale markers. ```promqltest load 1m my_metric{env="prod"} 5 2+3x2 _ stale {{schema:1 sum:3 count:22 buckets:[5 10 7]}} ``` -------------------------------- ### Install IONOS Cloud SDK for GO Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/ionos-cloud/sdk-go/v6/README.md Use `go get` to add the SDK to your GOPATH workspace or project's Go module dependencies. ```bash go get github.com/ionos-cloud/sdk-go/v6 ``` -------------------------------- ### Initialize Procfs and Get Stats Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/prometheus/procfs/README.md Initializes the proc filesystem and retrieves general statistics. Use this to start interacting with procfs data. ```go fs, err := procfs.NewFS("/proc") stats, err := fs.Stat() ``` -------------------------------- ### Basic Test Script Example Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/fsnotify/fsnotify/CONTRIBUTING.md An example of a test script that creates a file and writes data to it, demonstrating expected output events. ```bash # Create a new empty file with some data. watch / echo data >/file Output: create /file write /file ``` -------------------------------- ### Install Specific SDK Version with Go Modules Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/ionos-cloud/sdk-go/v6/README.md When using Go modules, specify a release version using `@` with the `go get` command. ```bash go get github.com/ionos-cloud/sdk-go/v6@v6.0.0 ``` -------------------------------- ### Install ULID Package Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/oklog/ulid/v2/README.md Installs the oklog/ulid/v2 package using Go modules. ```shell go get github.com/oklog/ulid/v2 ``` -------------------------------- ### Enhanced GET Request with Query Params and Auth Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/go-resty/resty/v2/README.md Demonstrates setting query parameters, headers, and authentication tokens for a GET request. Requires `strconv` and `time` packages. ```go // Create a Resty Client client := resty.New() resp, err := client.R(). SetQueryParams(map[string]string{ "page_no": "1", "limit": "20", "sort":"name", "order": "asc", "random":strconv.FormatInt(time.Now().Unix(), 10), }). SetHeader("Accept", "application/json"). SetAuthToken("BC594900518B4F7EAC75BD37F019E08FBC594900518B4F7EAC75BD37F019E08F"). Get("/search_result") // Sample of using Request.SetQueryString method resp, err := client.R(). SetQueryString("productId=232&template=fresh-sample&cat=resty&source=google&kw=buy a lot more"). SetHeader("Accept", "application/json"). SetAuthToken("BC594900518B4F7EAC75BD37F019E08FBC594900518B4F7EAC75BD37F019E08F"). Get("/show_product") // If necessary, you can force response content type to tell Resty to parse a JSON response into your struct resp, err := client.R(). SetResult(result). ForceContentType("application/json"). Get("v2/alpine/manifests/latest") ``` -------------------------------- ### General Usage Example Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/linode/linodego/README.md Demonstrates how to initialize the linodego client with an API key and retrieve a Linode instance. Ensure the LINODE_TOKEN environment variable is set. ```go package main import ( "context" "fmt" "log" "net/http" "os" "github.com/linode/linodego" "golang.org/x/oauth2" ) func main() { apiKey, ok := os.LookupEnv("LINODE_TOKEN") if !ok { log.Fatal("Could not find LINODE_TOKEN, please assert it is set.") } tokenSource := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: apiKey}) oauth2Client := &http.Client{ Transport: &oauth2.Transport{ Source: tokenSource, }, } linodeClient := linodego.NewClient(oauth2Client) linodeClient.SetDebug(true) res, err := linodeClient.GetInstance(context.Background(), 4090913) if err != nil { log.Fatal(err) } fmt.Printf("%v", res) } ``` -------------------------------- ### Install npm Dependencies and Build UI Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/prometheus/prometheus/web/ui/README.md Installs all required npm package dependencies and builds the local workspace npm modules. Run this from the repository root. ```bash make ui-build ``` -------------------------------- ### Reading Scaleway Config and Creating Client Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/scaleway/scaleway-sdk-go/scw/README.md Demonstrates how to load the Scaleway configuration, select an active profile, and initialize a new client with specific options. The order of options determines precedence. ```go p, _ := scw.MustLoadConfig().GetActiveProfile() scw.NewClient( scw.WithProfile(p), scw.WithEnv(), scw.WithDefaultRegion(scw.RegionFrPar) ) ``` -------------------------------- ### Install gobwas/glob Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/gobwas/glob/readme.md Install the gobwas/glob library using the go get command. ```shell go get github.com/gobwas/glob ``` -------------------------------- ### Example Configuration A Source: https://github.com/jacksontj/promxy/blob/master/vendor/go.opentelemetry.io/collector/confmap/README.md A sample configuration file defining receivers, processors, exporters, extensions, and service pipelines. ```yaml receivers: nop: processors: nop: exporters: nop: extensions: nop: service: extensions: [nop] pipelines: traces: receivers: [nop] processors: [nop] exporters: [nop] ``` -------------------------------- ### Install go.uber.org/atomic Source: https://github.com/jacksontj/promxy/blob/master/vendor/go.uber.org/atomic/README.md Install the latest version of the atomic package using go get. ```shell $ go get -u go.uber.org/atomic@v1 ``` -------------------------------- ### Instantiation with Options Source: https://github.com/jacksontj/promxy/blob/master/vendor/go.opentelemetry.io/otel/CONTRIBUTING.md Demonstrates how to instantiate a type using a variadic slice of Option parameters. ```go func NewT(options ...Option) T {…} ``` -------------------------------- ### Install go.uber.org/multierr Source: https://github.com/jacksontj/promxy/blob/master/vendor/go.uber.org/multierr/README.md Install the latest version of the multierr library using the go get command. ```bash go get -u go.uber.org/multierr@latest ``` -------------------------------- ### Install uuid Package Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/google/uuid/README.md Use this command to install the uuid package using go get. ```sh go get github.com/google/uuid ``` -------------------------------- ### Basic HttpRouter Usage in Go Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/julienschmidt/httprouter/README.md Demonstrates setting up a basic HTTP server with HttpRouter, defining routes for the root and a dynamic path, and handling requests. ```go package main import ( "fmt" "net/http" "log" "github.com/julienschmidt/httprouter" ) func Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { fmt.Fprint(w, "Welcome!\n") } func Hello(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { fmt.Fprintf(w, "hello, %s!\n", ps.ByName("name")) } func main() { router := httprouter.New() router.GET("/", Index) router.GET("/hello/:name", Hello) log.Fatal(http.ListenAndServe(":8080", router)) } ``` -------------------------------- ### Coexisting klog/v1 and klog/v2 Source: https://github.com/jacksontj/promxy/blob/master/vendor/k8s.io/klog/v2/README.md This example demonstrates how to use both klog/v1 and klog/v2 within the same project, which might be necessary during migration phases. ```go // See examples/coexist_klog_v1_and_v2/ ``` -------------------------------- ### Install and Import Kubernetes YAML Package Source: https://github.com/jacksontj/promxy/blob/master/vendor/sigs.k8s.io/yaml/README.md Install the package using go get and import it into your Go projects. ```bash go get sigs.k8s.io/yaml ``` ```go import "sigs.k8s.io/yaml" ``` -------------------------------- ### Install Golex Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/prometheus/prometheus/model/textparse/README.md Install the golex tool, which is required for regenerating lexer files. Use this command to get the latest version. ```bash go get -u modernc.org/golex ``` -------------------------------- ### Build All Files (Old System) Source: https://github.com/jacksontj/promxy/blob/master/vendor/golang.org/x/sys/unix/README.md Builds the Go files for the current OS and architecture using the old build system. Ensure GOOS and GOARCH are set correctly. ```bash mkall.sh ``` -------------------------------- ### Initialize klog-gokit with go-kit logger Source: https://github.com/jacksontj/promxy/blob/master/vendor/k8s.io/klog/README.md Import the package and create a go-kit logger. Then, set this logger as the default for klog. This must be done at the beginning of your program. ```go // Import the package like it is original klog import ( ... "github.com/go-kit/log" klog "k8s.io/klog/v2" ... ) // Create go-kit logger in your main.go logger := log.NewLogfmtLogger(log.NewSyncWriter(os.Stdout)) logger = log.With(logger, "ts", log.DefaultTimestampUTC) logger = log.With(logger, "caller", log.DefaultCaller) logger = level.NewFilter(logger, level.AllowAll()) // Overriding the default klog with our go-kit klog implementation. // Thus we need to pass it our go-kit logger object. klog.SetLogger(logger) ``` -------------------------------- ### Update Import Path and Install JWT Go v4 Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/golang-jwt/jwt/v5/MIGRATION_GUIDE.md Replace existing JWT import paths with 'github.com/golang-jwt/jwt/v4' and install the new version using go get and go mod tidy. ```bash go get github.com/golang-jwt/jwt/v4 go mod tidy ``` -------------------------------- ### HJSON Parser Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/knadh/koanf/v2/README.md Parses HJSON bytes into a nested map. Install with 'go get -u github.com/knadh/koanf/parsers/hjson'. ```go hjson.Parser() ``` -------------------------------- ### Basic Cache Usage with Context and Options Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/Code-Hex/go-generics-cache/README.md Demonstrates creating a cache with context, setting and getting values, and using expiration options. This snippet shows both a simple cache and a numeric cache with increment/decrement operations. ```Go package main import ( "context" "fmt" "time" cache "github.com/Code-Hex/go-generics-cache" ) func main() { ctx, cancel := context.WithCancel(context.Background()) defer cancel() // use simple cache algorithm without options. c := cache.NewContext[string, int](ctx) c.Set("a", 1) gota, aok := c.Get("a") gotb, bok := c.Get("b") fmt.Println(gota, aok) // 1 true fmt.Println(gotb, bok) // 0 false // Create a cache for Number constraint. key as string, value as int. nc := cache.NewNumber[string, int]() nc.Set("age", 26, cache.WithExpiration(time.Hour)) incremented := nc.Increment("age", 1) fmt.Println(incremented) // 27 decremented := nc.Decrement("age", 1) fmt.Println(decremented) // 26 } ``` -------------------------------- ### NestedText Parser Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/knadh/koanf/v2/README.md Parses NestedText bytes into a flat map. Install with 'go get -u github.com/knadh/koanf/parsers/nestedtext'. ```go nestedtext.Parser() ``` -------------------------------- ### Client Setup Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/vultr/govultr/v2/README.md This snippet shows how to initialize the GoVultr client with your Vultr API key and optionally configure base URL, user agent, and rate limiting. ```APIDOC ## Client Setup ### Description Initialize the GoVultr client using your Vultr Personal Access Token (PAT). Optional parameters allow customization of the base URL, User-Agent, and rate limiting to avoid API errors. ### Code Example ```go package main import ( "context" "os" "github.com/vultr/govultr/v2" "golang.org/x/oauth2" ) func main() { apiKey := os.Getenv("VultrAPIKey") config := &oauth2.Config{} ctx := context.Background() ts := config.TokenSource(ctx, &oauth2.Token{AccessToken: apiKey}) vultrClient := govultr.NewClient(oauth2.NewClient(ctx, ts)) // Optional changes _ = vultrClient.SetBaseURL("https://api.vultr.com") vultrClient.SetUserAgent("mycool-app") vultrClient.SetRateLimit(500) } ``` ``` -------------------------------- ### DotEnv Parser Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/knadh/koanf/v2/README.md Parses DotEnv bytes into a flat map. Install with 'go get -u github.com/knadh/koanf/parsers/dotenv'. ```go dotenv.Parser() ``` -------------------------------- ### Example: Instant Query with Expectations Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/prometheus/prometheus/promql/promqltest/README.md Demonstrates an instant query evaluation with 'expect warn' and 'expect no_info', followed by expected results for specific series. ```promql eval instant at 1m sum by (env) (my_metric) expect warn expect no_info {env="prod"} 5 {env="test"} 20 ``` -------------------------------- ### TOML Parser Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/knadh/koanf/v2/README.md Parses TOML bytes into a nested map. Install with 'go get -u github.com/knadh/koanf/parsers/toml'. ```go toml.Parser() ``` -------------------------------- ### YAML Parser Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/knadh/koanf/v2/README.md Parses YAML bytes into a nested map. Install with 'go get -u github.com/knadh/koanf/parsers/yaml'. ```go yaml.Parser() ``` -------------------------------- ### Explicit Instrumentation Setup in Go Source: https://github.com/jacksontj/promxy/blob/master/vendor/go.opentelemetry.io/otel/CONTRIBUTING.md Demonstrates the recommended pattern for initializing OpenTelemetry instrumentation within a component's constructor. This approach ensures clear ownership and scope, avoiding global side effects. It requires importing necessary OpenTelemetry packages. ```go import ( "errors" semconv "go.opentelemetry.io/otel/semconv/v1.40.0" "go.opentelemetry.io/otel/semconv/v1.40.0/otelconv" ) type SDKComponent struct { inst *instrumentation } func NewSDKComponent(config Config) (*SDKComponent, error) { inst, err := newInstrumentation() if err != nil { return nil, err } return &SDKComponent{inst: inst}, nil } type instrumentation struct { inflight otelconv.SDKComponentInflight exported otelconv.SDKComponentExported } func newInstrumentation() (*instrumentation, error) { if !x.Observability.Enabled() { return nil, nil } meter := otel.GetMeterProvider().Meter( "", metric.WithInstrumentationVersion(sdk.Version()), metric.WithSchemaURL(semconv.SchemaURL), ) inst := &instrumentation{} var err, e error inst.inflight, e = otelconv.NewSDKComponentInflight(meter) err = errors.Join(err, e) inst.exported, e = otelconv.NewSDKComponentExported(meter) err = errors.Join(err, e) return inst, err } ``` -------------------------------- ### JSON Parser Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/knadh/koanf/v2/README.md Parses JSON bytes into a nested map. Install with 'go get -u github.com/knadh/koanf/parsers/json'. ```go json.Parser() ``` -------------------------------- ### Run golangci-lint Locally Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/Microsoft/go-winio/README.md Install and run golangci-lint from the command line within the repository root. Use flags to control the verbosity of the output. ```shell # use . or specify a path to only lint a package # to show all lint errors, use flags "--max-issues-per-linter=0 --max-same-issues=0" > golangci-lint run ./... ``` -------------------------------- ### Basic Structured Logging with Logfmt in Go Kit Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/go-kit/kit/log/README.md Demonstrates how to set up a basic logfmt logger that writes to standard error and logs a simple key-value pair. ```go w := log.NewSyncWriter(os.Stderr) logger := log.NewLogfmtLogger(w) logger.Log("question", "what is the meaning of life?", "answer", 42) // Output: // question="what is the meaning of life?" answer=42 ``` -------------------------------- ### URL Path Construction Example Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/Azure/go-autorest/README.md Illustrates how multiple WithPath decorators can be used to construct a URL. Decorators are applied in the order provided, resulting in a concatenated path. ```go req, err := Prepare(&http.Request{}, \ WithBaseURL("https://microsoft.com/"), \ WithPath("a"), \ WithPath("b"), \ WithPath("c")) ``` -------------------------------- ### Simple Backoff Example Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/jpillora/backoff/README.md Demonstrates the basic usage of the Backoff counter with default settings. Shows how Duration() increases the backoff time and Reset() restarts the counter. ```go b := &backoff.Backoff{ //These are the defaults Min: 100 * time.Millisecond, Max: 10 * time.Second, Factor: 2, Jitter: false, } fmt.Printf("%s\n", b.Duration()) fmt.Printf("%s\n", b.Duration()) fmt.Printf("%s\n", b.Duration()) fmt.Printf("Reset!\n") b.Reset() fmt.Printf("%s\n", b.Duration()) ``` -------------------------------- ### AWS ParameterStore Provider Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/knadh/koanf/v2/README.md AWS ParameterStore provider for Koanf. Includes an optional function to transform environment variables. Install with 'go get -u github.com/defensestation/koanf/providers/parameterstore'. ```go vault.ParameterStore(parameterstore.Config{}, f func(s string) string) ``` -------------------------------- ### Coexisting klog with glog Source: https://github.com/jacksontj/promxy/blob/master/vendor/k8s.io/klog/v2/README.md This example shows how to initialize and synchronize flags between klog and glog, and how to direct all logs to stderr by setting `alsologtostderr` or `logtostderr` to true. ```go // See examples/coexist_glog/coexist_glog.go ``` -------------------------------- ### HCL Parser with FlattenSlices Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/knadh/koanf/v2/README.md Parses Hashicorp HCL bytes into a nested map. 'flattenSlices' is recommended to be set to true. Install with 'go get -u github.com/knadh/koanf/parsers/hcl'. ```go hcl.Parser(flattenSlices bool) ``` -------------------------------- ### AWS Secrets Manager Provider Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/knadh/koanf/v2/README.md AWS Secrets Manager provider for Koanf. Takes a map or string value from the store. Install with 'go get -u github.com/defensestation/koanf/providers/secretsmanager'. ```go vault.SecretsManager(secretsmanager.Config{}, f func(s string) string) ``` -------------------------------- ### Catch-All Parameters Example Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/julienschmidt/httprouter/README.md Illustrates the use of catch-all parameters, denoted by '*name'. These parameters match any remaining path and must always be at the end of the pattern. ```go Pattern: /src/*filepath /src/ match /src/somefile.go match /src/subdir/somefile.go match ``` -------------------------------- ### Device Code Authentication with azidentity Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/Azure/azure-sdk-for-go/sdk/azidentity/MIGRATION.md Shows how to implement device code authentication using the azidentity package. ```go import ( "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions" ) cred, err := azidentity.NewDeviceCodeCredential(nil) handle(err) client, err := armsubscriptions.NewSubscriptionsClient(cred, nil) handle(err) ``` -------------------------------- ### Basic Glob Compilation and Matching Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/gobwas/glob/readme.md Demonstrates compiling a simple glob pattern and matching a string against it. ```go package main import "github.com/gobwas/glob" func main() { var g glob.Glob // create simple glob g = glob.MustCompile("*.github.com") g.Match("api.github.com") // true // quote meta characters and then create simple glob g = glob.MustCompile(glob.QuoteMeta("*.github.com")) g.Match("*.github.com") // true } ``` -------------------------------- ### Install ULID Command-line Tool Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/oklog/ulid/v2/README.md Installs the ULID command-line tool using Go modules. Ensure you have Go installed and configured. ```shell go install github.com/oklog/ulid/v2/cmd/ulid@latest ``` -------------------------------- ### Deterministic Testing Setup Source: https://github.com/jacksontj/promxy/blob/master/vendor/go.opentelemetry.io/otel/CONTRIBUTING.md Set up deterministic testing by isolating state, using manual readers for metrics, and managing environment variables and global counters. Use t.Cleanup to restore state after tests. ```go func TestObservability(t *testing.T) { // Restore state after test to ensure this does not affect other tests. prev := otel.GetMeterProvider() t.Cleanup(func() { otel.SetMeterProvider(prev) }) // Isolate the meter provider for deterministic testing reader := metric.NewManualReader() meterProvider := metric.NewMeterProvider(metric.WithReader(reader)) otel.SetMeterProvider(meterProvider) // Use t.Setenv to ensure environment variable is restored after test. t.Setenv("OTEL_GO_X_OBSERVABILITY", "true") // Reset component ID counter to ensure deterministic component names. componentIDCounter.Store(0) /* ... test code ... */ } ``` -------------------------------- ### Provision a server Source: https://github.com/jacksontj/promxy/blob/master/vendor/github.com/gophercloud/gophercloud/v2/README.md Uses the Compute service client to create a new server with specified flavor and image IDs. Returns a servers.Server object. ```go import "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers" func main() { // [...] server, err := servers.Create(context.TODO(), computeClient, servers.CreateOpts{ Name: "My new server!", FlavorRef: "flavor_id", ImageRef: "image_id", }).Extract() // [...] } ```