### Install go-autorest/autorest/adal Source: https://github.com/knative/serving/blob/main/vendor/github.com/Azure/go-autorest/autorest/adal/README.md Install the adal package using go get. ```bash go get -u github.com/Azure/go-autorest/autorest/adal ``` -------------------------------- ### Install easyjson for Go >= 1.17 Source: https://github.com/knative/serving/blob/main/vendor/github.com/mailru/easyjson/README.md Install easyjson using 'go get' and then install its tools for Go 1.17 and later. ```sh # for Go >= 1.17 go get github.com/mailru/easyjson && go install github.com/mailru/easyjson/...@latest ``` -------------------------------- ### Install Flect Source: https://github.com/knative/serving/blob/main/vendor/github.com/gobuffalo/flect/README.md Use 'go get' to install the Flect library into your Go project. ```console $ go get github.com/gobuffalo/flect ``` -------------------------------- ### Install OpenCensus Go Source: https://github.com/knative/serving/blob/main/vendor/go.opencensus.io/README.md Use 'go get' to install the OpenCensus Go library. Vendoring or a dependency management tool is recommended. ```bash $ go get -u go.opencensus.io ``` -------------------------------- ### Install and Import kubernetes-sigs/yaml Source: https://github.com/knative/serving/blob/main/vendor/sigs.k8s.io/yaml/README.md Install the library using go get and import it using the standard import path. ```bash $ go get sigs.k8s.io/yaml ``` ```go import "sigs.k8s.io/yaml" ``` -------------------------------- ### Install utfbom Package Source: https://github.com/knative/serving/blob/main/vendor/github.com/dimchansky/utfbom/README.md Use the go get command to install the utfbom package. ```go go get -u github.com/dimchansky/utfbom ``` -------------------------------- ### Install go.yaml.in/yaml/v3 Source: https://github.com/knative/serving/blob/main/vendor/go.yaml.in/yaml/v3/README.md Use 'go get' to install the latest version of the yaml package. ```bash go get go.yaml.in/yaml/v3 ``` -------------------------------- ### Install dnscache Package Source: https://github.com/knative/serving/blob/main/vendor/github.com/rs/dnscache/README.md Use the 'go get' command to install the dnscache package. ```bash go get -u github.com/rs/dnscache ``` -------------------------------- ### Install OTLP Prometheus Translator Source: https://github.com/knative/serving/blob/main/vendor/github.com/prometheus/otlptranslator/README.md Install the library using the go get command. ```bash go get github.com/prometheus/otlptranslator ``` -------------------------------- ### Install and Run Local Go Doc Site Source: https://github.com/knative/serving/blob/main/vendor/go.opentelemetry.io/otel/CONTRIBUTING.md Installs and runs a local Go Doc site for previewing package documentation. Ensure you have Go installed and configured. ```sh go install golang.org/x/pkgsite/cmd/pkgsite@latest pkgsite ``` -------------------------------- ### Install multierr Go Package Source: https://github.com/knative/serving/blob/main/vendor/go.uber.org/multierr/README.md Use `go get` to install the latest version of the multierr package. ```bash go get -u go.uber.org/multierr@latest ``` -------------------------------- ### Install Blackfriday v2 Source: https://github.com/knative/serving/blob/main/vendor/github.com/russross/blackfriday/v2/README.md Use 'go get' to install the Blackfriday v2 package. This command resolves and adds the package to your module, then builds and installs it. ```go go get github.com/russross/blackfriday/v2 ``` -------------------------------- ### Install blackfriday-tool Source: https://github.com/knative/serving/blob/main/vendor/github.com/russross/blackfriday/v2/README.md Download and install the blackfriday-tool command-line utility using 'go get'. This tool provides a standalone program for processing markdown files. ```go go get github.com/russross/blackfriday-tool ``` -------------------------------- ### Install json-iterator/go Source: https://github.com/knative/serving/blob/main/vendor/github.com/json-iterator/go/README.md Use the go get command to install the json-iterator/go library into your project. ```bash go get github.com/json-iterator/go ``` -------------------------------- ### Development Setup and Build Source: https://github.com/knative/serving/blob/main/vendor/github.com/apapsch/go-jsonmerge/v2/README.md Commands for setting up development dependencies and building the project. ```bash # Install depencencies ./init.sh # Build ./build.sh ``` -------------------------------- ### Install Development Tools Source: https://github.com/knative/serving/blob/main/vendor/go.opencensus.io/CONTRIBUTING.md Installs necessary tools for development. This command only needs to be run once. ```bash $ make install-tools # Only first time. ``` -------------------------------- ### Install easyjson for Go < 1.17 Source: https://github.com/knative/serving/blob/main/vendor/github.com/mailru/easyjson/README.md Use 'go get -u' to install easyjson and its dependencies for older Go versions. ```sh # for Go < 1.17 go get -u github.com/mailru/easyjson/... ``` -------------------------------- ### Install go-autorest Packages Source: https://github.com/knative/serving/blob/main/vendor/github.com/Azure/go-autorest/README.md Provides the go get commands to install the core go-autorest packages, including autorest, autorest/azure, and autorest/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 ``` -------------------------------- ### Example Knative Serving Deployments Output Source: https://github.com/knative/serving/blob/main/docs/resources-overview.md Example output from 'kubectl -n knative-serving get deployments', showing the desired, current, up-to-date, and available pod counts for core Knative Serving components. ```console $ kubectl -n knative-serving get deployments NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE activator 1 1 1 1 5d autoscaler 1 1 1 1 5d controller 1 1 1 1 5d webhook 1 1 1 1 5d ``` -------------------------------- ### Example Knative Serving Pods Output Source: https://github.com/knative/serving/blob/main/docs/resources-overview.md Example output from 'kubectl -n knative-serving get pods', verifying the running status and readiness of pods corresponding to the deployments. ```console $ kubectl -n knative-serving get pods NAME READY STATUS RESTARTS AGE activator-c8495dc9-z7xpz 2/2 Running 0 5d autoscaler-66897845df-t5cwg 2/2 Running 0 5d controller-699fb46bb5-xhlkg 1/1 Running 0 5d webhook-76b87b8459-tzj6r 1/1 Running 0 5d ``` -------------------------------- ### Install uuid Package Source: https://github.com/knative/serving/blob/main/vendor/github.com/google/uuid/README.md Use 'go get' to install the uuid package. This command fetches and installs the package, making it available for use in your Go projects. ```sh go get github.com/google/uuid ``` -------------------------------- ### Install Kubetest Source: https://github.com/knative/serving/blob/main/test/README.md Install the kubetest tool, which is required for running presubmit-tests.sh and e2e-tests.sh scripts. ```bash go get -u k8s.io/test-infra/kubetest ``` -------------------------------- ### Install YAML Package for Go Source: https://github.com/knative/serving/blob/main/vendor/go.yaml.in/yaml/v2/README.md Use 'go get' to install the yaml v2 package. The import path is go.yaml.in/yaml/v2. ```bash go get go.yaml.in/yaml/v2 ``` -------------------------------- ### Install Vegeta with Pkg Source: https://github.com/knative/serving/blob/main/vendor/github.com/tsenart/vegeta/v12/README.md Installs Vegeta on FreeBSD using the pkg package manager. ```shell pkg install vegeta ``` -------------------------------- ### Setup Zap Repository Source: https://github.com/knative/serving/blob/main/vendor/go.uber.org/zap/CONTRIBUTING.md Clone the zap repository and set up the upstream remote for contributing. ```bash mkdir -p $GOPATH/src/go.uber.org cd $GOPATH/src/go.uber.org git clone git@github.com:your_github_username/zap.git cd zap git remote add upstream https://github.com/uber-go/zap.git git fetch upstream ``` -------------------------------- ### Install Compute Metadata Package Source: https://github.com/knative/serving/blob/main/vendor/cloud.google.com/go/compute/metadata/README.md Use this command to install the compute metadata package for your Go project. ```bash go get cloud.google.com/go/compute/metadata ``` -------------------------------- ### Initialize Procfs and Get Stat Information Source: https://github.com/knative/serving/blob/main/vendor/github.com/prometheus/procfs/README.md Initializes the proc filesystem and reads CPU statistics. Use this to get general system-wide CPU metrics. ```go fs, err := procfs.NewFS("/proc") stats, err := fs.Stat() ``` -------------------------------- ### Install and Use jsonmerge CLI Source: https://github.com/knative/serving/blob/main/vendor/github.com/apapsch/go-jsonmerge/v2/README.md Instructions for installing the command-line tool and its basic usage for merging JSON files. ```bash $ go get -u github.com/RaveNoX/go-jsonmerge/cmd/jsonmerge $ jsonmerge [options] ... # For help $ jsonmerge -h ``` -------------------------------- ### ConfigStore Initialization in NewImpl Source: https://github.com/knative/serving/blob/main/vendor/knative.dev/pkg/injection/README.md Demonstrates how to initialize and configure the ConfigStore when creating a new controller implementation. ```go kindreconciler "knative.dev//pkg/client/injection/reconciler///" ... impl := kindreconciler.NewImpl(ctx, c, func(impl *controller.Impl) controller.Options { // Setup options that require access to a controller.Impl. configsToResync := []interface{}{ &some.Config{}, } resyncOnConfigChange := configmap.TypeFilter(configsToResync...)(func(string, interface{}) { impl.FilteredGlobalResync(myFilterFunc, kindInformer.Informer()) }) configStore := config.NewStore(c.Logger.Named("config-store"), resyncOnConfigChange) configStore.WatchConfigs(cmw) // Return the controller options. return controller.Options{ ConfigStore: configStore, } }) ``` -------------------------------- ### Main Function for Webhook Setup Source: https://github.com/knative/serving/blob/main/vendor/knative.dev/pkg/webhook/README.md Sets up the webhook server with signal context and options, then calls `sharedmain.MainWithContext` to run the certificate controller and the resource admission controller. ```go func main() { // Set up a signal context with our webhook options. ctx := webhook.WithOptions(signals.NewContext(), webhook.Options{ // The name of the Kubernetes service selecting over this deployment's pods. ServiceName: "webhook", // The port on which to serve. Port: 8443, // The name of the secret containing certificate data. SecretName: "webhook-certs", }) sharedmain.MainWithContext(ctx, "webhook", // The certificate controller will ensure that the named secret (above) has // the appropriate shape for our webhook's admission controllers. certificates.NewController, // This invokes the method defined above to instantiate the resource admission // controller. NewResourceAdmissionController, ) } ``` -------------------------------- ### Sample release script implementation Source: https://github.com/knative/serving/blob/main/vendor/knative.dev/hack/README.md This sample demonstrates how to implement the `build_release` function and call the `main` function to perform a release. It includes building release artifacts and setting them for publication. ```bash source "$(go run knative.dev/hack/cmd/script release.sh)" function build_release() { # config/ contains the manifests ko resolve ${KO_FLAGS} -f config/ > release.yaml ARTIFACTS_TO_PUBLISH="release.yaml" } main "$@" ``` -------------------------------- ### URL Path Preparation Example Source: https://github.com/knative/serving/blob/main/vendor/github.com/Azure/go-autorest/README.md Illustrates how multiple WithPath decorators can be used with Prepare to construct a final URL. Decorators are applied in the order provided, concatenating path segments. ```go req, err := Prepare(&http.Request{}, WithBaseURL("https://microsoft.com/"), WithPath("a"), WithPath("b"), WithPath("c")) ``` -------------------------------- ### Example Using TagSet and TagOptions Source: https://github.com/knative/serving/blob/main/vendor/github.com/fxamacker/cbor/v2/README.md Demonstrates creating a TagSet, registering a custom tag, and using it with DecMode and EncMode for custom tag handling. ```go // Use signedCWT struct defined in "Decoding CWT" example. // Create TagSet (safe for concurrency). tags := cbor.NewTagSet() // Register tag COSE_Sign1 18 with signedCWT type. tags.Add( cbor.TagOptions{EncTag: cbor.EncTagRequired, DecTag: cbor.DecTagRequired}, reflect.TypeOf(signedCWT{}), 18) // Create DecMode with immutable tags. dm, _ := cbor.DecOptions{}.DecModeWithTags(tags) // Unmarshal to signedCWT with tag support. var v signedCWT if err := dm.Unmarshal(data, &v); err != nil { return err } // Create EncMode with immutable tags. em, _ := cbor.EncOptions{}.EncModeWithTags(tags) // Marshal signedCWT with tag number. if data, err := em.Marshal(v); err != nil { return err } ``` -------------------------------- ### View Makefile Help Source: https://github.com/knative/serving/blob/main/vendor/github.com/tsenart/go-tsz/README.md Run this command to see all available options for the Makefile, which helps in testing and building the project. ```bash make help ``` -------------------------------- ### Implement Configuration Initialization Source: https://github.com/knative/serving/blob/main/vendor/go.opentelemetry.io/otel/CONTRIBUTING.md Wraps default settings and applies options to create a configured struct. This function is typically unexported and may return an error if validation fails. ```go // newConfig returns an appropriately configured config. func newConfig(options ...Option) config { // Set default values for config. config := config{/* […] */} for _, option := range options { config = option.apply(config) } // Perform any validation here. return config } ``` -------------------------------- ### Starting Controllers with Shared Main Source: https://github.com/knative/serving/blob/main/vendor/knative.dev/pkg/injection/README.md Run controllers using the `sharedmain.Main` function. This function takes a component name and a list of controller constructors, setting up and running the specified controllers. ```go package main import ( // The set of controllers this process will run. "github.com/knative/foo/pkg/reconciler/bar" "github.com/knative/baz/pkg/reconciler/blah" // This defines the shared main for injected controllers. "knative.dev/pkg/injection/sharedmain" ) func main() { sharedmain.Main("componentname", bar.NewController, blah.NewController, ) } ``` -------------------------------- ### Install Latest JSON-Patch v5 Source: https://github.com/knative/serving/blob/main/vendor/gopkg.in/evanphx/json-patch.v4/README.md Use this command to get the latest version of the json-patch library. ```bash go get -u github.com/evanphx/json-patch/v5 ``` -------------------------------- ### Dog and Bird Constructors Source: https://github.com/knative/serving/blob/main/vendor/go.opentelemetry.io/otel/CONTRIBUTING.md Shows example constructors for `Dog` and `Bird` types, accepting specific options (`DogOption` or `BirdOption`) alongside other parameters. ```go func NewDog(name string, o ...DogOption) Dog {…} func NewBird(name string, o ...BirdOption) Bird {…} ``` -------------------------------- ### Quick Start: Translate OTLP Metrics and Labels Source: https://github.com/knative/serving/blob/main/vendor/github.com/prometheus/otlptranslator/README.md Demonstrates creating a metric namer with specific translation strategies and translating an OTLP metric name and a label. ```go package main import ( "fmt" "github.com/prometheus/otlptranslator" ) func main() { // Create a metric namer using traditional Prometheus name translation, with suffixes added and UTF-8 disallowed. strategy := otlptranslator.UnderscoreEscapingWithSuffixes namer := otlptranslator.NewMetricNamer("myapp", strategy) // Translate OTLP metric to Prometheus format metric := otlptranslator.Metric{ Name: "http.server.request.duration", Unit: "s", Type: otlptranslator.MetricTypeHistogram, } fmt.Println(namer.Build(metric)) // Output: myapp_http_server_request_duration_seconds // Translate label names labelNamer := otlptranslator.LabelNamer{UTF8Allowed: false} fmt.Println(labelNamer.Build("http.method")) // Output: http_method } ``` -------------------------------- ### Update Import Path and Install JWT v4 Source: https://github.com/knative/serving/blob/main/vendor/github.com/golang-jwt/jwt/v4/MIGRATION_GUIDE.md To migrate to v4.0.0, update your import path and install the new version using `go get`. Then, run `go mod tidy` to clean up your module dependencies. ```bash go get github.com/golang-jwt/jwt/v4 go mod tidy ``` -------------------------------- ### Get Command Line Arguments Source: https://github.com/knative/serving/blob/main/test/performance/PROFILING.md Fetch the command line arguments for the current program using curl. This provides insight into how the process was started. ```shell curl http://localhost:8008/debug/pprof/cmdline --output - ``` -------------------------------- ### Get/Set unsafe.Pointer with reflect2 Source: https://github.com/knative/serving/blob/main/vendor/github.com/modern-go/reflect2/README.md This example shows how to use `reflect2` to get and set values via `unsafe.Pointer`. Similar to interface{} operations, use the pointer to the type for setting values. ```go valType := reflect2.TypeOf(1) i := 1 j := 10 valType.UnsafeSet(unsafe.Pointer(&i), unsafe.Pointer(&j)) // i will be 10 ``` -------------------------------- ### Filter Controller Promotions with PromoteFilterFunc Source: https://github.com/knative/serving/blob/main/vendor/knative.dev/pkg/injection/README.md Pass a PromoteFilterFunc to the controller's constructor to filter which objects get reconciled when a controller is promoted. This example uses LabelFilterFunc to filter based on labels. ```go kindreconciler "knative.dev//pkg/client/injection/reconciler///" pkgreconciler "knative.dev/pkg/reconciler" ... impl := kindreconciler.NewImpl(ctx, c, func(impl *controller.Impl) controller.Options { return controller.Options{ PromoteFilterFunc: pkgreconciler.LabelFilterFunc("mylabel", "myvalue", false), } }) ``` -------------------------------- ### Define a RESTful Web Service Source: https://github.com/knative/serving/blob/main/vendor/github.com/emicklei/go-restful/v3/README.md Example of defining a WebService with path, consumes, produces, and a GET route for finding a user. The route specifies documentation, parameters, and the expected response type. ```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") ... } ``` -------------------------------- ### Vegeta Attack Command Examples Source: https://github.com/knative/serving/blob/main/vendor/github.com/tsenart/vegeta/v12/README.md Demonstrates how to run load tests using the 'attack' command and pipe results to other Vegeta commands or files. Shows common attack configurations. ```console echo "GET http://localhost/" | vegeta attack -duration=5s | tee results.bin | vegeta report ``` ```console cat results.bin | vegeta plot > plot.html ``` ```console cat results.bin | vegeta report -type="hist[0,100ms,200ms,300ms]" ``` -------------------------------- ### List Image Tags with Go Container Registry Source: https://github.com/knative/serving/blob/main/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/README.md This example demonstrates how to list tags for a specific image repository using the go-containerregistry library. It shows how to set up authentication, construct an authorized HTTP client, and handle potential errors during the request. ```go package main import ( "io" "net/http" "os" "github.com/google/go-containerregistry/pkg/authn" "github.com/google/go-containerregistry/pkg/name" "github.com/google/go-containerregistry/pkg/v1/remote/transport" ) func main() { repo, err := name.NewRepository("gcr.io/google-containers/pause") if err != nil { panic(err) } // Fetch credentials based on your docker config file, which is $HOME/.docker/config.json or $DOCKER_CONFIG. auth, err := authn.DefaultKeychain.Resolve(repo.Registry) if err != nil { panic(err) } // Construct an http.Client that is authorized to pull from gcr.io/google-containers/pause. scopes := []string{repo.Scope(transport.PullScope)} t, err := transport.New(repo.Registry, auth, http.DefaultTransport, scopes) if err != nil { panic(err) } client := &http.Client{Transport: t} // Make the actual request. resp, err := client.Get("https://gcr.io/v2/google-containers/pause/tags/list") if err != nil { panic(err) } // Assert that we get a 200, otherwise attempt to parse body as a structured error. if err := transport.CheckError(resp, http.StatusOK); err != nil { panic(err) } // Write the response to stdout. if _, err := io.Copy(os.Stdout, resp.Body); err != nil { panic(err) } } ``` -------------------------------- ### Install Vegeta with MacPorts Source: https://github.com/knative/serving/blob/main/vendor/github.com/tsenart/vegeta/v12/README.md Installs Vegeta on macOS using the MacPorts package manager. ```shell port install vegeta ``` -------------------------------- ### Install Vegeta with Homebrew Source: https://github.com/knative/serving/blob/main/vendor/github.com/tsenart/vegeta/v12/README.md Installs Vegeta on macOS using the Homebrew package manager. ```shell brew update && brew install vegeta ``` -------------------------------- ### Define Duck Type Example Source: https://github.com/knative/serving/blob/main/vendor/knative.dev/pkg/apis/duck/ABOUT.md Example of defining a duck type for a PodSpecable resource. ```yaml type PodSpecable corev1.PodTemplateSpec type WithPod struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` Spec WithPodSpec `json:"spec,omitempty"` } type WithPodSpec struct { Template PodSpecable `json:"template,omitempty"` } ``` -------------------------------- ### Logrus Text Output Example Source: https://github.com/knative/serving/blob/main/vendor/github.com/sirupsen/logrus/README.md Example of text output when caller reporting is enabled. ```text time="2015-03-26T01:27:38-04:00" level=fatal method=github.com/sirupsen/arcticcreatures.migrate msg="a penguin swims by" animal=penguin ``` -------------------------------- ### Configure InfluxDB Client with Options Source: https://github.com/knative/serving/blob/main/vendor/github.com/influxdata/influxdb-client-go/v2/README.md Shows how to create an InfluxDB client instance with custom options, such as enabling gzip compression and trusting all server certificates. ```go client := influxdb2.NewClientWithOptions("http://localhost:8086", "my-token", influxdb2.DefaultOptions(). SetUseGZip(true). SetTLSConfig(&tls.Config{ InsecureSkipVerify: true, })) ``` -------------------------------- ### Logrus JSON Output Example Source: https://github.com/knative/serving/blob/main/vendor/github.com/sirupsen/logrus/README.md Example of JSON output when caller reporting is enabled. ```json {"animal":"penguin","level":"fatal","method":"github.com/sirupsen/arcticcreatures.migrate","msg":"a penguin swims by", "time":"2014-03-10 19:57:38.562543129 -0400 EDT"} ``` -------------------------------- ### Example Usage of Custom Credential Helpers Source: https://github.com/knative/serving/blob/main/vendor/github.com/google/go-containerregistry/pkg/authn/README.md Demonstrates how to use custom credential helpers with 'crane' and 'docker' commands. The output shows the credential helper being invoked. ```bash $ crane manifest gcr.io/google-containers/pause > /dev/null {"ServerURL":"","Username":"_dcgcr_1_5_0_token","Secret":""} $ docker pull gcr.io/google-containers/pause Using default tag: latest {"ServerURL":"","Username":"_dcgcr_1_5_0_token","Secret":""} latest: Pulling from google-containers/pause a3ed95caeb02: Pull complete 4964c72cd024: Pull complete Digest: sha256:a78c2d6208eff9b672de43f880093100050983047b7b0afe0217d3656e1b0d5f Status: Downloaded newer image for gcr.io/google-containers/pause:latest gcr.io/google-containers/pause:latest ``` -------------------------------- ### Install Vegeta with Pacman Source: https://github.com/knative/serving/blob/main/vendor/github.com/tsenart/vegeta/v12/README.md Installs Vegeta on Arch Linux using the pacman package manager. ```shell pacman -S vegeta ``` -------------------------------- ### Get ByteSize in Bytes Source: https://github.com/knative/serving/blob/main/vendor/github.com/c2h5oh/datasize/README.md Use the Bytes() helper to get the total size in bytes as a uint64. ```go var size datasize.ByteSize = 1024 * datasize.KB bytes := size.Bytes() ``` -------------------------------- ### Sample performance test script Source: https://github.com/knative/serving/blob/main/vendor/knative.dev/hack/README.md This sample script demonstrates how to define `update_knative` and `update_benchmark` functions, and then call `main` to run the performance tests. Ensure necessary configurations are applied using `ko apply`. ```bash source "$(go run knative.dev/hack/cmd/script performance-tests.sh)" function update_knative() { echo ">> Updating serving" ko apply -f config/ || abort "failed to apply serving" } function update_benchmark() { echo ">> Updating benchmark $1" ko apply -f ${BENCHMARK_ROOT_PATH}/$1 || abort "failed to apply benchmark $1" } main $@ ``` -------------------------------- ### Install oapi Generator Source: https://github.com/knative/serving/blob/main/vendor/github.com/influxdata/influxdb-client-go/v2/domain/Readme.md Clone the oapi-codegen repository, checkout the required branch, and install the generator binary. ```bash git clone git@github.com:bonitoo-io/oapi-codegen.git cd oapi-codegen git checkout feat/template_helpers go install ./cmd/oapi-codegen/oapi-codegen.go ``` -------------------------------- ### Sample End-to-End Test Script Source: https://github.com/knative/serving/blob/main/vendor/knative.dev/hack/README.md An example script demonstrating how to use the `e2e-tests.sh` helper for testing Knative Serving. It includes custom flag parsing and cluster initialization. ```bash source "$(go run knative.dev/hack/cmd/script e2e-tests.sh)" function knative_setup() { start_latest_knative_serving if (( WAIT_FOR_KNATIVE )); then wait_until_pods_running knative-serving || fail_test "Knative Serving not up" fi } function parse_flags() { if [[ "$1" == "--no-knative-wait" ]]; then WAIT_FOR_KNATIVE=0 return 1 fi return 0 } WAIT_FOR_KNATIVE=1 # This test requires a cluster in LA initialize $@ --region=us-west2 # TODO: use go_test_e2e to run the tests. kubectl get pods || fail_test success ``` -------------------------------- ### Create and Use Tags for Profiling in Go Source: https://github.com/knative/serving/blob/main/vendor/go.opencensus.io/README.md Demonstrates how to create a context with custom tags (e.g., OS, User ID) and use `tag.Do` to associate these tags with work being done. When profiling is enabled, these tags act as labels for collected samples. ```go ctx, err = tag.New(ctx, tag.Insert(osKey, "macOS-10.12.5"), tag.Insert(userIDKey, "fff0989878"), ) if err != nil { log.Fatal(err) } tag.Do(ctx, func(ctx context.Context) { // Do work. // When profiling is on, samples will be // recorded with the key/values from the tag map. }) ``` -------------------------------- ### Install InfluxDB Client Go (GOPATH) Source: https://github.com/knative/serving/blob/main/vendor/github.com/influxdata/influxdb-client-go/v2/README.md Install the client package for GOPATH projects. Ensure GO111MODULE is set to 'off'. ```sh go get github.com/influxdata/influxdb-client-go ```