### Install color package Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/cppforlife/color/README.md Use 'go get' to install the color package. ```bash go get github.com/fatih/color ``` -------------------------------- ### Install go-autorest/autorest/adal Source: https://github.com/carvel-dev/imgpkg/blob/develop/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 go-colorable Source: https://github.com/carvel-dev/imgpkg/blob/develop/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 and Import sigs.k8s.io/yaml Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/sigs.k8s.io/yaml/README.md Instructions for installing the library using go get and importing it into your Go project. ```bash go get sigs.k8s.io/yaml ``` ```go import "sigs.k8s.io/yaml" ``` -------------------------------- ### Install go-isatty Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/mattn/go-isatty/README.md Use this command to install the go-isatty package. ```bash go get github.com/mattn/go-isatty ``` -------------------------------- ### Install uniseg Package Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/rivo/uniseg/README.md Use 'go get' to install the uniseg package. This command fetches and installs the specified package and any dependencies. ```bash go get github.com/rivo/uniseg ``` -------------------------------- ### Install utfbom Package Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/dimchansky/utfbom/README.md Use the go get command to install the latest version of the utfbom package. ```go go get -u github.com/dimchansky/utfbom ``` -------------------------------- ### Install Cobra Library Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/spf13/cobra/README.md Install the latest version of the Cobra library using go get. ```bash go get -u github.com/spf13/cobra@latest ``` -------------------------------- ### Start godoc Server Source: https://github.com/carvel-dev/imgpkg/blob/develop/README.md Starts a local HTTP server for viewing Go package documentation. Visit http://localhost:6060/pkg/carvel.dev/imgpkg/ to access imgpkg documentation. ```bash godoc -http=:6060 ``` -------------------------------- ### Install go-autorest Packages Source: https://github.com/carvel-dev/imgpkg/blob/develop/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 ``` -------------------------------- ### Credential Helper Configuration Example Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/google/go-containerregistry/pkg/authn/README.md Modify your Docker configuration file to use custom credential helpers. This example maps 'gcr.io' to the 'tee' helper and 'eu.gcr.io' to the 'hardcoded' helper. ```json { "credHelpers": { "gcr.io": "tee", "eu.gcr.io": "hardcoded" } } ``` -------------------------------- ### Install godoc Tool Source: https://github.com/carvel-dev/imgpkg/blob/develop/README.md Installs the godoc command-line tool, which is used for viewing Go package documentation. ```bash go install golang.org/x/tools/cmd/godoc@latest ``` -------------------------------- ### Decorator Order Example Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/Azure/go-autorest/README.md Illustrates how decorators are applied sequentially in the Prepare phase. Multiple WithPath decorators are used to construct a URL, showing that decorators execute in the order they are provided. ```go req, err := Prepare(&http.Request{}, \ WithBaseURL("https://microsoft.com/"), \ WithPath("a"), \ WithPath("b"), \ WithPath("c")) ``` -------------------------------- ### Basic Logrus Usage Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/sirupsen/logrus/README.md Demonstrates the simplest way to use Logrus with the package-level exported logger. No special setup is required. ```go package main import "github.com/sirupsen/logrus" func main() { logrus.WithFields(logrus.Fields{ "animal": "walrus", }).Info("A walrus appears") } ``` -------------------------------- ### Install Cobra CLI Generator Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/spf13/cobra/README.md Install the cobra-cli tool, which generates Cobra application and command files, by running the go install command. ```bash go install github.com/spf13/cobra-cli@latest ``` -------------------------------- ### Install Counterfeiter to `$GOPATH/bin` Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/maxbrunsfeld/counterfeiter/v6/README.md Install counterfeiter globally to your `$GOPATH/bin` directory using `go install`. This allows you to invoke the `counterfeiter` command directly from your shell, even outside of a Go module. ```shell go install github.com/maxbrunsfeld/counterfeiter/v6 $ ~/go/bin/counterfeiter USAGE counterfeiter [-generate>] [-o ] [-p] [--fake-name ] [-header ] [] [-] ``` -------------------------------- ### List Tags for a Repository using Remote Transport Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/README.md This example demonstrates how to list tags for a specific repository (e.g., gcr.io/google-containers/pause) by directly interacting with the registry API. It shows how to set up authentication, construct an authorized HTTP client, make the request, and handle potential errors using `transport.CheckError`. ```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) } } ``` -------------------------------- ### HTTP Request Pipeline Example Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/Azure/go-autorest/README.md Demonstrates the typical pattern for preparing, sending, and responding to HTTP requests using go-autorest decorators. This pattern allows for customization of request preparation, response handling, and error management. ```go req, err := Prepare(&http.Request{}, \ token.WithAuthorization()) resp, err := Send(req, \ WithLogging(logger), \ DoErrorIfStatusCode(http.StatusInternalServerError), \ DoCloseIfError(), \ DoRetryForAttempts(5, time.Second)) err = Respond(resp, \ ByDiscardingBody(), \ ByClosing()) ``` -------------------------------- ### EWMA Usage Example Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/VividCortex/ewma/README.md Demonstrates how to create and use both SimpleEWMA and VariableEWMA. SimpleEWMA is created with no arguments, while VariableEWMA requires a sample size argument. Both are updated with sample data and their final values are retrieved. ```go package main import "github.com/VividCortex/ewma" func main() { samples := [100]float64{ 4599, 5711, 4746, 4621, 5037, 4218, 4925, 4281, 5207, 5203, 5594, 5149, } e := ewma.NewMovingAverage() //=> Returns a SimpleEWMA if called without params a := ewma.NewMovingAverage(5) //=> returns a VariableEWMA with a decay of 2 / (5 + 1) for _, f := range samples { e.Add(f) a.Add(f) } e.Value() //=> 13.577404704631077 a.Value() //=> 1.5806140565521463e-12 } ``` -------------------------------- ### Configure `go-codegen` Plugin Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/aws/smithy-go/README.md Example `smithy-build.json` configuration for the `go-codegen` plugin. This specifies the service, module, and Go directive for code generation. ```json { "version": "1.0", "sources": [ "models" ], "maven": { "dependencies": [ "software.amazon.smithy.go:smithy-go-codegen:0.1.0" ] }, "plugins": { "go-codegen": { "service": "example.weather#Weather", "module": "github.com/example/weather", "generateGoMod": true, "goDirective": "1.23" } } } ``` -------------------------------- ### Customizing Logrus Configuration Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/sirupsen/logrus/README.md Shows how to configure Logrus for JSON formatting, output to stdout, and setting the logging level. This example replaces the standard library logger. ```go package main import ( "os" log "github.com/sirupsen/logrus" ) func init() { // Log as JSON instead of the default ASCII formatter. log.SetFormatter(&log.JSONFormatter{}) // Output to stdout instead of the default stderr // Can be any io.Writer, see below for File example log.SetOutput(os.Stdout) // Only log the warning severity or above. log.SetLevel(log.WarnLevel) } func main() { log.WithFields(log.Fields{ "animal": "walrus", "size": 10, }).Info("A group of walrus emerges from the ocean") log.WithFields(log.Fields{ "omg": true, "number": 122, }).Warn("The group's number increased tremendously!") log.WithFields(log.Fields{ "omg": true, "number": 100, }).Fatal("The ice breaks!") // A common pattern is to re-use fields between logging statements by re-using // the logrus.Entry returned from WithFields() contextLogger := log.WithFields(log.Fields{ "common": "this is a common field", "other": "I also should be logged always", }) contextLogger.Info("I'll be logged with common and other field") contextLogger.Info("Me too") } ``` -------------------------------- ### Stateless gzip Writer with bufio.Writer Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/klauspost/compress/README.md Example of using stateless gzip compression with a controlled buffer size. Replace 'ioutil.Discard' with your actual output destination. This configuration limits memory usage when the writer is idle. ```go // replace 'ioutil.Discard' with your output. gzw, err := gzip.NewWriterLevel(ioutil.Discard, gzip.StatelessCompression) if err != nil { return err } defer gzw.Close() w := bufio.NewWriterSize(gzw, 4096) defer w.Flush() // Write to 'w' ``` -------------------------------- ### Initialize OAuth Configuration Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/Azure/go-autorest/autorest/adal/README.md Initialize the OAuth configuration with the Azure AD endpoint and tenant ID. This is a common setup for all authentication flows. ```go const activeDirectoryEndpoint = "https://login.microsoftonline.com/" tenantID := "TENANT_ID" oauthConfig, err := adal.NewOAuthConfig(activeDirectoryEndpoint, tenantID) applicationID := "APPLICATION_ID" callback := func(token adal.Token) error { // This is called after the token is acquired } // The resource for which the token is acquired resource := "https://management.core.windows.net/" ``` -------------------------------- ### Registering Zstd Compressor/Decompressor for ZIP Files Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/klauspost/compress/zstd/README.md Example demonstrating how to register Zstd compressors and decompressors for individual zip.Reader or zip.Writer instances. This approach avoids global registration conflicts and allows for resource reuse. ```go import ( "archive/zip" "io" "github.com/klauspost/compress/zstd" ) func ExampleZipCompressor() { // Create a new zip file // ... create zip writer ... // Register Zstd compressor and decompressor compressor, err := zstd.NewWriter(nil) if err != nil { panic(err) } decompressor, err := zstd.NewReader(nil) if err != nil { panic(err) } // Use the compressor and decompressor for individual files // ... add file to zip using compressor ... // ... read file from zip using decompressor ... // Close the compressor and decompressor when done compressor.Close() decompressor.Close() // ... close zip writer ... } ``` -------------------------------- ### Build All Files (Old System) Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/golang.org/x/sys/unix/README.md Use this script to generate Go files for your current OS and architecture using the old build system. Ensure GOOS and GOARCH are set correctly. Running with `-n` shows the commands that will be executed. ```bash mkall.sh ``` ```bash mkall.sh -n ``` -------------------------------- ### Text Formatter Output (No TTY) Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/sirupsen/logrus/README.md Example output using the default TextFormatter when a TTY is not attached, compatible with the logfmt format. ```text time="2015-03-26T01:27:38-04:00" level=debug msg="Started observing beach" animal=walrus number=8 time="2015-03-26T01:27:38-04:00" level=info msg="A group of walrus emerges from the ocean" animal=walrus size=10 time="2015-03-26T01:27:38-04:00" level=warning msg="The group's number increased tremendously!" number=122 omg=true time="2015-03-26T01:27:38-04:00" level=debug msg="Temperature changes" temperature=-4 time="2015-03-26T01:27:38-04:00" level=panic msg="It's over 9000!" animal=orca size=9009 time="2015-03-26T01:27:38-04:00" level=fatal msg="The ice breaks!" err=&{0x2082280c0 map[animal:orca size:9009] 2015-03-26 01:27:38.441574009 -0400 EDT panic It's over 9000!} number=100 omg=true ``` -------------------------------- ### Push, Copy, Pull, and List imgpkg Bundles Source: https://github.com/carvel-dev/imgpkg/blob/develop/README.md Demonstrates basic imgpkg commands for managing bundles. Use 'push' to store files as an OCI image, 'copy' to move bundles between registries, 'pull' to extract files, and 'tag ls' to list image tags. ```bash imgpkg push -b your-user/app1-config:0.1.1 -f config/ ``` ```bash imgpkg copy -b your-user/app1-config:0.1.1 --to-repo other-user/app1 ``` ```bash imgpkg pull -b your-user/app1-config:0.1.1 -o /tmp/app1-config ``` ```bash imgpkg tag ls -i your-user/app1-config ``` -------------------------------- ### Creating a Logger Instance Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/sirupsen/logrus/README.md Demonstrates how to create and use a custom instance of the `logrus.Logger`. This allows for multiple logger instances with different configurations. ```go package main import ( "os" "github.com/sirupsen/logrus" ) // Create a new instance of the logger. You can have any number of instances. var logger = logrus.New() func main() { // The API for setting attributes is a little different than the package level // exported logger. See Godoc. logger.Out = os.Stdout // You could set this to any `io.Writer` such as a file // file, err := os.OpenFile("logrus.log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666) // if err == nil { // logger.Out = file // } else { // logger.Info("Failed to log to file, using default stderr") // } logger.WithFields(logrus.Fields{ "animal": "walrus", "size": 10, }).Info("A group of walrus emerges from the ocean") } ``` -------------------------------- ### Run All Local Registry End-to-End Tests Source: https://github.com/carvel-dev/imgpkg/blob/develop/test/e2e/README.md Execute all end-to-end tests using a local Docker registry. Ensure Docker is installed and running. ```bash #!/bin/bash ./hack/test-all-local-registry.sh ``` -------------------------------- ### JSON Formatter Output Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/sirupsen/logrus/README.md Example output when using the JSON formatter, suitable for parsing by log aggregation tools like logstash or Splunk. ```text {"animal":"walrus","level":"info","msg":"A group of walrus emerges from the ocean","size":10,"time":"2014-03-10 19:57:38.562264131 -0400 EDT"} {"level":"warning","msg":"The group's number increased tremendously!", "number":122,"omg":true,"time":"2014-03-10 19:57:38.562471297 -0400 EDT"} {"animal":"walrus","level":"info","msg":"A giant walrus appears!", "size":10,"time":"2014-03-10 19:57:38.562500591 -0400 EDT"} {"animal":"walrus","level":"info","msg":"Tremendously sized cow enters the ocean.", "size":9,"time":"2014-03-10 19:57:38.562527896 -0400 EDT"} {"level":"fatal","msg":"The ice breaks!","number":100,"omg":true, "time":"2014-03-10 19:57:38.562543128 -0400 EDT"} ``` -------------------------------- ### Import Hash Implementations Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/opencontainers/go-digest/README.md Ensures necessary hash implementations (e.g., SHA-256, SHA-512) are available to prevent panics. This is typically done in the application's entrypoint. ```go import ( _ "crypto/sha256" _ "crypto/sha512" ) ``` -------------------------------- ### StartedByExplorer Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/inconshreveable/mousetrap/README.md Checks if the current process was started by a user double-clicking the executable in Windows Explorer. This is useful for providing more user-friendly messages for command-line tools on Windows. ```APIDOC ## StartedByExplorer ### Description Detects if the program was invoked by double-clicking the executable in Windows Explorer. ### Signature ```go func StartedByExplorer() (bool) ``` ### Returns - **bool**: `true` if the process was started by Explorer, `false` otherwise. ``` -------------------------------- ### Create a Multi-Keychain for Authentication Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/google/go-containerregistry/pkg/authn/README.md Use NewMultiKeychain to combine multiple Keychain implementations. They are checked in order until credentials are found. ```go kc := authn.NewMultiKeychain( authn.DefaultKeychain, google.Keychain, authn.NewKeychainFromHelper(ecr.ECRHelper{ClientFactory: api.DefaultClientFactory{}}), authn.NewKeychainFromHelper(acr.ACRCredHelper{}), ) ``` -------------------------------- ### Text Output with Caller Information Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/sirupsen/logrus/README.md Example text log entry when caller reporting is enabled, including the 'method' field indicating the calling function. ```text time="2015-03-26T01:27:38-04:00" level=fatal method=github.com/sirupsen/arcticcreatures.migrate msg="a penguin swims by" animal=penguin ``` -------------------------------- ### Plug into Existing Code Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/fatih/color/README.md Temporarily set global color attributes for subsequent output. Remember to unset them when finished to avoid affecting other parts of the application. ```go // Use handy standard colors color.Set(color.FgYellow) fmt.Println("Existing text will now be in yellow") fmt.Printf("This one %s\n", "too") color.Unset() // Don't forget to unset // You can mix up parameters color.Set(color.FgMagenta, color.Bold) defer color.Unset() // Use it in your function fmt.Println("All text will now be bold magenta.") ``` -------------------------------- ### JSON Output with Caller Information Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/sirupsen/logrus/README.md Example JSON log entry when caller reporting is enabled, including the 'method' field indicating the calling function. ```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"} ``` -------------------------------- ### Initiate Device Auth with Context Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/Azure/go-autorest/CHANGELOG.md Provides `adal.InitiateDeviceAuthWithContext()` as a context-aware alternative to `InitiateDeviceAuth`. ```go adal.InitiateDeviceAuthWithContext() ``` -------------------------------- ### Buffer Decompression with Zstd Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/klauspost/compress/zstd/README.md Ideal for decompressing smaller, in-memory buffers. This example uses a pre-created decoder for efficiency and allows the decoder to allocate the destination buffer. ```Go import "github.com/klauspost/compress/zstd" // Create a reader that caches decompressors. // For this operation type we supply a nil Reader. var decoder, _ = zstd.NewReader(nil, zstd.WithDecoderConcurrency(0)) // Decompress a buffer. We don't supply a destination buffer, // so it will be allocated by the decoder. func Decompress(src []byte) ([]byte, error) { return decoder.DecodeAll(src, nil) } ``` -------------------------------- ### Add Counterfeiter as a Tool Dependency Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/maxbrunsfeld/counterfeiter/v6/README.md Use `go get -tool` to add counterfeiter as a tool dependency for your project. This ensures it's available for use with `go generate`. ```shell go get -tool github.com/maxbrunsfeld/counterfeiter/v6 ``` -------------------------------- ### Testing Credential Helpers with Crane and Docker Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/google/go-containerregistry/pkg/authn/README.md Demonstrates how to test your configured credential helpers by pulling an image using both 'crane' and 'docker' commands. The output shows the authentication details passed to the helpers. ```bash $ crane manifest gcr.io/google-containers/pause > /dev/null {"ServerURL":"","Username":"_dcgcr_1_5_0_token","Secret":""} ``` ```bash $ 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 ``` -------------------------------- ### Disabling Sorting of Flags Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/spf13/pflag/README.md Shows how to disable the automatic sorting of flags in help and usage messages. This example defines several flags and then sets `flags.SortFlags = false` before printing defaults. ```go flags.BoolP("verbose", "v", false, "verbose output") flags.String("coolflag", "yeaah", "it's really cool flag") flags.Int("usefulflag", 777, "sometimes it's very useful") flags.SortFlags = false flags.PrintDefaults() ``` -------------------------------- ### Add Custom Prepare Decorators Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/Azure/go-autorest/CHANGELOG.md Use `autorest.WithPrepareDecorators` to add a custom chain of PrepareDecorators to the provided context. ```go autorest.WithPrepareDecorators ``` -------------------------------- ### Get Flag Value from FlagSet Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/spf13/pflag/README.md Retrieve the integer value of a flag from a pflag.FlagSet using GetInt(). Ensure the flag exists and is of the expected type, as GetString() would fail otherwise. ```go i, err := flagset.GetInt("flagname") ``` -------------------------------- ### Structured Logging with Fields Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/sirupsen/logrus/README.md Illustrates the recommended way to log events using fields for better discoverability, instead of long, unparseable error messages. The `WithFields` call is optional. ```go logrus.WithFields(logrus.Fields{ "event": event, "topic": topic, "key": key, }).Fatal("Failed to send event") ``` -------------------------------- ### Build and Sign JWT with HMAC Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/form3tech-oss/jwt-go/README.md Shows how to create a new JWT and sign it using HMAC SHA. Custom claims can be added to the token. ```go package main import ( "fmt" "github.com/dgrijalva/jwt-go" "time" ) func main() { // Create a new token object, specifying signing method and the claims token := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{ "name": "John Doe", "admin": true, "exp": time.Now().Add(time.Hour * 24).Unix(), // Expiration time }) // Sign the token with a secret key ttokenString, err := token.SignedString([]byte("your secret key")) if err != nil { panic(err) } fmt.Println(tokenString) } ``` -------------------------------- ### Check if Started by Explorer Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/inconshreveable/mousetrap/README.md Use this function to determine if the current process was launched by a user double-clicking the executable in Windows Explorer. This is useful for providing alternative behavior or instructions for users unfamiliar with the command line. ```go func StartedByExplorer() (bool) ``` -------------------------------- ### Client Send Method Source: https://github.com/carvel-dev/imgpkg/blob/develop/vendor/github.com/Azure/go-autorest/CHANGELOG.md The `Client.Send()` method includes logic for selecting the preferred chain of SendDecorators. ```go Client.Send() ```