### Full Example of Mux Server Setup Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/gorilla/mux/README.md This is a complete, runnable example of a small HTTP server using Gorilla Mux. It sets up a single route and starts the server. ```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 Blackfriday v2 Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/russross/blackfriday/v2/README.md Use `go get` to install the package in module mode. Alternatively, import it in your package and run `go get`. ```go go get github.com/russross/blackfriday/v2 ``` ```go import "github.com/russross/blackfriday/v2" ``` -------------------------------- ### Install goquery Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/PuerkitoBio/goquery/README.md Use 'go get' to install the goquery library. This command fetches and installs the package and its dependencies. ```bash go get github.com/PuerkitoBio/goquery ``` -------------------------------- ### Install htmlquery Package Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/antchfx/htmlquery/README.md Use 'go get' to install the htmlquery package. ```bash go get github.com/antchfx/htmlquery ``` -------------------------------- ### Install uilive Package Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/mintoolkit/uilive/README.md Use the go get command to install the uilive library into your Go workspace. ```sh go get -v github.com/mintoolkit/uilive ``` -------------------------------- ### Install xmlquery Package Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/antchfx/xmlquery/README.md Use 'go get' to install the xmlquery package. ```bash $ go get github.com/antchfx/xmlquery ``` -------------------------------- ### Install Mergo Source: https://github.com/mintoolkit/mint/blob/master/vendor/dario.cat/mergo/README.md Instructions on how to install the Mergo library using go get. ```bash go get dario.cat/mergo ``` -------------------------------- ### Install go-colorful Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/lucasb-eyer/go-colorful/README.md Install the library using go get. The package can then be used through an import statement. ```bash go get github.com/lucasb-eyer/go-colorful ``` ```go import "github.com/lucasb-eyer/go-colorful" ``` -------------------------------- ### Full Registry Workflow Example Source: https://context7.com/mintoolkit/mint/llms.txt Demonstrates a complete workflow: starting a local registry, pushing an image to it, and then pulling it back. ```bash mint registry server & mint registry push --docker nginx --as localhost:5000/nginx mint registry pull localhost:5000/nginx ``` -------------------------------- ### Install Build Tools and Run Tests Source: https://github.com/mintoolkit/mint/blob/master/vendor/go.opencensus.io/CONTRIBUTING.md Install necessary tools for building and testing the project. 'make install-tools' is a one-time setup, while 'make' runs the test suite. ```bash $ make install-tools # Only first time. $ make ``` -------------------------------- ### Install go-isatty Package Source: https://github.com/mintoolkit/mint/blob/master/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 OpenCensus Go Source: https://github.com/mintoolkit/mint/blob/master/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 ``` -------------------------------- ### Start the Virtual Machine Source: https://github.com/mintoolkit/mint/blob/master/examples/fedora39_docker26/README.md Use this command to provision and start the virtual machine. ```bash vagrant up ``` -------------------------------- ### Install go-tty Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/mattn/go-tty/README.md Installs the go-tty package using the go get command. ```bash $ go get github.com/mattn/go-tty ``` -------------------------------- ### Install gobwas/glob Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/gobwas/glob/readme.md Use 'go get' to install the library. ```shell go get github.com/gobwas/glob ``` -------------------------------- ### Install ULID Go Package Source: https://github.com/mintoolkit/mint/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 nxadm/tail library Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/nxadm/tail/README.md Install the nxadm/tail library using the go get command. ```Go go get github.com/nxadm/tail/... ``` -------------------------------- ### Install and Import YAML Library Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/ghodss/yaml/README.md Instructions for installing the library using go get and importing it into your Go project. ```bash go get github.com/ghodss/yaml ``` ```go import "github.com/ghodss/yaml" ``` -------------------------------- ### Install go-yaml.v2 Source: https://github.com/mintoolkit/mint/blob/master/vendor/sigs.k8s.io/yaml/goyaml.v2/README.md Use 'go get' to install the go-yaml.v2 package for your Go projects. ```bash go get gopkg.in/yaml.v2 ``` -------------------------------- ### Install Diskv using Go Get Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/peterbourgon/diskv/README.md Installs the diskv package using the Go build tool. Ensure Go 1.x is installed first. ```bash go get github.com/peterbourgon/diskv ``` -------------------------------- ### Install and Import kubernetes-sigs/yaml Source: https://github.com/mintoolkit/mint/blob/master/vendor/sigs.k8s.io/yaml/README.md Install the library using go get and import it in your Go projects. ```bash go get sigs.k8s.io/yaml ``` ```go import "sigs.k8s.io/yaml" ``` -------------------------------- ### Install Cobra Library Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/spf13/cobra/README.md Use 'go get' to install the latest version of the Cobra library. ```bash go get -u github.com/spf13/cobra@latest ``` -------------------------------- ### Build and Install miekg/dns Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/miekg/dns/README.md Standard Go commands to get and build the miekg/dns library. ```bash go get github.com/miekg/dns go build github.com/miekg/dns ``` -------------------------------- ### Install blackfriday-tool Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/russross/blackfriday/v2/README.md 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 Golang Color Package Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/fatih/color/README.md Use 'go get' to install the color package. This command fetches and installs the specified package and its dependencies. ```bash go get github.com/fatih/color ``` -------------------------------- ### Install pgzip Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/klauspost/pgzip/README.md Use 'go get' to install the pgzip package. You may need to update its dependencies. ```go go get github.com/klauspost/pgzip/... ``` ```go go get -u github.com/klauspost/compress ``` -------------------------------- ### Basic Web Crawler Example in Go Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/gocolly/colly/v2/README.md This is a fundamental example demonstrating how to create a new collector, define an HTML element handler to visit links, and set up a request handler to print visited URLs. It starts by visiting a given URL. ```go func main() { c := colly.NewCollector() // Find and visit all links c.OnHTML("a[href]", func(e *colly.HTMLElement) { e.Request.Visit(e.Attr("href")) }) c.OnRequest(func(r *colly.Request) { fmt.Println("Visiting", r.URL) }) c.Visit("http://go-colly.org/") } ``` -------------------------------- ### Install Mergo Source: https://github.com/mintoolkit/mint/blob/master/vendor/dario.cat/mergo/README.md Use 'go get' to install the Mergo package. Import it in your Go code. ```go go get dario.cat/mergo // use in your .go code import ( "dario.cat/mergo" ) ``` -------------------------------- ### Install go-colorable Package Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/mattn/go-colorable/README.md Install the go-colorable package using the go get command. This command fetches and installs the package and its dependencies into your Go workspace. ```bash go get github.com/mattn/go-colorable ``` -------------------------------- ### Install Gorilla Mux Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/gorilla/mux/README.md Install the gorilla/mux package using the go get command. Ensure your Go toolchain is correctly configured. ```sh go get -u github.com/gorilla/mux ``` -------------------------------- ### Install terminfo Package Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/xo/terminfo/README.md Install the terminfo package using the standard Go command. ```sh go get -u github.com/xo/terminfo ``` -------------------------------- ### Download and Install Protobuf Compiler Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/containerd/containerd/BUILDING.md Download and install the Protobuf compiler and headers. This is a build requirement for containerd. Ensure it is installed in a location like /usr/local. ```sh wget -c https://github.com/protocolbuffers/protobuf/releases/download/v3.11.4/protoc-3.11.4-linux-x86_64.zip sudo unzip protoc-3.11.4-linux-x86_64.zip -d /usr/local ``` -------------------------------- ### Install GoDotEnv as a Bin Command Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/ulyssessouza/godotenv/README.md Use this command to install the GoDotEnv command-line tool. ```shell go get github.com/joho/godotenv/cmd/godotenv ``` -------------------------------- ### Build and Run PKCS#11 Example Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/stefanberger/go-pkcs11uri/README.md These commands demonstrate building the Go example program and then running it with a specific PKCS#11 URI. The URI includes the slot ID obtained from token initialization and the path to the SoftHSM2 module. ```bash $ go build ./... $ sudo ./pkcs11-example 'pkcs11:slot-id=2053753261?module-path=/usr/lib64/pkcs11/libsofthsm2.so&pin-value=1234' 517592df8fec3ad146a79a9af153db2a4d784ec5 ``` -------------------------------- ### Basic Diskv Usage Example Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/peterbourgon/diskv/README.md Demonstrates the simplest way to use diskv: initializing a store, writing a key-value pair, reading it back, and erasing it. Uses a flat transform function and specifies a cache size. ```go package main import ( "fmt" "github.com/peterbourgon/diskv" ) func main() { // Simplest transform function: put all the data files into the base dir. flatTransform := func(s string) []string { return []string{} } // Initialize a new diskv store, rooted at "my-data-dir", with a 1MB cache. d := diskv.New(diskv.Options{ BasePath: "my-data-dir", Transform: flatTransform, CacheSizeMax: 1024 * 1024, }) // Write three bytes to the key "alpha". key := "alpha" d.Write(key, []byte{'1', '2', '3'}) // Read the value back out of the store. value, _ := d.Read(key) fmt.Printf("%v\n", value) // Erase the key+value from the store (and the disk). d.Erase(key) } ``` -------------------------------- ### Install go-localereader Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/mattn/go-localereader/README.md Install the go-localereader package using the go get command. ```bash $ go get github.com/mattn/go-localereader ``` -------------------------------- ### Initialize containerd Client Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/containerd/containerd/README.md Demonstrates how to create a new containerd client instance. Ensure the socket path is correct for your environment. ```go import ( "context" "github.com/containerd/containerd" "github.com/containerd/containerd/cio" "github.com/containerd/containerd/namespaces" ) func main() { client, err := containerd.New("/run/containerd/containerd.sock") defer client.Close() } ``` -------------------------------- ### Pull Image, Create and Start Container (Go) Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/containers/podman/v5/pkg/bindings/README.md Demonstrates pulling an image, creating a container with a specific name, and then starting it. Ensure the Podman socket is accessible. ```go import ( "context" "fmt" "os" "github.com/containers/podman/v5/pkg/bindings" "github.com/containers/podman/v5/pkg/bindings/containers" "github.com/containers/podman/v5/pkg/bindings/images" "github.com/containers/podman/v5/pkg/specgen" ) func main() { conn, err := bindings.NewConnection(context.Background(), "unix:///run/podman/podman.sock") if err != nil { fmt.Println(err) os.Exit(1) } _, err = images.Pull(conn, "quay.io/libpod/alpine_nginx", nil) if err != nil { fmt.Println(err) os.Exit(1) } s := specgen.NewSpecGenerator("quay.io/libpod/alpine_nginx", false) s.Name = "foobar" createResponse, err := containers.CreateWithSpec(conn, s, nil) if err != nil { fmt.Println(err) os.Exit(1) } fmt.Println("Container created.") if err := containers.Start(conn, createResponse.ID, nil); err != nil { fmt.Println(err) os.Exit(1) } fmt.Println("Container started.") } ``` -------------------------------- ### Configured CLI Application with Action Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/urfave/cli/v2/godoc-current.txt Shows how to configure a basic CLI application with a name, usage, and a simple action that prints 'Greetings'. The application is then run with command-line arguments. ```go func main() { app := &cli.App{ Name: "greet", Usage: "say a greeting", Action: func(c *cli.Context) error { fmt.Println("Greetings") return nil }, } app.Run(os.Args) } ``` -------------------------------- ### Install termenv Package Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/muesli/termenv/README.md Use go get to install the termenv package. This command fetches and installs the package and its dependencies. ```bash go get github.com/muesli/termenv ``` -------------------------------- ### Install doublestar Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/bmatcuk/doublestar/v3/README.md Install the doublestar package using go get. This command fetches and installs the specified version of the package. ```bash go get github.com/bmatcuk/doublestar/v2 ``` -------------------------------- ### SpdyStream Client Example Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/moby/spdystream/README.md Demonstrates how to establish a SpdyStream connection as a client, create a stream, write data, read data, and close the stream. Connects to a mirroring server without authentication. ```go package main import ( "fmt" "github.com/moby/spdystream" "net" "net/http" ) func main() { conn, err := net.Dial("tcp", "localhost:8080") if err != nil { panic(err) } spdyConn, err := spdystream.NewConnection(conn, false) if err != nil { panic(err) } go spdyConn.Serve(spdystream.NoOpStreamHandler) stream, err := spdyConn.CreateStream(http.Header{}, nil, false) if err != nil { panic(err) } stream.Wait() fmt.Fprint(stream, "Writing to stream") buf := make([]byte, 25) stream.Read(buf) fmt.Println(string(buf)) stream.Close() } ``` -------------------------------- ### Install doublestar package Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/bmatcuk/doublestar/README.md Install the doublestar package using go get. This command fetches and installs the package and its dependencies. ```bash go get github.com/bmatcuk/doublestar ``` -------------------------------- ### Install stripansi Package Source: https://github.com/mintoolkit/mint/blob/master/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 ``` -------------------------------- ### Go Connect RPC Client Example Source: https://github.com/mintoolkit/mint/blob/master/vendor/connectrpc.com/connect/README.md Create a Connect RPC client to interact with a running server. This example demonstrates how to instantiate a client, set request headers, and process the response. ```go package main import ( "context" "log" "net/http" "connectrpc.com/connect" pingv1 "connectrpc.com/connect/internal/gen/connect/ping/v1" "connectrpc.com/connect/internal/gen/connect/ping/v1/pingv1connect" ) func main() { client := pingv1connect.NewPingServiceClient( http.DefaultClient, "http://localhost:8080/", ) req := connect.NewRequest(&pingv1.PingRequest{ Number: 42, }) req.Header().Set("Some-Header", "hello from connect") res, err := client.Ping(context.Background(), req) if err != nil { log.Fatalln(err) } log.Println(res.Msg) log.Println(res.Header().Get("Some-Other-Header")) } ``` -------------------------------- ### Basic terminfo Example Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/xo/terminfo/README.md Demonstrates basic usage of the terminfo package, including terminal initialization, setting the title, displaying text, and rendering colors. It handles terminal cleanup on exit. ```go // _examples/simple/main.go package main import ( "bytes" "fmt" "log" "os" "os/signal" "strings" "sync" "syscall" "github.com/xo/terminfo" ) func main() { //r := rand.New(nil) // load terminfo ti, err := terminfo.LoadFromEnv() if err != nil { log.Fatal(err) } // cleanup defer func() { err := recover() termreset(ti) if err != nil { log.Fatal(err) } }() terminit(ti) termtitle(ti, "simple example!") termputs(ti, 3, 3, "Ctrl-C to exit") maxColors := termcolors(ti) if maxColors > 256 { maxColors = 256 } for i := 0; i < maxColors; i++ { termputs(ti, 5+i/16, 5+i%16, ti.Colorf(i, 0, "█")) } // wait for signal sigs := make(chan os.Signal, 1) signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) <-sigs } // terminit initializes the special CA mode on the terminal, and makes the // cursor invisible. func terminit(ti *terminfo.Terminfo) { buf := new(bytes.Buffer) // set the cursor invisible ti.Fprintf(buf, terminfo.CursorInvisible) // enter special mode ti.Fprintf(buf, terminfo.EnterCaMode) // clear the screen ti.Fprintf(buf, terminfo.ClearScreen) os.Stdout.Write(buf.Bytes()) } // termreset is the inverse of terminit. func termreset(ti *terminfo.Terminfo) { buf := new(bytes.Buffer) ti.Fprintf(buf, terminfo.ExitCaMode) ti.Fprintf(buf, terminfo.CursorNormal) os.Stdout.Write(buf.Bytes()) } // termputs puts a string at row, col, interpolating v. func termputs(ti *terminfo.Terminfo, row, col int, s string, v ...interface{}) { buf := new(bytes.Buffer) ti.Fprintf(buf, terminfo.CursorAddress, row, col) fmt.Fprintf(buf, s, v...) os.Stdout.Write(buf.Bytes()) } // sl is the status line terminfo. var sl *terminfo.Terminfo // termtitle sets the window title. func termtitle(ti *terminfo.Terminfo, s string) { var once sync.Once once.Do(func() { if ti.Has(terminfo.HasStatusLine) { return } // load the sl xterm if terminal is an xterm or has COLORTERM if strings.Contains(strings.ToLower(os.Getenv("TERM")), "xterm") || os.Getenv("COLORTERM") == "truecolor" { sl, _ = terminfo.Load("xterm+sl") } }) if sl != nil { ti = sl } if !ti.Has(terminfo.HasStatusLine) { return } buf := new(bytes.Buffer) ti.Fprintf(buf, terminfo.ToStatusLine) fmt.Fprint(buf, s) ti.Fprintf(buf, terminfo.FromStatusLine) os.Stdout.Write(buf.Bytes()) } // termcolors returns the maximum colors available for the terminal. func termcolors(ti *terminfo.Terminfo) int { if colors := ti.Num(terminfo.MaxColors); colors > 0 { return colors } return int(terminfo.ColorLevelBasic) } ``` -------------------------------- ### Go Installation Command Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/dsnet/compress/README.md Run this command to install the library. Requires Go 1.9 or higher. ```bash go get -u github.com/dsnet/compress ``` -------------------------------- ### Go Connect RPC Server Example Source: https://github.com/mintoolkit/mint/blob/master/vendor/connectrpc.com/connect/README.md Implement a Connect RPC server using generated code from a Protobuf schema. This example shows how to define a service handler, process incoming requests, and set response headers. ```go package main import ( "context" "log" "net/http" "connectrpc.com/connect" pingv1 "connectrpc.com/connect/internal/gen/connect/ping/v1" "connectrpc.com/connect/internal/gen/connect/ping/v1/pingv1connect" "golang.org/x/net/http2" "golang.org/x/net/http2/h2c" ) type PingServer struct { pingv1connect.UnimplementedPingServiceHandler // returns errors from all methods } func (ps *PingServer) Ping( ctx context.Context, req *connect.Request[pingv1.PingRequest], ) (*connect.Response[pingv1.PingResponse], error) { // connect.Request and connect.Response give you direct access to headers and // trailers. No context-based nonsense! log.Println(req.Header().Get("Some-Header")) res := connect.NewResponse(&pingv1.PingResponse{ // req.Msg is a strongly-typed *pingv1.PingRequest, so we can access its // fields without type assertions. Number: req.Msg.Number, }) res.Header().Set("Some-Other-Header", "hello!") return res, nil } func main() { mux := http.NewServeMux() // The generated constructors return a path and a plain net/http // handler. mux.Handle(pingv1connect.NewPingServiceHandler(&PingServer{})) err := http.ListenAndServe( "localhost:8080", // For gRPC clients, it's convenient to support HTTP/2 without TLS. You can // avoid x/net/http2 by using http.ListenAndServeTLS. h2c.NewHandler(mux, &http2.Server{}), ) log.Fatalf("listen failed: %v", err) } ``` -------------------------------- ### Install json-iterator/go Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/json-iterator/go/README.md Use the go get command to install the json-iterator/go package into your project. ```bash go get github.com/json-iterator/go ``` -------------------------------- ### Clone Mint Examples Repository Source: https://github.com/mintoolkit/mint/blob/master/README.md Clone the examples repository to use sample applications. This step can be skipped if you have your own application. ```bash git clone https://github.com/mintoolkit/examples.git ``` -------------------------------- ### Install aec Package Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/morikuni/aec/README.md Use 'go get' to install the aec package. This command fetches and installs the specified package and its dependencies. ```bash go get github.com/morikuni/aec ``` -------------------------------- ### Setup Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/urfave/cli/v2/godoc-current.txt Runs initialization code to ensure all data structures are ready for `Run` or inspection prior to `Run`. It is internally called by `Run`, but will return early if setup has already happened. ```APIDOC ## App.Setup ### Description `Setup` runs initialization code to ensure all data structures are ready for `Run` or inspection prior to `Run`. It is internally called by `Run`, but will return early if setup has already happened. ### Signature `func (a *App) Setup()` ``` -------------------------------- ### Install mapstructure Go Library Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/mitchellh/mapstructure/README.md Use `go get` to install the mapstructure library. This command fetches and installs the package and its dependencies. ```bash $ go get github.com/mitchellh/mapstructure ``` -------------------------------- ### Install govalidator Package Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/asaskevich/govalidator/README.md Use 'go get' to install the govalidator package. You can install the latest version or a specific release using gopkg.in. ```bash go get github.com/asaskevich/govalidator ``` ```bash go get gopkg.in/asaskevich/govalidator.v10 ``` -------------------------------- ### Install uniseg Package Source: https://github.com/mintoolkit/mint/blob/master/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 uuid Package Source: https://github.com/mintoolkit/mint/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 Interactive Prompt with Auto-completion Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/c-bata/go-prompt/README.md This example demonstrates how to set up a basic interactive prompt with auto-completion suggestions. It defines a completer function that filters suggestions based on user input. ```go package main import ( "fmt" "github.com/c-bata/go-prompt" ) func completer(d prompt.Document) []prompt.Suggest { s := []prompt.Suggest{ {Text: "users", Description: "Store the username and age"}, {Text: "articles", Description: "Store the article text posted by user"}, {Text: "comments", Description: "Store the text commented to articles"}, } return prompt.FilterHasPrefix(s, d.GetWordBeforeCursor(), true) } func main() { fmt.Println("Please select table.") t := prompt.Input("> ", completer) fmt.Println("You selected " + t) } ``` -------------------------------- ### Create a Simple List Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/charmbracelet/lipgloss/README.md Define and print a basic list with string items. ```go l := list.New("A", "B", "C") ``` ```go fmt.Println(l) ``` -------------------------------- ### Install and Run Local Go Doc Site Source: https://github.com/mintoolkit/mint/blob/master/vendor/go.opentelemetry.io/otel/CONTRIBUTING.md Installs and runs a local Go Doc site using pkgsite. This is useful for previewing package documentation. ```sh go install golang.org/x/pkgsite/cmd/pkgsite@latest pkgsite ``` -------------------------------- ### Install treeprint Go Package Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/xlab/treeprint/README.md Use 'go get' to install the treeprint package for your Go project. ```bash $ go get github.com/xlab/treeprint ``` -------------------------------- ### Install GoTree using Go Get Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/disiqueira/gotree/v3/README.md Use this command to install the GoTree module into your Go project. ```bash go get github.com/disiqueira/gotree ``` -------------------------------- ### List Docker Images Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/fsouza/go-dockerclient/README.md Instantiate a client from environment variables and list all Docker images. Ensure Docker is running and accessible via environment variables. ```go package main import ( "fmt" docker "github.com/fsouza/go-dockerclient" ) func main() { client, err := docker.NewClientFromEnv() if err != nil { panic(err) } imgs, err := client.ListImages(docker.ListImagesOptions{All: false}) if err != nil { panic(err) } for _, img := range imgs { fmt.Println("ID: ", img.ID) fmt.Println("RepoTags: ", img.RepoTags) fmt.Println("Created: ", img.Created) fmt.Println("Size: ", img.Size) fmt.Println("VirtualSize: ", img.VirtualSize) fmt.Println("ParentId: ", img.ParentID) } } ``` -------------------------------- ### Install dbus Library Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/godbus/dbus/v5/README.md Install the dbus library using the go get command. This package requires Go 1.12 or later. ```go go get github.com/godbus/dbus/v5 ``` -------------------------------- ### Build Image with Podman Engine Source: https://github.com/mintoolkit/mint/blob/master/README.md Example using the `Podman` engine. This snippet demonstrates setting the image name, build arguments, and labels. The `--dockerfile` flag is optional if `Dockerfile` is present in the context directory. ```bash mint imagebuild --engine podman --image-name imagebuild-podman-app:latest --build-arg BA=1 --label LONE=value --label LTWO="label two value" --dockerfile Dockerfile --context-dir node_app ``` -------------------------------- ### Install ksuid Go Library Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/segmentio/ksuid/README.md Use 'go get' to install or update the ksuid library. This command fetches the latest version and makes it available in your Go workspace. ```sh go get -u github.com/segmentio/ksuid ``` -------------------------------- ### GitLab CI/CD Mint Integration Example Source: https://github.com/mintoolkit/mint/blob/master/README.md Example for configuring Mint within a GitLab CI/CD pipeline using the `dind` service, ensuring Docker host communication. ```bash docker run -e DOCKER_HOST=tcp://$(grep docker /etc/hosts | cut -f1):2375 mintoolkit/mint slim your-docker-image-name ``` -------------------------------- ### Create, Snapshot, Clone, and Destroy ZFS Filesystem Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/mistifyio/go-zfs/v3/README.md Demonstrates the lifecycle of a ZFS filesystem: creation, snapshotting, cloning, and destruction. Assumes a ZFS pool named 'test' exists. Error handling is omitted for brevity. ```go //assuming a zpool named test //error handling omitted f, err := zfs.CreateFilesystem("test/snapshot-test", nil) ok(t, err) s, err := f.Snapshot("test", nil) ok(t, err) // snapshot is named "test/snapshot-test@test" c, err := s.Clone("test/clone-test", nil) err := c.Destroy() err := s.Destroy() err := f.Destroy() ``` -------------------------------- ### Basic GoTree Usage Example Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/disiqueira/gotree/v3/README.md Demonstrates how to create a simple tree structure with nodes and print it to the console. Requires importing the 'gotree' package. ```golang package main import ( "fmt" "github.com/disiqueira/gotree" ) func main() { artist := gotree.New("Pantera") album := artist.Add("Far Beyond Driven") album.Add("5 minutes Alone") fmt.Println(artist.Print()) } ``` -------------------------------- ### Install Latest JSON-Patch Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/evanphx/json-patch/README.md Use this command to get the latest version of the jsonpatch library. ```bash go get -u github.com/evanphx/json-patch/v5 ``` -------------------------------- ### Get and Set Interface{} Value with reflect2 Source: https://github.com/mintoolkit/mint/blob/master/vendor/github.com/modern-go/reflect2/README.md To get and set values of an interface{}, always use the pointer to the type. This example demonstrates setting the value of `i` to `10` by passing pointers to `i` and `j` to the Set method. ```go valType := reflect2.TypeOf(1) i := 1 j := 10 valType.Set(&i, &j) // i will be 10 ```