### Install gziphandler Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/NYTimes/gziphandler/README.md Use `go get` to install the package. ```bash go get -u github.com/NYTimes/gziphandler ``` -------------------------------- ### Install pgzip Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/klauspost/pgzip/README.md Use 'go get' to install the pgzip library and its dependencies. ```go go get github.com/klauspost/pgzip/... go get -u github.com/klauspost/compress ``` -------------------------------- ### Install go-gitignore Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/monochromegane/go-gitignore/README.md Install the go-gitignore library using the go get command. This command fetches and installs the package and its dependencies. ```sh go get github.com/monochromegane/go-gitignore ``` -------------------------------- ### Install etcd/client/v3 Source: https://github.com/loft-sh/vcluster/blob/main/vendor/go.etcd.io/etcd/client/v3/README.md Install the official Go etcd client using go get. ```bash go get go.etcd.io/etcd/client/v3 ``` -------------------------------- ### Install ULID Go Library Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/oklog/ulid/README.md Use 'go get' to install the ULID library. ```shell go get github.com/oklog/ulid ``` -------------------------------- ### Install Golang Color Library Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/fatih/color/README.md Use go get to install the color library. ```bash go get github.com/fatih/color ``` -------------------------------- ### Install go-isatty Package Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/mattn/go-isatty/README.md Install the go-isatty package using the go get command. ```bash go get github.com/mattn/go-isatty ``` -------------------------------- ### Install go.yaml.in/yaml/v3 Source: https://github.com/loft-sh/vcluster/blob/main/vendor/go.yaml.in/yaml/v3/README.md Use 'go get' to install the package. The import path is go.yaml.in/yaml/v3. ```bash go get go.yaml.in/yaml/v3 ``` -------------------------------- ### Install Cobra Library Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/spf13/cobra/README.md Use 'go get' to install the latest version of the Cobra library. ```go go get -u github.com/spf13/cobra@latest ``` -------------------------------- ### Full Example of a Mux-based Server Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/gorilla/mux/README.md Provides a complete, runnable Go program demonstrating a basic server setup using Gorilla Mux, including route definition and HTTP listening. ```go package main import ( "net/http" "log" "github.com/gorilla/mux" ) func YourHandler(w http.ResponseWriter, r *http.Request) { w.Write([]byte("Gorilla!\n")) } func main() { r := mux.NewRouter() // Routes consist of a path and a handler function. r.HandleFunc("/", YourHandler) // Bind to a port and pass our router in log.Fatal(http.ListenAndServe(":8000", r)) } ``` -------------------------------- ### Install Diskv using Go Get Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/peterbourgon/diskv/README.md Installs the diskv library using the Go package manager. ```bash go get github.com/peterbourgon/diskv ``` -------------------------------- ### Install Blackfriday v2 Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/russross/blackfriday/v2/README.md Use `go get` to install the package in module mode. It will be added to your development module and built. ```go go get github.com/russross/blackfriday/v2 ``` -------------------------------- ### Install blackfriday-tool Source: https://github.com/loft-sh/vcluster/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 way to process markdown files. ```go go get github.com/russross/blackfriday-tool ``` -------------------------------- ### Install json-iterator/go Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/json-iterator/go/README.md Use the go get command to install the json-iterator/go library. ```bash go get github.com/json-iterator/go ``` -------------------------------- ### Install uuid Package Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/google/uuid/README.md Use 'go get' to install the uuid package. This command fetches and installs the package and its dependencies. ```shell go get github.com/google/uuid ``` -------------------------------- ### Install lo Library Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/samber/lo/README.md Install the lo library using go get. This library is v1 and follows SemVer strictly. ```sh go get github.com/samber/lo@v1 ``` -------------------------------- ### Install ansi Go Library Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/mgutz/ansi/README.md Use 'go get' to install the ansi library. This command fetches and installs the specified package. ```sh go get -u github.com/mgutz/ansi ``` -------------------------------- ### Install gexe Package Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/vladimirvivien/gexe/README.md Use `go get` to install the gexe package for use in your Go projects. ```bash go get github.com/vladimirvivien/gexe ``` -------------------------------- ### Install mapstructure Go Library Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/mitchellh/mapstructure/README.md Use standard 'go get' command to install the mapstructure library. ```bash $ go get github.com/mitchellh/mapstructure ``` -------------------------------- ### Install Heredoc Package Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/MakeNowJust/heredoc/README.md Use 'go get' to install the heredoc package. This command fetches and installs the package into your Go workspace. ```console go get github.com/MakeNowJust/heredoc ``` -------------------------------- ### Install jsonpath Package Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/exponent-io/jsonpath/README.md Use go get to install the jsonpath package. This command fetches and installs the package and its dependencies. ```bash go get -u github.com/exponent-io/jsonpath ``` -------------------------------- ### Define a RESTful WebService Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/emicklei/go-restful/v3/README.md Example demonstrating how to define a WebService, set its path, supported content types, and define a GET route for retrieving a user. ```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") ... } ``` -------------------------------- ### Install uniseg Package Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/rivo/uniseg/README.md Use 'go get' to install the uniseg package for your Go project. ```bash go get github.com/rivo/uniseg ``` -------------------------------- ### Install blang/semver Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/blang/semver/README.md Install the semver library using go get. It's recommended to vendor dependencies or use specific version tags. ```bash go get github.com/blang/semver ``` -------------------------------- ### Install and Run Local Go Doc Site Source: https://github.com/loft-sh/vcluster/blob/main/vendor/go.opentelemetry.io/otel/CONTRIBUTING.md Installs and runs a local Go Doc site using pkgsite. Ensure you have the latest version installed. ```sh go install golang.org/x/pkgsite/cmd/pkgsite@latest pkgsite ``` -------------------------------- ### Install etcd/client Go Library Source: https://github.com/loft-sh/vcluster/blob/main/vendor/go.etcd.io/etcd/server/v3/internal/clientv2/README.md Install the etcd client library using go modules. ```bash go get go.etcd.io/etcd/v3/client ``` -------------------------------- ### Install Azure Storage Module Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage/README.md Install the Azure Storage module using go get. This command fetches and installs the specified package and its dependencies. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage ``` -------------------------------- ### Install go-colorable Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/mattn/go-colorable/README.md Install the go-colorable package using the go get command. This is the standard method for adding external Go packages to your project. ```bash go get github.com/mattn/go-colorable ``` -------------------------------- ### Install Ginkgo Locally Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/onsi/ginkgo/v2/CONTRIBUTING.md Installs the Ginkgo CLI locally. Ensure you have Go installed and configured. ```bash go install ./... ``` -------------------------------- ### vCluster with PreSetup Hook Source: https://github.com/loft-sh/vcluster/blob/main/e2e-next/README.md This Go snippet shows how to initialize a vCluster with a pre-setup hook. The hook allows for executing host-side prerequisites like installing CRDs or creating PVCs before the vCluster starts. ```go BeforeAll(func(ctx context.Context) context.Context { return lazyvcluster.LazyVCluster(ctx, myFeatureVClusterName, myFeatureVClusterYAML, lazyvcluster.WithPreSetup(func(ctx context.Context) error { // install CRDs, create PVC, etc. return nil }), ) }) ``` -------------------------------- ### Install Gorilla Mux Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/gorilla/mux/README.md Use go get to install the latest version of the gorilla/mux package. Ensure your Go toolchain is correctly configured. ```sh go get -u github.com/gorilla/mux ``` -------------------------------- ### Install go-ordered-map/v2 Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/wk8/go-ordered-map/v2/README.md Use this command to install the library. Ensure you are using Go version 1.18 or higher. ```bash go get -u github.com/wk8/go-ordered-map/v2 ``` -------------------------------- ### Install Cron V3 Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/robfig/cron/v3/README.md Use go get to download the specific tagged release of Cron V3. Import it in your program using the provided path. ```go go get github.com/robfig/cron/v3@v3.0.0 ``` ```go import "github.com/robfig/cron/v3" ``` -------------------------------- ### Initialize Procfs and Get Stat Information Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/prometheus/procfs/README.md Initializes the proc filesystem and retrieves CPU statistics. Use this to start gathering data from /proc. ```go fs, err := procfs.NewFS("/proc") stats, err := fs.Stat() ``` -------------------------------- ### Install MachineID Library Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/denisbrodbeck/machineid/README.md Get the machineid library for your Go project. ```bash go get github.com/denisbrodbeck/machineid ``` -------------------------------- ### Install Sonobuoy CLI Source: https://github.com/loft-sh/vcluster/blob/main/conformance/v1.30/README.md Installs the Sonobuoy CLI tool using 'go install'. Ensure Go is installed and configured in your PATH. ```bash go install github.com/vmware-tanzu/sonobuoy@latest ``` -------------------------------- ### Start Minikube Cluster Source: https://github.com/loft-sh/vcluster/blob/main/conformance/v1.26/README.md Starts a local minikube cluster with 2 nodes and Kubernetes version 1.26.1. Ensure you have the kvm2 driver installed if using this setup. ```bash minikube start --kubernetes-version 1.26.1 --nodes=2 ``` -------------------------------- ### Build and Run PKCS#11 Example Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/stefanberger/go-pkcs11uri/README.md These commands demonstrate building the Go example program and then running it with a PKCS#11 URI that specifies the slot ID, module path, and PIN for SoftHSM2. ```bash $ go build ./... $ sudo ./pkcs11-example 'pkcs11:slot-id=2053753261?module-path=/usr/lib64/pkcs11/libsofthsm2.so&pin-value=1234' 517592df8fec3ad146a79a9af153db2a4d784ec5 ``` -------------------------------- ### Install MachineID CLI Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/denisbrodbeck/machineid/README.md Install the command-line interface tool for machineid to your Go bin directory. ```bash go get github.com/denisbrodbeck/machineid/cmd/machineid ``` -------------------------------- ### Install helm-unittest Plugin Source: https://github.com/loft-sh/vcluster/blob/main/chart/tests/README.md Install the helm-unittest plugin to enable chart testing. This command should be run once to set up the testing environment. ```bash helm plugin install https://github.com/helm-unittest/helm-unittest.git ``` -------------------------------- ### Yamux Server Setup and Stream Handling Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/hashicorp/yamux/README.md Illustrates how to set up a Yamux server session to accept incoming TCP connections and handle new streams. It shows how to accept a stream and read data from it. ```go func server() { // Accept a TCP connection conn, err := listener.Accept() if err != nil { panic(err) } // Setup server side of yamux session, err := yamux.Server(conn, nil) if err != nil { panic(err) } // Accept a stream stream, err := session.Accept() if err != nil { panic(err) } // Listen for a message buf := make([]byte, 4) stream.Read(buf) } ``` -------------------------------- ### Install go.uber.org/atomic Source: https://github.com/loft-sh/vcluster/blob/main/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 ``` -------------------------------- ### Initialize GitIgnore Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/monochromegane/go-gitignore/README.md Initialize a new GitIgnore instance with a specified gitignore file path. This is the basic setup for using the library. ```go gitignore, _ := gitignore.NewGitIgnore("/path/to/gitignore") path := "/path/to/file" isDir := false gitignore.Match(path, isDir) ``` -------------------------------- ### Install SQLite Go Package Source: https://github.com/loft-sh/vcluster/blob/main/vendor/modernc.org/sqlite/README.md Use 'go get' to install the modernc.org/sqlite package. This command fetches and installs the package and its dependencies. ```bash $ go get modernc.org/sqlite ``` -------------------------------- ### Install treeprint Package Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/xlab/treeprint/README.md Use 'go get' to install the treeprint package. This command fetches and installs the package into your Go workspace. ```bash $ go get github.com/xlab/treeprint ``` -------------------------------- ### Install stripansi Go Package Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/acarl005/stripansi/README.md Use 'go get' to install the stripansi package. This command fetches and installs the latest version. ```sh $ go get -u github.com/acarl005/stripansi ``` -------------------------------- ### Example using TagSet and TagOptions Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/fxamacker/cbor/v2/README.md Shows how to create a TagSet, register custom tags with specific options, and then use these tags to create decoding and encoding modes for handling tagged CBOR data. ```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 } ``` -------------------------------- ### Install CamelCase Package Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/fatih/camelcase/README.md Install the CamelCase Go package using the go get command. ```bash go get github.com/fatih/camelcase ``` -------------------------------- ### Install govalidator Package Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/asaskevich/govalidator/README.md Install the govalidator package using the go get command. You can install the latest release or a specific version using gopkg.in. ```bash go get github.com/asaskevich/govalidator ``` ```bash go get gopkg.in/asaskevich/govalidator.v10 ``` -------------------------------- ### Create New Configuration Instance Source: https://github.com/loft-sh/vcluster/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. Validation can be added, returning an error if necessary. ```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 } ``` -------------------------------- ### Basic etcd Client Usage Source: https://github.com/loft-sh/vcluster/blob/main/vendor/go.etcd.io/etcd/server/v3/internal/clientv2/README.md Demonstrates how to create an etcd client, set a key-value pair, and retrieve it. Ensure etcd is running on http://127.0.0.1:2379. ```go package main import ( "context" "log" "time" "go.etcd.io/etcd/v3/client" ) func main() { cfg := client.Config{ Endpoints: []string{"http://127.0.0.1:2379"}, Transport: client.DefaultTransport, // set timeout per request to fail fast when the target endpoint is unavailable HeaderTimeoutPerRequest: time.Second, } c, err := client.New(cfg) if err != nil { log.Fatal(err) } kapi := client.NewKeysAPI(c) // set "/foo" key with "bar" value log.Print("Setting '/foo' key with 'bar' value") resp, err := kapi.Set(context.Background(), "/foo", "bar", nil) if err != nil { log.Fatal(err) } else { // print common key info log.Printf("Set is done. Metadata is \"%q\"\n", resp) } // get "/foo" key's value log.Print("Getting '/foo' key value") resp, err = kapi.Get(context.Background(), "/foo", nil) if err != nil { log.Fatal(err) } else { // print common key info log.Printf("Get is done. Metadata is \"%q\"\n", resp) // print value log.Printf("%q key has %q value\n", resp.Node.Key, resp.Node.Value) } } ``` -------------------------------- ### New Function with Options Source: https://github.com/loft-sh/vcluster/blob/main/vendor/go.opentelemetry.io/otel/CONTRIBUTING.md Demonstrates the signature for a constructor function that accepts a variadic list of `Option` types for configuration. ```go func NewT(options ...Option) T {…} ``` -------------------------------- ### Install and Import ghodss/yaml Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/ghodss/yaml/README.md Instructions for installing the library using go get and importing it into your Go projects. ```bash $ go get github.com/ghodss/yaml ``` ```go import "github.com/ghodss/yaml" ``` -------------------------------- ### Install Latest JSON-Patch (v5) Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/evanphx/json-patch/README.md Installs the latest version of the json-patch library using go get. ```bash go get -u github.com/evanphx/json-patch/v5 ``` -------------------------------- ### Install go-gitconfig Package Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/tcnksm/go-gitconfig/README.md Installs the go-gitconfig package using 'go get'. This command downloads the package source code without necessarily building or installing it. ```bash $ go get -d github.com/tcnksm/go-gitconfig ``` -------------------------------- ### Install bbolt Source: https://github.com/loft-sh/vcluster/blob/main/vendor/go.etcd.io/bbolt/README.md Install the bbolt library using go get. This command updates your go.mod and go.sum files. ```sh $ go get go.etcd.io/bbolt@latest ``` -------------------------------- ### Acquire Token with azidentity Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/Azure/azure-sdk-for-go/sdk/azidentity/MIGRATION.md This example shows how to manually acquire a token using an azidentity credential. This is typically done when integrating with non-SDK clients or for specific token needs. ```go import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" ) cred, err := azidentity.NewClientSecretCredential(tenantID, clientID, secret, nil) handle(err) tk, err := cred.GetToken( context.TODO(), policy.TokenRequestOptions{Scopes: []string{"https://vault.azure.net/.default"}}, ) if err == nil { token := tk.Token } ``` -------------------------------- ### Initialize PKCS#11 Module Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/miekg/pkcs11/README.md Instantiates a new PKCS#11 module and initializes it. Ensure the library path is correct for your system. ```go p := pkcs11.New("/usr/lib/softhsm/libsofthsm2.so") err := p.Initialize() if err != nil { panic(err) } defer p.Destroy() deffer p.Finalize() ``` -------------------------------- ### Sign and Detach PKCS7 Data in Go Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/smallstep/pkcs7/README.md Demonstrates how to sign content using a certificate and private key, detach the signature, and then verify it. Ensure you have the necessary certificate and private key to run this example. ```go package main import ( "bytes" "crypto/rsa" "crypto/x509" "encoding/pem" "fmt" "os" "github.com/smallstep/pkcs7" ) func SignAndDetach(content []byte, cert *x509.Certificate, privkey *rsa.PrivateKey) (signed []byte, err error) { toBeSigned, err := NewSignedData(content) if err != nil { return fmt.Errorf("Cannot initialize signed data: %w", err) } if err = toBeSigned.AddSigner(cert, privkey, SignerInfoConfig{}); err != nil { return fmt.Errorf("Cannot add signer: %w", err) } // Detach signature, omit if you want an embedded signature ttoBeSigned.Detach() signed, err = toBeSigned.Finish() if err != nil { return fmt.Errorf("Cannot finish signing data: %w", err) } // Verify the signature pem.Encode(os.Stdout, &pem.Block{Type: "PKCS7", Bytes: signed}) p7, err := pkcs7.Parse(signed) if err != nil { return fmt.Errorf("Cannot parse our signed data: %w", err) } // since the signature was detached, reattach the content here p7.Content = content if bytes.Compare(content, p7.Content) != 0 { return fmt.Errorf("Our content was not in the parsed data:\n\tExpected: %s\n\tActual: %s", content, p7.Content) } if err = p7.Verify(); err != nil { return fmt.Errorf("Cannot verify our signed data: %w", err) } return signed, nil } ``` -------------------------------- ### Basic Structured Logging vs. Standard Library Logging Source: https://github.com/loft-sh/vcluster/blob/main/vendor/sigs.k8s.io/controller-runtime/TMP-LOGGING.md Illustrates the difference between traditional Go standard library logging and controller-runtime's structured logging approach using key-value pairs. ```go log.Printf("starting reconciliation for pod %s/%s", podNamespace, podName) ``` ```go logger.Info("starting reconciliation", "pod", req.NamespacedName) ``` -------------------------------- ### Using FileSystem Interface for BindLocale Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/chai2010/gettext-go/README.md Demonstrates how to use the `FileSystem` interface with `BindLocale` to bind locales from a directory or a zip file. ```Go // Use FileSystem: // BindLocale(New("poedit", "name", OS("path/to/dir"))) // bind "poedit" domain // BindLocale(New("poedit", "name", OS("path/to.zip"))) // bind "poedit" domain ``` -------------------------------- ### Start Minikube Cluster Source: https://github.com/loft-sh/vcluster/blob/main/conformance/v1.30/README.md Starts a local minikube cluster with Kubernetes version 1.30.2 and 2 nodes. Ensure you have minikube installed and configured. ```bash minikube start --kubernetes-version 1.30.2 --nodes=2 ``` -------------------------------- ### Setup E2E Environment Only Source: https://github.com/loft-sh/vcluster/blob/main/e2e-next/README.md Prepares the testing environment without running any tests. This is useful if you only need to set up prerequisites or infrastructure. ```bash just setup ``` -------------------------------- ### Basic Translation Example Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/chai2010/gettext-go/README.md Demonstrates basic translation using a specific domain and language. Ensure the locale directory and PO file are correctly set up. ```Go package main import ( "fmt" "github.com/chai2010/gettext-go" ) func main() { gettext := gettext.New("hello", "./examples/locale").SetLanguage("zh_CN") fmt.Println(gettext.Gettext("Hello, world!")) // Output: 你好, 世界! } ``` -------------------------------- ### Basic Table Generation Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/olekukonko/tablewriter/README.md Demonstrates basic table creation with headers and row appending. The table is rendered to standard output. ```go data := [][]string{ []string{"A", "The Good", "500"}, []string{"B", "The Very very Bad Man", "288"}, []string{"C", "The Ugly", "120"}, []string{"D", "The Gopher", "800"}, } table := tablewriter.NewWriter(os.Stdout) table.SetHeader([]string{"Name", "Sign", "Rating"}) for _, v := range data { table.Append(v) } table.Render() // Send output ``` -------------------------------- ### Start Minikube Cluster Source: https://github.com/loft-sh/vcluster/blob/main/conformance/v1.27/README.md Starts a local Kubernetes cluster with 2 nodes using the specified Kubernetes version. Ensure you have the kvm2 driver installed if using minikube. ```bash minikube start --kubernetes-version 1.27.2 --nodes=2 ``` -------------------------------- ### Start Minikube Cluster Source: https://github.com/loft-sh/vcluster/blob/main/conformance/v1.32/README.md Starts a local minikube cluster with Kubernetes version 1.32.1 and 2 nodes. Ensure you have minikube installed and configured with a compatible driver (e.g., docker). ```bash minikube start --kubernetes-version 1.32.1 --nodes=2 ``` -------------------------------- ### Invoke Docker Credential Helper Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/google/go-containerregistry/pkg/authn/README.md Example of invoking a Docker credential helper ('docker-credential-gcr') to get credentials for a registry. ```bash $ echo "gcr.io" | docker-credential-gcr get {"Username":"_token","Secret":""} ``` -------------------------------- ### Basic Input Prompt Source: https://github.com/loft-sh/vcluster/blob/main/vendor/github.com/AlecAivazis/survey/v2/README.md A simple example of using the Input prompt to get a single string value from the user. ```go name := "" prompt := &survey.Input{ Message: "ping", } survey.AskOne(prompt, &name) ``` -------------------------------- ### Setup Zap Repository Source: https://github.com/loft-sh/vcluster/blob/main/vendor/go.uber.org/zap/CONTRIBUTING.md Clone the zap repository and set up 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 JSON-Patch Version 4 Source: https://github.com/loft-sh/vcluster/blob/main/vendor/gopkg.in/evanphx/json-patch.v4/README.md If you require version 4 of the json-patch library, use this specific go get command. ```bash go get -u gopkg.in/evanphx/json-patch.v4 ```