### Install and Test go-ole Source: https://github.com/grafana/loki/blob/main/vendor/github.com/go-ole/go-ole/README.md Instructions to get, compile, and test the go-ole library, including running an example program for Excel. ```bash go get github.com/go-ole/go-ole cd /path/to/go-ole/ go test cd /path/to/go-ole/example/excel go run excel.go ``` -------------------------------- ### Start Mail-House Example Source: https://github.com/grafana/loki/blob/main/docs/sources/query/logcli/logcli-tutorial.md Start the mail-house example using Docker Compose. This sets up a Loki instance accessible at http://localhost:3100. ```bash docker compose -f alloy-scenarios/mail-house/docker-compose.yml up -d ``` -------------------------------- ### Install go-version Source: https://github.com/grafana/loki/blob/main/vendor/github.com/hashicorp/go-version/README.md Install the go-version library using the go get command. ```bash $ go get github.com/hashicorp/go-version ``` -------------------------------- ### Install go-proxyproto Source: https://github.com/grafana/loki/blob/main/vendor/github.com/pires/go-proxyproto/README.md Install the go-proxyproto library using the go get command. ```shell go get -u github.com/pires/go-proxyproto ``` -------------------------------- ### Install Objx Source: https://github.com/grafana/loki/blob/main/vendor/github.com/stretchr/objx/README.md Install the Objx package using the `go get` command. ```bash go get github.com/stretchr/objx ``` -------------------------------- ### Install fatih/color Source: https://github.com/grafana/loki/blob/main/vendor/github.com/fatih/color/README.md Install the color library using go get. ```go go get github.com/fatih/color ``` -------------------------------- ### Install go-openapi/loads Source: https://github.com/grafana/loki/blob/main/vendor/github.com/go-openapi/loads/README.md Install the go-openapi/loads library using the go get command. ```cmd go get github.com/go-openapi/loads ``` -------------------------------- ### Install go-urn Source: https://github.com/grafana/loki/blob/main/vendor/github.com/leodido/go-urn/README.md Use 'go get' to install the go-urn library. ```go go get github.com/leodido/go-urn ``` -------------------------------- ### Install Swift Library Source: https://github.com/grafana/loki/blob/main/vendor/github.com/ncw/swift/README.md Use 'go get' to install the Swift library for Go. ```bash go get github.com/ncw/swift ``` -------------------------------- ### Install parquet-go/bitpack Source: https://github.com/grafana/loki/blob/main/vendor/github.com/parquet-go/bitpack/README.md Install the library using the go get command. ```bash go get github.com/parquet-go/bitpack ``` -------------------------------- ### Install clipboard for Go Source: https://github.com/grafana/loki/blob/main/vendor/github.com/atotto/clipboard/README.md Install the clipboard library using go get. ```bash go get github.com/atotto/clipboard ``` -------------------------------- ### Install geoip2-golang Source: https://github.com/grafana/loki/blob/main/vendor/github.com/oschwald/geoip2-golang/v2/README.md Install the geoip2-golang library using go get. ```bash go get github.com/oschwald/geoip2-golang/v2 ``` -------------------------------- ### Install goccy/go-json Source: https://github.com/grafana/loki/blob/main/vendor/github.com/goccy/go-json/README.md Install the library using the go get command. ```go go get github.com/goccy/go-json ``` -------------------------------- ### Install pgzip Source: https://github.com/grafana/loki/blob/main/vendor/github.com/klauspost/pgzip/README.md Install the pgzip package using go get. ```go go get github.com/klauspost/pgzip/... ``` -------------------------------- ### Install Swift Go Library Source: https://github.com/grafana/loki/blob/main/vendor/github.com/ncw/swift/v2/README.md Use 'go get' to install the library. This command fetches and installs the specified package and its dependencies. ```go go get github.com/ncw/swift/v2 ``` -------------------------------- ### Install Afero Package Source: https://github.com/grafana/loki/blob/main/vendor/github.com/spf13/afero/README.md Use go get to install the Afero package for your project. ```bash go get github.com/spf13/afero ``` -------------------------------- ### Install Ultraviolet Source: https://github.com/grafana/loki/blob/main/vendor/github.com/charmbracelet/ultraviolet/README.md Install the latest version of Ultraviolet using go get. ```bash go get github.com/charmbracelet/ultraviolet@latest ``` -------------------------------- ### Install colorstring Go Library Source: https://github.com/grafana/loki/blob/main/vendor/github.com/mitchellh/colorstring/README.md Use 'go get' to install the colorstring library. This is the standard method for Go package installation. ```bash go get github.com/mitchellh/colorstring ``` -------------------------------- ### Install displaywidth Package Source: https://github.com/grafana/loki/blob/main/vendor/github.com/clipperhouse/displaywidth/README.md Use 'go get' to install the displaywidth package for your Go project. ```bash go get github.com/clipperhouse/displaywidth ``` -------------------------------- ### Install Lip Gloss v2 Source: https://github.com/grafana/loki/blob/main/vendor/charm.land/lipgloss/v2/UPGRADE_GUIDE_V2.md Install Lip Gloss v2 using go get. ```bash go get charm.land/lipgloss/v2 ``` -------------------------------- ### Build All Examples Source: https://github.com/grafana/loki/blob/main/vendor/github.com/minio/minio-go/v7/CLAUDE.md Compile all example programs within the repository. ```bash # Build all examples make examples ``` -------------------------------- ### Generate Example Configuration Documentation Source: https://github.com/grafana/loki/blob/main/docs/sources/configure/examples/yaml/README.txt Run this command to update the documentation after adding a new example. ```bash make generate-example-config-doc ``` -------------------------------- ### Setup and Run Demo Source: https://github.com/grafana/loki/blob/main/vendor/github.com/axiomhq/hyperloglog/Contributing.md Steps to clone the repository, navigate to the demo directory, and run the HyperLogLog demo application. ```bash git clone https://github.com/axiomhq/hyperloglog.git cd hyperloglog cd demo go run hyperloglog_demo.go ``` -------------------------------- ### Install go-str2duration Source: https://github.com/grafana/loki/blob/main/vendor/github.com/xhit/go-str2duration/v2/README.md Install the go-str2duration package using go get. ```bash go get github.com/xhit/go-str2duration/v2 ``` -------------------------------- ### Swift Go Library Usage Example Source: https://github.com/grafana/loki/blob/main/vendor/github.com/ncw/swift/v2/README.md Example demonstrating how to create a Swift connection, authenticate, and list containers. Ensure to replace placeholder values with your actual credentials and URLs. ```go import "github.com/ncw/swift/v2" // Create a connection c := swift.Connection{ UserName: "user", ApiKey: "key", AuthUrl: "auth_url", Domain: "domain", // Name of the domain (v3 auth only) Tenant: "tenant", // Name of the tenant (v2 auth only) } // Authenticate err := c.Authenticate() if err != nil { panic(err) } // List all the containers containers, err := c.ContainerNames(nil) fmt.Println(containers) // etc... ``` -------------------------------- ### Install slog-gokit Source: https://github.com/grafana/loki/blob/main/vendor/github.com/tjhop/slog-gokit/README.md Install the slog-gokit library using go get. ```bash go get github.com/tjhop/slog-gokit ``` -------------------------------- ### Run MinIO Go Example Source: https://github.com/grafana/loki/blob/main/vendor/github.com/minio/minio-go/v7/README.md Commands to initialize the Go module, download dependencies, and run the FileUploader example. ```sh go mod init example/FileUploader go get github.com/minio/minio-go/v7 go get github.com/minio/minio-go/v7/pkg/credentials go run FileUploader.go ``` -------------------------------- ### Build a Specific Example Source: https://github.com/grafana/loki/blob/main/vendor/github.com/minio/minio-go/v7/CLAUDE.md Compile a single example program by navigating to its directory and running go build. ```bash # Build a specific example cd examples/s3 && go build -mod=mod putobject.go ``` -------------------------------- ### Quick Start: Basic Terminal Application Source: https://github.com/grafana/loki/blob/main/vendor/github.com/charmbracelet/ultraviolet/README.md A basic example demonstrating how to initialize a terminal, enter an alternate screen, and handle window resize and key press events. This snippet shows how to draw centered text and exit the application. ```go package main import ( "log" uv "github.com/charmbracelet/ultraviolet" "github.com/charmbracelet/ultraviolet/screen" ) func main() { t := uv.DefaultTerminal() scr := t.Screen() scr.EnterAltScreen() if err := t.Start(); err != nil { log.Fatalf("failed to start terminal: %v", err) } defer t.Stop() ctx := screen.NewContext(scr) text := "Hello, World!" textWidth := scr.StringWidth(text) display := func() { screen.Clear(scr) bounds := scr.Bounds() x := (bounds.Dx() - textWidth) / 2 y := bounds.Dy() / 2 ctx.DrawString(text, x, y) scr.Render() scr.Flush() } for ev := range t.Events() { switch ev := ev.(type) { case uv.WindowSizeEvent: scr.Resize(ev.Width, ev.Height) display() case uv.KeyPressEvent: if ev.MatchString("q", "ctrl+c") { return } } } } ``` -------------------------------- ### DQue Go Library Example Source: https://github.com/grafana/loki/blob/main/vendor/github.com/joncrlsn/dque/README.md Demonstrates the basic usage of the DQue library, including creating, opening, enqueuing, and dequeuing items from a persistent queue. It also shows how to handle custom item types and potential errors. ```Go package dque_test import ( "log" "github.com/joncrlsn/dque" ) // Item is what we'll be storing in the queue. It can be any struct // as long as the fields you want stored are public. type Item struct { Name string Id int } // ItemBuilder creates a new item and returns a pointer to it. // This is used when we load a segment of the queue from disk. func ItemBuilder() interface{} { return &Item{} } func main() { ExampleDQue_main() } // ExampleQueue_main() show how the queue works func ExampleDQue_main() { qName := "item-queue" qDir := "/tmp" segmentSize := 50 // Create a new queue with segment size of 50 q, err := dque.New(qName, qDir, segmentSize, ItemBuilder) ... // Add an item to the queue err := q.Enqueue(&Item{"Joe", 1}) ... // Properly close a queue q.Close() // You can reconsitute the queue from disk at any time q, err = dque.Open(qName, qDir, segmentSize, ItemBuilder) ... // Peek at the next item in the queue var iface interface{} if iface, err = q.Peek(); err != nil { if err != dque.ErrEmpty { log.Fatal("Error peeking at item ", err) } } // Dequeue the next item in the queue if iface, err = q.Dequeue(); err != nil { if err != dque.ErrEmpty { log.Fatal("Error dequeuing item ", err) } } // Dequeue the next item in the queue and block until one is available if iface, err = q.DequeueBlock(); err != nil { log.Fatal("Error dequeuing item ", err) } // Assert type of the response to an Item pointer so we can work with it item, ok := iface.(*Item) if !ok { log.Fatal("Dequeued object is not an Item pointer") } doSomething(item) } func doSomething(item *Item) { log.Println("Dequeued", item) } ``` -------------------------------- ### Install go-redis/v9 Source: https://github.com/grafana/loki/blob/main/vendor/github.com/redis/go-redis/v9/README.md Install the go-redis/v9 library using the go get command. ```shell go get github.com/redis/go-redis/v9 ``` -------------------------------- ### Setup In-memory Sink and Signal Handler Source: https://github.com/grafana/loki/blob/main/vendor/github.com/armon/go-metrics/README.md Example of setting up an in-memory sink and a signal handler for capturing and dumping recent metrics. ```go // Setup the inmem sink and signal handler inm := metrics.NewInmemSink(10*time.Second, time.Minute) sig := metrics.DefaultInmemSignal(inm) metrics.NewGlobal(metrics.DefaultConfig("service-name"), inm) ``` -------------------------------- ### Basic Parameter Expansion Example Source: https://github.com/grafana/loki/blob/main/vendor/github.com/mfridman/interpolate/README.md Demonstrates basic parameter expansion using environment variables. It shows how to define custom environment variables and use them within strings, including default values for unset variables. ```go package main import ( "github.com/mfridman/interpolate" "fmt" ) func main() { env := interpolate.NewSliceEnv([]string{ "NAME=James", }) output, _ := interpolate.Interpolate(env, "Hello... ${NAME} welcome to the ${ANOTHER_VAR:-🏖}") fmt.Println(output) // Output: Hello... James welcome to the 🏖 } ``` -------------------------------- ### Full Runnable Mux Server Example Source: https://github.com/grafana/loki/blob/main/vendor/github.com/gorilla/mux/README.md A complete, self-contained Go program demonstrating a basic web server using Gorilla Mux, including route definition and handler setup. ```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)) } ``` -------------------------------- ### Installing go-colorable Source: https://github.com/grafana/loki/blob/main/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 json-iterator/go Source: https://github.com/grafana/loki/blob/main/vendor/github.com/json-iterator/go/README.md Install the json-iterator/go library using the go get command. ```go go get github.com/json-iterator/go ``` -------------------------------- ### Install mapstructure Source: https://github.com/grafana/loki/blob/main/vendor/github.com/go-viper/mapstructure/v2/README.md Install the mapstructure library using the go get command. ```shell go get github.com/go-viper/mapstructure/v2 ``` -------------------------------- ### Install Dependencies and Run Tests Source: https://github.com/grafana/loki/blob/main/vendor/github.com/uber/jaeger-client-go/CONTRIBUTING.md After cloning the repository and initializing submodules, install project dependencies and run the test suite. This verifies your setup and ensures code quality. ```bash make install make test ``` -------------------------------- ### Install Locales Package Source: https://github.com/grafana/loki/blob/main/vendor/github.com/go-playground/locales/README.md Install the locales package using go get. ```shell go get github.com/go-playground/locales ``` -------------------------------- ### Install Mimetype Package Source: https://github.com/grafana/loki/blob/main/vendor/github.com/gabriel-vasile/mimetype/README.md Install the mimetype package using go get. ```bash go get github.com/gabriel-vasile/mimetype ``` -------------------------------- ### Install zombiezen.com/go/sqlite Source: https://github.com/grafana/loki/blob/main/vendor/zombiezen.com/go/sqlite/README.md Install the package using go get. Ensure you are building for a supported architecture, even though the library does not use CGo. ```shell go get zombiezen.com/go/sqlite ``` -------------------------------- ### Install Graphemes Package Source: https://github.com/grafana/loki/blob/main/vendor/github.com/clipperhouse/uax29/v2/graphemes/README.md Install the graphemes package using go get. ```bash go get github.com/clipperhouse/uax29/v2/graphemes ``` -------------------------------- ### Install Kingpin Source: https://github.com/grafana/loki/blob/main/vendor/github.com/alecthomas/kingpin/v2/README.md Install Kingpin v2 using the go get command. ```bash $ go get github.com/alecthomas/kingpin/v2 ``` -------------------------------- ### Validate Example Configurations Source: https://github.com/grafana/loki/blob/main/docs/sources/configure/examples/yaml/README.txt Run this command to verify the validity of example configurations. Validation is skipped for examples with the `# doc-example:skip-validation=true` comment. ```bash make validate-example-configs ``` -------------------------------- ### Build and Install miekg/dns Source: https://github.com/grafana/loki/blob/main/vendor/github.com/miekg/dns/README.md Instructions for building and installing the miekg/dns library using Go modules. ```bash go get github.com/miekg/dns go build github.com/miekg/dns ``` -------------------------------- ### Install gziphandler Source: https://github.com/grafana/loki/blob/main/vendor/github.com/NYTimes/gziphandler/README.md Install the gziphandler package using the go get command. ```bash go get -u github.com/NYTimes/gziphandler ``` -------------------------------- ### Install Mergo Source: https://github.com/grafana/loki/blob/main/vendor/dario.cat/mergo/README.md Install the Mergo library using go get. This command fetches and installs the latest version of the library. ```go go get dario.cat/mergo ``` -------------------------------- ### Install xk6 Extension Bundler Source: https://github.com/grafana/loki/blob/main/docs/sources/send-data/k6/_index.md Install the xk6 extension bundler using go install. ```bash go install go.k6.io/xk6/cmd/xk6@latest ``` -------------------------------- ### Installing Latest Version with Go Get Source: https://github.com/grafana/loki/blob/main/vendor/github.com/uber/jaeger-client-go/README.md This shell command sequence demonstrates how to install the latest version of the Jaeger client library using 'go get', followed by steps to update submodules and run 'make install' to resolve potential dependency issues. ```shell go get -u github.com/uber/jaeger-client-go/ cd $GOPATH/src/github.com/uber/jaeger-client-go/ git submodule update --init --recursive make install ``` -------------------------------- ### Install go.yaml.in/yaml/v3 Source: https://github.com/grafana/loki/blob/main/vendor/go.yaml.in/yaml/v3/README.md Install the YAML package for Go using the go get command. ```bash go get go.yaml.in/yaml/v3 ```