### Getting Started with Cat Library Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/olekukonko/cat/README.md Provides instructions for installing the Cat library using go get and demonstrates basic usage within a main function, including simple concatenation and pooled builders. ```bash go get github.com/your-repo/cat ``` ```go import "github.com/your-repo/cat" func main() { // Simple concatenation msg := cat.Concat("User ", userID, " has ", count, " items") // Pooled builder (for high-performance loops) builder := cat.New(", ") defer builder.Release() // Return to pool result := builder.Add(items...).String() } ``` -------------------------------- ### Install Objx Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/stretchr/objx/README.md Use `go get` to install the Objx package. ```bash go get github.com/stretchr/objx ``` -------------------------------- ### Install SSE Library Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/r3labs/sse/v2/README.md Use 'go get' to install the SSE library. ```bash go get github.com/r3labs/sse/v2 ``` -------------------------------- ### Install Now Package Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/jinzhu/now/README.md Install the 'now' package using the go get command. ```bash go get -u github.com/jinzhu/now ``` -------------------------------- ### Install GCache Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/bluele/gcache/README.md Use 'go get' to install the GCache library. ```bash $ go get github.com/bluele/gcache ``` -------------------------------- ### Install otelchi Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/riandyrn/otelchi/README.md Install the otelchi library using go get. ```bash $ go get github.com/riandyrn/otelchi ``` -------------------------------- ### Install go-ordered-map Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/wk8/go-ordered-map/README.md Install the library using the go get command. ```bash go get -u github.com/wk8/go-ordered-map ``` -------------------------------- ### Install Afero Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/spf13/afero/README.md Install the Afero library using the go get command. ```bash go get github.com/spf13/afero ``` -------------------------------- ### Install Blackfriday v2 Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/russross/blackfriday/v2/README.md Use `go get` to install the package. This command resolves and adds the package to your module, then builds and installs it. ```go go get github.com/russross/blackfriday/v2 ``` -------------------------------- ### Install displaywidth Package Source: https://github.com/opencloud-eu/opencloud/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 Match Package Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/tidwall/match/README.md Use 'go get' to install the latest version of the match package. ```bash go get -u github.com/tidwall/match ``` -------------------------------- ### Install and Import kubernetes-sigs/yaml Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/sigs.k8s.io/yaml/README.md Install the library using 'go get' and import it into your Go projects. ```bash go get sigs.k8s.io/yaml ``` ```go import "sigs.k8s.io/yaml" ``` -------------------------------- ### Install copystructure Go Library Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/mitchellh/copystructure/README.md Use standard go get to install the copystructure library. ```bash $ go get github.com/mitchellh/copystructure ``` -------------------------------- ### Quickstart: Basic Redis Operations Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/go-redis/redis/v8/README.md Demonstrates how to create a Redis client, set a key-value pair, and retrieve its value. Handles cases where a key does not exist. ```go import ( "context" "github.com/go-redis/redis/v8" "fmt" ) var ctx = context.Background() func ExampleClient() { rdb := redis.NewClient(&redis.Options{ Addr: "localhost:6379", Password: "", // no password set DB: 0, // use default DB }) err := rdb.Set(ctx, "key", "value", 0).Err() if err != nil { panic(err) } val, err := rdb.Get(ctx, "key").Result() if err != nil { panic(err) } fmt.Println("key", val) val2, err := rdb.Get(ctx, "key2").Result() if err == redis.Nil { fmt.Println("key2 does not exist") } else if err != nil { panic(err) } else { fmt.Println("key2", val2) } // Output: key value // key2 does not exist } ``` -------------------------------- ### Build All Examples Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/minio/minio-go/v7/CLAUDE.md Compile all example programs included in the repository. ```bash make examples ``` -------------------------------- ### Install gobwas/glob Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/gobwas/glob/readme.md Use 'go get' to install the library. ```shell go get github.com/gobwas/glob ``` -------------------------------- ### Basic Mux Server Setup Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/gorilla/mux/README.md Provides a complete, runnable example of a minimal HTTP server using Gorilla Mux. This demonstrates basic route definition and server startup. ```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 Yacspin Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/theckman/yacspin/README.md Install the yacspin package using go get. ```bash go get github.com/theckman/yacspin ``` -------------------------------- ### Basic Zero-copy Upgrade Example Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/gobwas/ws/README.md Demonstrates a simple zero-copy upgrade setup. Use this for basic integration where custom header processing is minimal. ```go package main import ( "net" "log" "github.com/gobwas/ws" ) func main() { ln, err := net.Listen("tcp", "localhost:8080") if err != nil { log.Fatal(err) } u := ws.Upgrader{ OnHeader: func(key, value []byte) (err error) { log.Printf("non-websocket header: %q=%q", key, value) return }, } for { conn, err := ln.Accept() if err != nil { // handle error } _, err = u.Upgrade(conn) if err != nil { // handle error } } } ``` -------------------------------- ### Web Server with Structured Logging Example Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/olekukonko/ll/README.md Example of setting up a web server with structured logging using ll. It demonstrates creating a root logger, configuring JSON output for production, and using a request logger with context. ```go package main import ( "github.com/olekukonko/ll" "github.com/olekukonko/ll/lh" "net/http" "time" ) func main() { // Root logger - enabled by default log := ll.New("server") // JSON output for production log.Handler(lh.NewJSONHandler(os.Stdout)) // Request logger with context http.HandleFunc("/api/users", func(w http.ResponseWriter, r *http.Request) { reqLog := log.Namespace("http").Fields( "method", r.Method, "path", r.URL.Path, "request_id", r.Header.Get("X-Request-ID"), ) start := time.Now() reqLog.Info("request started") // ... handle request ... reqLog.Fields( "status", 200, "duration_ms", time.Since(start).Milliseconds(), ).Info("request completed") }) log.Info("Server listening on :8080") http.ListenAndServe(":8080", nil) } ``` -------------------------------- ### Build a Specific Example Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/minio/minio-go/v7/CLAUDE.md Compile a specific example program. Navigate to the example's directory first. ```bash cd examples/s3 && go build -mod=mod putobject.go ``` -------------------------------- ### Install go-playground/locales Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/go-playground/locales/README.md Use 'go get' to install the locales package. ```shell go get github.com/go-playground/locales ``` -------------------------------- ### OpenCloud Runtime Example with Process Management Source: https://github.com/opencloud-eu/opencloud/blob/main/opencloud/pkg/runtime/README.md This Go example shows how to initialize and manage a service within the OpenCloud runtime. It includes starting a process, setting a shutdown timer, and handling termination signals. Run with RUNTIME_KEEP_ALIVE=true and without it to observe behavior differences. Requires an OpenCloud binary in your PATH. ```go package main import ( "fmt" "github.com/opencloud-eu/opencloud/opencloud/pkg/runtime/process" "github.com/opencloud-eu/opencloud/opencloud/pkg/runtime/service" "github.com/rs/zerolog/log" os" os/signal" syscall" time" ) func main() { s := service.NewService() var c = make(chan os.Signal, 1) var o int signal.Notify(c, syscall.SIGINT, syscall.SIGTERM) if err := s.Start(process.NewProcEntry("ocs", nil, "ocs"), &o); err != nil { os.Exit(1) } time.AfterFunc(3*time.Second, func() { var acc = "ocs" fmt.Printf(fmt.Sprintf("shutting down service: %s", acc)) if err := s.Controller.Kill(&acc); err != nil { log.Fatal() } os.Exit(0) }) for { select { case <-c: return } } } ``` -------------------------------- ### Run MinIO Go Example Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/minio/minio-go/v7/README.md Initializes the Go module, downloads the MinIO SDK dependencies, and runs the FileUploader Go program. ```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 ``` -------------------------------- ### Install Mergo Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/dario.cat/mergo/README.md Install the Mergo library using go get. ```go go get dario.cat/mergo ``` -------------------------------- ### Example Client Initialization and Resource Fetching Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/lestrrat-go/httprc/v3/README.md Demonstrates how to initialize an httprc client, configure it with options, start it, and add a new resource for asynchronous fetching. It shows how to handle potential errors and retrieve the fetched resource. ```go package httprc_test import ( "context" "encoding/json" "fmt" "net/http" "net/http/httptest" "time" "github.com/lestrrat-go/httprc/v3" ) func ExampleClient() { ctx, cancel := context.WithCancel(context.Background()) defer cancel() type HelloWorld struct { Hello string `json:"hello"` } srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { json.NewEncoder(w).Encode(map[string]string{"hello": "world"}) })) options := []httprc.NewClientOption{ // By default the client will allow all URLs (which is what the option // below is explicitly specifying). If you want to restrict what URLs // are allowed, you can specify another whitelist. // // httprc.WithWhitelist(httprc.NewInsecureWhitelist()), } // If you would like to handle errors from asynchronous workers, you can specify a error sink. // This is disabled in this example because the trace logs are dynamic // and thus would interfere with the runnable example test. // options = append(options, httprc.WithErrorSink(errsink.NewSlog(slog.New(slog.NewJSONHandler(os.Stdout, nil))))) // If you would like to see the trace logs, you can specify a trace sink. // This is disabled in this example because the trace logs are dynamic // and thus would interfere with the runnable example test. // options = append(options, httprc.WithTraceSink(tracesink.NewSlog(slog.New(slog.NewJSONHandler(os.Stdout, nil))))) // Create a new client cl := httprc.NewClient(options...) // Start the client, and obtain a Controller object ctrl, err := cl.Start(ctx) if err != nil { fmt.Println(err.Error()) return } // The following is required if you want to make sure that there are no // dangling goroutines hanging around when you exit. For example, if you // are running tests to check for goroutine leaks, you should call this // function before the end of your test. defer ctrl.Shutdown(time.Second) // Create a new resource that is synchronized every so often // // By default the client will attempt to fetch the resource once // as soon as it can, and then if no other metadata is provided, // it will fetch the resource every 15 minutes. // // If the resource responds with a Cache-Control/Expires header, // the client will attempt to respect that, and will try to fetch // the resource again based on the values obatained from the headers. r, err := httprc.NewResource[HelloWorld](srv.URL, httprc.JSONTransformer[HelloWorld]()) if err != nil { fmt.Println(err.Error()) return } // Add the resource to the controller, so that it starts fetching. // By default, a call to `Add()` will block until the first fetch // succeeds, via an implicit call to `r.Ready()` // You can change this behavior if you specify the `WithWaitReady(false)` // option. ctrl.Add(ctx, r) // if you specified `httprc.WithWaitReady(false)` option, the fetch will happen // "soon", but you're not guaranteed that it will happen before the next // call to `Lookup()`. // If you want to make sure that the resource is ready, you can call `Ready()` like so: /* { tctx, tcancel := context.WithTimeout(ctx, time.Second) defer tcancel() if err := r.Ready(tctx); err != nil { fmt.Println(err.Error()) return } } */ m := r.Resource() fmt.Println(m.Hello) // OUTPUT: // world } ``` -------------------------------- ### Install go-intersect Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/juliangruber/go-intersect/Readme.md Use go get to install the library. This command fetches and installs the specified package and its dependencies. ```bash $ go get github.com/juliangruber/go-intersect ``` -------------------------------- ### Create Test File (Windows) Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/minio/minio-go/v7/README.md Creates a dummy file named 'sample.txt' on the Desktop with 20KB of data. This is used for the file upload example. ```sh fsutil file createnew "C:\Users\\Desktop\sample.txt" 20480 ``` -------------------------------- ### Install GJSON Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/tidwall/gjson/README.md Install the GJSON library using the go get command. ```sh go get -u github.com/tidwall/gjson ``` -------------------------------- ### Initialize OpenSearch Client and Perform Basic Operations Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/opensearch-project/opensearch-go/v4/USER_GUIDE.md Demonstrates initializing the OpenSearch client with custom configuration, including SSL/TLS settings and authentication. It covers fetching cluster info, creating an index with specific settings, inserting a document, searching for it, deleting the document, and finally deleting the index. Includes error handling for resource existence and not found exceptions. ```go package main import ( "context" "crypto/tls" "errors" "fmt" "net/http" "os" "strings" "github.com/opensearch-project/opensearch-go/v4" "github.com/opensearch-project/opensearch-go/v4/opensearchapi" "github.com/opensearch-project/opensearch-go/v4/opensearchutil" ) const IndexName = "go-test-index1" func main() { if err := example(); err != nil { fmt.Printf("Error: %s\n", err) os.Exit(1) } } func example() error { // Initialize the client with SSL/TLS enabled. client, err := opensearchapi.NewClient( opensearchapi.Config{ Client: opensearch.Config{ Transport: &http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, // For testing only. Use certificate for validation. }, Addresses: []string{"https://localhost:9200"}, Username: "admin", // For testing only. Don't store credentials in code. Password: "myStrongPassword123!", }, }, ) if err != nil { return err } ctx := context.Background() // Print OpenSearch version information on console. infoResp, err := client.Info(ctx, nil) if err != nil { return err } fmt.Printf("Cluster INFO:\n Cluster Name: %s\n Cluster UUID: %s\n Version Number: %s\n", infoResp.ClusterName, infoResp.ClusterUUID, infoResp.Version.Number) // Define index mapping. // Note: these particular settings (eg, shards/replicas) // will have no effect in AWS OpenSearch Serverless mapping := strings.NewReader(`{ "settings": { "index": { "number_of_shards": 4 } } }`) // Create an index with non-default settings. createIndexResponse, err := client.Indices.Create( ctx, opensearchapi.IndicesCreateReq{ Index: IndexName, Body: mapping, }, ) var opensearchError *opensearch.StructError // Load err into opensearch.Error to access the fields and tolerate if the index already exists if err != nil { if errors.As(err, &opensearchError) { if opensearchError.Err.Type != "resource_already_exists_exception" { return err } } else { return err } } fmt.Printf("Created Index: %s\n Shards Acknowledged: %t\n", createIndexResponse.Index, createIndexResponse.ShardsAcknowledged) // When using a structure, the conversion process to io.Reader can be omitted using utility functions. document := struct { Title string `json:"title"` Director string `json:"director"` Year string `json:"year"` }{ Title: "Moneyball", Director: "Bennett Miller", Year: "2011", } docId := "1" insertResp, err := client.Index( ctx, opensearchapi.IndexReq{ Index: IndexName, DocumentID: docId, Body: opensearchutil.NewJSONReader(&document), Params: opensearchapi.IndexParams{ Refresh: "true", }, }, ) if err != nil { return err } fmt.Printf("Created document in %s\n ID: %s\n", insertResp.Index, insertResp.ID) // Search for the document. content := strings.NewReader(`{ "size": 5, "query": { "multi_match": { "query": "miller", "fields": ["title^2", "director"] } } }`) searchResp, err := client.Search( ctx, &opensearchapi.SearchReq{ Body: content, }, ) if err != nil { return err } fmt.Printf("Search hits: %v\n", searchResp.Hits.Total.Value) if searchResp.Hits.Total.Value > 0 { indices := make([]string, 0) for _, hit := range searchResp.Hits.Hits { add := true for _, index := range indices { if index == hit.Index { add = false } } if add { indices = append(indices, hit.Index) } } fmt.Printf("Search indices: %s\n", strings.Join(indices, ",")) } // Delete the document. deleteReq := opensearchapi.DocumentDeleteReq{ Index: IndexName, DocumentID: docId, } deleteResponse, err := client.Document.Delete(ctx, deleteReq) if err != nil { return err } fmt.Printf("Deleted document: %t\n", deleteResponse.Result == "deleted") // Delete previously created index. deleteIndex := opensearchapi.IndicesDeleteReq{Indices: []string{IndexName}}} deleteIndexResp, err := client.Indices.Delete(ctx, deleteIndex) if err != nil { return err } fmt.Printf("Deleted index: %t\n", deleteIndexResp.Acknowledged) // Try to delete the index again which fails as it does not exist _, err = client.Indices.Delete(ctx, deleteIndex) // Load err into opensearchapi.Error to access the fields and tolerate if the index is missing if err != nil { if errors.As(err, &opensearchError) { if opensearchError.Err.Type != "index_not_found_exception" { return err } } else { return err } } return nil } ``` -------------------------------- ### Install Go Color Library Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/fatih/color/README.md Use 'go get' to install the color library. This is the first step before using any of its features. ```bash go get github.com/fatih/color ``` -------------------------------- ### Install vfsgen Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/shurcooL/vfsgen/README.md Install the vfsgen package using the go get command. ```sh go get github.com/shurcooL/vfsgen ``` -------------------------------- ### Install goxmldsig Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/russellhaering/goxmldsig/README.md Install the goxmldsig library using the go get command. ```bash $ go get github.com/russellhaering/goxmldsig ``` -------------------------------- ### Install Zerolog Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/rs/zerolog/README.md Install the global logger package using go get. ```bash go get -u github.com/rs/zerolog/log ``` -------------------------------- ### Basic Go-Chi Router Setup Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/go-chi/chi/v5/README.md Demonstrates the minimal setup for a Go-Chi router with logging middleware and a simple GET route. ```go package main import ( "net/http" "github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" ) func main() { r := chi.NewRouter() r.Use(middleware.Logger) r.Get("/", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("welcome")) }) http.ListenAndServe(":3000", r) } ``` -------------------------------- ### Install json-iterator/go Source: https://github.com/opencloud-eu/opencloud/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 ``` -------------------------------- ### Initialize SSE Server Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/r3labs/sse/v2/README.md Create a new SSE server instance. ```go func main() { server := sse.New() } ``` -------------------------------- ### Install sysutil Package Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/gookit/goutil/sysutil/README.md Install the sysutil package using go get. ```bash go get github.com/gookit/goutil/sysutil ``` -------------------------------- ### Quickstart: Marshal and Unmarshal Data Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/vmihailenco/msgpack/v5/README.md A basic example demonstrating how to marshal a Go struct into MessagePack format and then unmarshal it back. This requires importing the msgpack library. ```go import "github.com/vmihailenco/msgpack/v5" func ExampleMarshal() { type Item struct { Foo string } b, err := msgpack.Marshal(&Item{Foo: "bar"}) if err != nil { panic(err) } var item Item err = msgpack.Unmarshal(b, &item) if err != nil { panic(err) } fmt.Println(item.Foo) // Output: bar } ``` -------------------------------- ### Install mathutil Package Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/gookit/goutil/mathutil/README.md Install the mathutil package using go get. ```bash go get github.com/gookit/goutil/mathutil ``` -------------------------------- ### Go CPU Information Example Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/klauspost/cpuid/v2/README.md Demonstrates how to access and print various CPU details like brand name, core counts, features, cache sizes, and frequency. It also shows how to check for specific CPU feature support. ```Go package main import ( "fmt" "strings" . "github.com/klauspost/cpuid/v2" ) func main() { // Print basic CPU information: fmt.Println("Name:", CPU.BrandName) fmt.Println("PhysicalCores:", CPU.PhysicalCores) fmt.Println("ThreadsPerCore:", CPU.ThreadsPerCore) fmt.Println("LogicalCores:", CPU.LogicalCores) fmt.Println("Family", CPU.Family, "Model:", CPU.Model, "Vendor ID:", CPU.VendorID) fmt.Println("Features:", strings.Join(CPU.FeatureSet(),",")) fmt.Println("Cacheline bytes:", CPU.CacheLine) fmt.Println("L1 Data Cache:", CPU.Cache.L1D, "bytes") fmt.Println("L1 Instruction Cache:", CPU.Cache.L1I, "bytes") fmt.Println("L2 Cache:", CPU.Cache.L2, "bytes") fmt.Println("L3 Cache:", CPU.Cache.L3, "bytes") fmt.Println("Frequency", CPU.Hz, "hz") // Test if we have these specific features: if CPU.Supports(SSE, SSE2) { fmt.Println("We have Streaming SIMD 2 Extensions") } } ``` -------------------------------- ### Install OpenCensus Go Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/go.opencensus.io/README.md Use `go get` to install the OpenCensus Go library. Vendoring or a dependency management tool is recommended. ```bash $ go get -u go.opencensus.io ``` -------------------------------- ### Install arrutil Package Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/gookit/goutil/arrutil/README.md Install the arrutil package using go get. ```shell go get github.com/gookit/goutil/arrutil ``` -------------------------------- ### Clone Repository Example Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/go-git/go-git/v5/COMPATIBILITY.md Demonstrates how to clone a repository. This example is referenced for plain clones and recurse submodules. ```go package main import ( "fmt" "log" "os" "github.com/go-git/go-git/v5" ) func main() { // Clone the repository to the current directory. _, err := git.PlainClone(".", false, &git.CloneOptions{ URL: "https://github.com/go-git/go-git", Progress: os.Stdout, }) if err != nil { log.Fatal(err) } fmt.Println("Repository cloned successfully.") } ``` -------------------------------- ### Install go-masker Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/ggwhite/go-masker/README.md Install the go-masker package using the go get command. ```bash $ go get -u github.com/ggwhite/go-masker ``` -------------------------------- ### Install gocloak Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/Nerzal/gocloak/v13/README.md Use `go get` to install the v13 of the gocloak package. ```shell go get github.com/Nerzal/gocloak/v13 ``` -------------------------------- ### Configured CLI Application with Action Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/urfave/cli/v2/godoc-current.txt Shows how to configure a basic CLI application with a name, usage string, and a simple action that prints 'Greetings'. ```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) } ``` -------------------------------- ### Create and Render a Simple Table Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/olekukonko/tablewriter/README.md Demonstrates how to create a basic table with headers and data, then render it to standard output using default settings. ```go package main import ( "fmt" "github.com/olekukonko/tablewriter" os" ) type Age int func (a Age) String() string { return fmt.Sprintf("%d yrs", a) } func main() { data := [][]any{ {"Alice", Age(25), "New York"}, {"Bob", Age(30), "Boston"}, } table := tablewriter.NewTable(os.Stdout) ttable.Header("Name", "Age", "City") ttable.Bulk(data) ttable.Render() } ``` -------------------------------- ### Install go-urn Library Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/leodido/go-urn/README.md Use 'go get' to install the go-urn library. This command fetches and installs the specified package. ```go go get github.com/leodido/go-urn ``` -------------------------------- ### App.Setup Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/urfave/cli/v2/godoc-current.txt Performs initialization to prepare data structures for running or inspection before `Run` is called. It's called internally by `Run` and will return early if setup has already occurred. ```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 TTLCache Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/jellydator/ttlcache/v3/README.md Use `go get` to install the TTLCache package. This command fetches and installs the latest version of the package. ```go go get github.com/jellydator/ttlcache/v3 ``` -------------------------------- ### Install uuid Package Source: https://github.com/opencloud-eu/opencloud/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. ```sh go get github.com/google/uuid ``` -------------------------------- ### Setup Ginkgo Development Environment Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/onsi/ginkgo/CONTRIBUTING.md Installs Ginkgo and Gomega, configures the remote repository, and runs initial tests and linting. Ensure you have Go installed and configured. ```bash go get github.com/onsi/ginkgo go get github.com/onsi/gomega/... cd $GOPATH/src/github.com/onsi/ginkgo git remote add fork git@github.com:/ginkgo.git ginkgo -r -p # ensure tests are green go vet ./... # ensure linter is happy ``` -------------------------------- ### Install flock Package Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/gofrs/flock/README.md Use go get to install the flock package. This command fetches and installs the latest version. ```bash go get -u github.com/gofrs/flock ``` -------------------------------- ### Create New Config Instances Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/gookit/config/v2/README.md Demonstrates various ways to create new configuration instances, including auto-registering drivers, creating empty instances, using generic options, and specifying custom options. ```go myConf := config.New("my-conf") myConf := config.NewEmpty("my-conf") myConf := config.NewGeneric("my-conf") myConf := config.NewWithOptions("my-conf", config.ParseEnv, config.ReadOnly) ``` -------------------------------- ### Initialize and Use BufferPool in Go Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/oxtoacart/bpool/README.md Demonstrates creating a BufferPool with a specified size and obtaining/returning buffers. Use this for managing bytes.Buffer instances. ```go var bufpool *bpool.BufferPool func main() { bufpool = bpool.NewBufferPool(48) } func someFunction() error { // Get a buffer from the pool buf := bufpool.Get() ... ... ... // Return the buffer to the pool bufpool.Put(buf) return nil } ``` -------------------------------- ### Install mapstructure Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/go-viper/mapstructure/v2/README.md Use go get to install the mapstructure library. This command fetches and installs the specified package and its dependencies. ```shell go get github.com/go-viper/mapstructure/v2 ``` -------------------------------- ### Install multierr Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/go.uber.org/multierr/README.md Use `go get` to install the latest version of the multierr package. ```bash go get -u go.uber.org/multierr@latest ``` -------------------------------- ### Standalone HTTP Server Setup Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/go-micro/plugins/v4/server/http/README.md Demonstrates how to create and run a standalone HTTP server using the go-micro HTTP server plugin. This is useful for services that primarily expose RESTful APIs. ```go import ( "net/http" "github.com/micro/go-micro/server" httpServer "github.com/go-micro/plugins/v4/server/http" ) func main() { srv := httpServer.NewServer( server.Name("helloworld"), ) mux := http.NewServeMux() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte(`hello world`)) }) hd := srv.NewHandler(mux) srv.Handle(hd) srv.Start() srv.Register() } ``` -------------------------------- ### Install Locafero Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/sagikazarmark/locafero/README.md Use this command to install the Locafero library using go get. ```shell go get github.com/sagikazarmark/locafero ``` -------------------------------- ### Start OpenCloud Runtime Source: https://github.com/opencloud-eu/opencloud/blob/main/opencloud/pkg/runtime/README.md This Go code snippet demonstrates how to start the OpenCloud runtime service. Ensure the necessary imports are included. ```go package main import "github.com/opencloude-eu/opencloud/opencloud/pkg/runtime/service" func main() { service.Start() } ``` -------------------------------- ### Install msgpack/v5 Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/vmihailenco/msgpack/v5/README.md Install the msgpack/v5 library using go get. Ensure you are using Go modules and have initialized your project with `go mod init`. ```shell go mod init github.com/my/repo ``` ```shell go get github.com/vmihailenco/msgpack/v5 ``` -------------------------------- ### Install concurrent-map Package Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/orcaman/concurrent-map/README.md Use 'go get' to install the concurrent-map package into your project. ```bash go get "github.com/orcaman/concurrent-map" ``` -------------------------------- ### Run Command with Pty Source: https://github.com/opencloud-eu/opencloud/blob/main/tests/ocwrapper/vendor/github.com/creack/pty/README.md This example demonstrates how to start a command with a pseudo-terminal and interact with it by writing input and reading output. It's intended for demonstration purposes. ```go package main import ( "io" "os" "os/exec" "github.com/creack/pty" ) func main() { c := exec.Command("grep", "--color=auto", "bar") f, err := pty.Start(c) if err != nil { panic(err) } go func() { f.Write([]byte("foo\n")) f.Write([]byte("bar\n")) f.Write([]byte("baz\n")) f.Write([]byte{4}) // EOT }() io.Copy(os.Stdout, f) } ``` -------------------------------- ### Install Gotext Package Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/leonelquinteros/gotext/README.md Use 'go get' to install the gotext package into your project. ```bash go get github.com/leonelquinteros/gotext ``` -------------------------------- ### Install go-isatty Package Source: https://github.com/opencloud-eu/opencloud/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 ``` -------------------------------- ### Basic Authentication Example Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/opencloud-eu/libre-graph-api-go/README.md Shows how to configure HTTP basic authentication by providing username and password within the context. ```go auth := context.WithValue(context.Background(), libregraph.ContextBasicAuth, libregraph.BasicAuth{ UserName: "username", Password: "password", }) r, err := client.Service.Operation(auth, args) ``` -------------------------------- ### Install Goutil X GoInfo Source: https://github.com/opencloud-eu/opencloud/blob/main/vendor/github.com/gookit/goutil/x/goinfo/README.md Use 'go get' to install the goinfo package. ```bash go get github.com/gookit/goutil/x/goinfo ```