### Install and Test Go OLE Source: https://github.com/datarhei/core/blob/main/vendor/github.com/go-ole/go-ole/README.md Instructions for installing the go-ole library and running tests. Includes an example of how to run a specific 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 ``` -------------------------------- ### Install xid Library Source: https://github.com/datarhei/core/blob/main/vendor/github.com/rs/xid/README.md Use 'go get' to install the xid library. This command fetches and installs the specified package. ```bash go get github.com/rs/xid ``` -------------------------------- ### Install go-isatty Package Source: https://github.com/datarhei/core/blob/main/vendor/github.com/mattn/go-isatty/README.md Install the go-isatty package using the go get command. ```bash $ go get github.com/mattn/go-isatty ``` -------------------------------- ### Install multierr Source: https://github.com/datarhei/core/blob/main/vendor/go.uber.org/multierr/README.md Use 'go get' to install the latest version of the multierr library. ```bash go get -u go.uber.org/multierr@latest ``` -------------------------------- ### Install miekg/dns Library Source: https://github.com/datarhei/core/blob/main/vendor/github.com/miekg/dns/README.md Use the go get command to download and install the library. Building is done with the go build command. ```bash go get github.com/miekg/dns go build github.com/miekg/dns ``` -------------------------------- ### Install Go Glob Library Source: https://github.com/datarhei/core/blob/main/vendor/github.com/gobwas/glob/readme.md Use 'go get' to install the library. Ensure your Go environment is set up correctly. ```shell go get github.com/gobwas/glob ``` -------------------------------- ### Basic Echo Server Example Source: https://github.com/datarhei/core/blob/main/vendor/github.com/labstack/echo/v4/README.md This example demonstrates how to create a basic Echo web server, including setting up essential middleware like Logger and Recover, defining a root route, and starting the server. ```go package main import ( "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" "net/http" ) func main() { // Echo instance e := echo.New() // Middleware e.Use(middleware.Logger()) e.Use(middleware.Recover()) // Routes e.GET("/", hello) // Start server e.Logger.Fatal(e.Start(":1323")) } // Handler func hello(c echo.Context) error { return c.String(http.StatusOK, "Hello, World!") } ``` -------------------------------- ### Install Go Locales Source: https://github.com/datarhei/core/blob/main/vendor/github.com/go-playground/locales/README.md Use 'go get' to install the library. The library returns []byte for efficiency when concatenating with larger text bodies. ```shell go get github.com/go-playground/locales ``` -------------------------------- ### Install go-m1cpu Package Source: https://github.com/datarhei/core/blob/main/vendor/github.com/shoenig/go-m1cpu/README.md Use 'go get' to install the latest version of the go-m1cpu library. ```shell go get github.com/shoenig/go-m1cpu@latest ``` -------------------------------- ### Install gojsonschema Source: https://github.com/datarhei/core/blob/main/vendor/github.com/xeipuuv/gojsonschema/README.md Use go get to install the gojsonschema library. ```bash go get github.com/xeipuuv/gojsonschema ``` -------------------------------- ### Get Object Example Source: https://github.com/datarhei/core/blob/main/vendor/github.com/minio/minio-go/v7/README.md Demonstrates how to download an object from MinIO storage. Ensure the MinIO client is initialized and the object exists. ```go package main import ( "context" "log" "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" ) func main() { ctx := context.Background() // Initialize minio client object. minioClient, err := minio.New("localhost:9000", &minio.Options{ Creds: credentials.NewStaticV4("minioadmin", "minioadmin", ""), Secure: false, }) if err != nil { log.Fatalln(err) } // The object to be downloaded. objectName := "my-object" // The file to save the object to. filePath := "./downloaded-object.txt" // Download the object with FGetObject. // The object is downloaded with the same path as the file name. err = minioClient.FPutObject(ctx, "my-bucket", objectName, filePath, minio.PutObjectOptions{}) if err != nil { log.Fatalln(err) } log.Printf("Successfully downloaded %s to %s\n", objectName, filePath) } ``` -------------------------------- ### Install gommon/color Package Source: https://github.com/datarhei/core/blob/main/vendor/github.com/labstack/gommon/color/README.md Use 'go get' to install the gommon/color package for your project. ```sh go get github.com/labstack/gommon/color ``` -------------------------------- ### Install Levenshtein Package Source: https://github.com/datarhei/core/blob/main/vendor/github.com/agnivade/levenshtein/README.md Use 'go get' to install the levenshtein package. Ensure your Go environment is set up. ```bash go get github.com/agnivade/levenshtein ``` -------------------------------- ### Install CertMagic Source: https://github.com/datarhei/core/blob/main/vendor/github.com/caddyserver/certmagic/README.md Use 'go get' to install the CertMagic library. Ensure you have Go 1.21 or newer installed. ```bash $ go get github.com/caddyserver/certmagic ``` -------------------------------- ### Install depth CLI Source: https://github.com/datarhei/core/blob/main/vendor/github.com/KyleBanks/depth/README.md Use 'go get' to install the depth command-line tool. This command fetches and installs the executable for the depth tool. ```sh go get github.com/KyleBanks/depth/cmd/depth ``` -------------------------------- ### Install Validator Package Source: https://github.com/datarhei/core/blob/main/vendor/github.com/go-playground/validator/v10/README.md Use 'go get' to install the validator package. Then import it into your Go code. ```go go get github.com/go-playground/validator/v10 ``` ```go import "github.com/go-playground/validator/v10" ``` -------------------------------- ### Install and Import YAML Package Source: https://github.com/datarhei/core/blob/main/vendor/github.com/ghodss/yaml/README.md Install the package using go get and import it into your Go project. ```bash $ go get github.com/ghodss/yaml ``` ```go import "github.com/ghodss/yaml" ``` -------------------------------- ### Install GoDotEnv Library Source: https://github.com/datarhei/core/blob/main/vendor/github.com/joho/godotenv/README.md Use 'go get' to add the godotenv library to your Go project. ```shell go get github.com/joho/godotenv ``` -------------------------------- ### Install Universal Translator Source: https://github.com/datarhei/core/blob/main/vendor/github.com/go-playground/universal-translator/README.md Use 'go get' to install the Universal Translator library. ```shell go get github.com/go-playground/universal-translator ``` -------------------------------- ### Install mapstructure Go Library Source: https://github.com/datarhei/core/blob/main/vendor/github.com/mitchellh/mapstructure/README.md Use standard go get to install the mapstructure library. This is the initial step before using its decoding functionalities. ```bash go get github.com/mitchellh/mapstructure ``` -------------------------------- ### Install uuid Package Source: https://github.com/datarhei/core/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 ``` -------------------------------- ### Start gqlgen GraphQL Server Source: https://github.com/datarhei/core/blob/main/vendor/github.com/99designs/gqlgen/README.md Runs the main server file to start the GraphQL server. This command assumes your server logic is in 'server.go'. ```bash go run server.go ``` -------------------------------- ### Install Echo Framework Source: https://github.com/datarhei/core/blob/main/vendor/github.com/labstack/echo/v4/README.md Use `go get` to install the latest version of the Echo framework. Ensure you are using a Go version compatible with the last four Go major releases. ```sh // go get github.com/labstack/echo/{version} go get github.com/labstack/echo/v4 ``` -------------------------------- ### Install blackfriday-tool Source: https://github.com/datarhei/core/blob/main/vendor/github.com/russross/blackfriday/v2/README.md Download and install the `blackfriday-tool` command-line utility using `go get`. This tool provides a standalone way to process markdown files. ```bash go get github.com/russross/blackfriday-tool ``` -------------------------------- ### Full Echo JWT Example Source: https://github.com/datarhei/core/blob/main/vendor/github.com/labstack/echo-jwt/README.md A complete Go program demonstrating the setup and usage of Echo JWT middleware, including logger, recover, JWT configuration, and a sample route. ```go package main import ( "errors" "github.com/golang-jwt/jwt/v4" "github.com/labstack/echo-jwt" "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" "log" "net/http" ) func main() { e := echo.New() e.Use(middleware.Logger()) e.Use(middleware.Recover()) e.Use(echojwt.WithConfig(echojwt.Config{ SigningKey: []byte("secret"), })) e.GET("/", func(c echo.Context) error { token, ok := c.Get("user").(*jwt.Token) // by default token is stored under `user` key if !ok { return errors.New("JWT token missing or invalid") } claims, ok := token.Claims.(jwt.MapClaims) // by default claims is of type `jwt.MapClaims` if !ok { return errors.New("failed to cast claims as jwt.MapClaims") } return c.JSON(http.StatusOK, claims) }) if err := e.Start(":8080"); err != http.ErrServerClosed { log.Fatal(err) } } ``` -------------------------------- ### Install goccy/go-json Source: https://github.com/datarhei/core/blob/main/vendor/github.com/goccy/go-json/README.md Use 'go get' to install the goccy/go-json library. This is the primary method for adding the package to your Go project. ```go go get github.com/goccy/go-json ``` -------------------------------- ### Install Go YAML Package Source: https://github.com/datarhei/core/blob/main/vendor/gopkg.in/yaml.v3/README.md Install the yaml package for Go using the go get command. ```bash go get gopkg.in/yaml.v3 ``` -------------------------------- ### Install HaikunatorGO Source: https://github.com/datarhei/core/blob/main/vendor/github.com/atrox/haikunatorgo/v2/README.md Use 'go get' to install the HaikunatorGO library for your Go project. ```bash go get github.com/atrox/haikunatorgo ``` -------------------------------- ### Download MinIO Go Client SDK Source: https://github.com/datarhei/core/blob/main/vendor/github.com/minio/minio-go/v7/README.md Use `go get` to download and install the MinIO Go Client SDK version 7. Ensure you are in your project directory. ```sh go get github.com/minio/minio-go/v7 ``` -------------------------------- ### Install GoSRT Source: https://github.com/datarhei/core/blob/main/vendor/github.com/datarhei/gosrt/README.md Install the GoSRT library using the go get command. A Go version of 1.18+ is required. ```shell go get github.com/datarhei/gosrt ``` -------------------------------- ### Install Mimetype Package Source: https://github.com/datarhei/core/blob/main/vendor/github.com/gabriel-vasile/mimetype/README.md Use 'go get' to install the mimetype package for your Go project. ```bash go get github.com/gabriel-vasile/mimetype ``` -------------------------------- ### SRT Listener Example Source: https://github.com/datarhei/core/blob/main/vendor/github.com/datarhei/gosrt/README.md Example of setting up an SRT listener and accepting incoming connections. The Accept function requires a callback to handle connection requests, determining whether to PUBLISH, SUBSCRIBE, or REJECT. ```go import "github.com/datarhei/gosrt" ln, err := srt.Listen("srt", ":6000", srt.Config{...}) if err != nil { // handle error } for { conn, mode, err := ln.Accept(func(req ConnRequest) ConnType { // check connection request return srt.REJECT }) if err != nil { // handle error } if mode == srt.REJECT { // rejected connection, ignore continue } if mode == srt.PUBLISH { go handlePublish(conn) } else { // srt.SUBSCRIBE go handleSubscribe(conn) } } ``` -------------------------------- ### Install GoDotEnv Command-Line Tool (Go < 1.17) Source: https://github.com/datarhei/core/blob/main/vendor/github.com/joho/godotenv/README.md Install the godotenv command-line tool using 'go get' for Go versions prior to 1.17. ```shell go get github.com/joho/godotenv/cmd/godotenv ``` -------------------------------- ### Install Swag CLI Source: https://github.com/datarhei/core/blob/main/vendor/github.com/swaggo/echo-swagger/README.md Download and install the Swag command-line interface for Go. Use 'go install' for Go 1.16 or newer. ```sh $ go get -d github.com/swaggo/swag/cmd/swag # 1.16 or newer $ go install github.com/swaggo/swag/cmd/swag@latest ``` -------------------------------- ### Install go-colorable Package Source: https://github.com/datarhei/core/blob/main/vendor/github.com/mattn/go-colorable/README.md Install the go-colorable package using the go get command. This is the standard method for adding external Go packages to your project. ```bash $ go get github.com/mattn/go-colorable ``` -------------------------------- ### File Get Object Example Source: https://github.com/datarhei/core/blob/main/vendor/github.com/minio/minio-go/v7/README.md Downloads an object from a MinIO bucket to a local file using the Go client. Ensure the object exists and the bucket is accessible. ```go package main import ( "fmt" "log" "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" ) func main() { // All services are accessible via the S3 API. Endpoint // has to be described with endpoint in the form of // "play.min.io" or "192.168.1.210:9000". // NOTE: Dedicated endpoint is recommended. Use this only for development. endpoint := "localhost:9000" // A list of region names that are valid for MinIO. // For example "us-east-1". region := "" // Use a hard-coded access key and secret key for testing purposes. // For production, use environment variables or AWS credentials file. accessKeyID := "minioadmin" secretAccessKey := "minioadmin" // Force use of TLS (https) to communicate with MinIO Server. // Set to false if you are using HTTP instead of HTTPS. useSSL := true // Create a client with the MinIO Go SDK - it won't work without the IO object being initialized. minioClient, err := minio.New(endpoint, &minio.Options{ Creds: credentials.NewStaticV4(accessKeyID, secretAccessKey, ""), Secure: useSSL, }) if err != nil { log.Fatalln(err) } // Download the zip file // bucketName := "mybucket" // objectName := "my_archive.zip" // downloadPath := "./my_archive.zip" // // Download the file with FGetObject // err = minioClient.FGetObject(bucketName, objectName, downloadPath, minio.GetObjectOptions{}) // if err != nil { // log.Fatalln(err) // } // fmt.Printf("Successfully downloaded %s to %s\n", objectName, downloadPath) } ``` -------------------------------- ### Install go-urn Library Source: https://github.com/datarhei/core/blob/main/vendor/github.com/leodido/go-urn/README.md Use this command to install the go-urn library for your Go project. ```bash go get github.com/leodido/go-urn ``` -------------------------------- ### Install Blackfriday v2 Package Source: https://github.com/datarhei/core/blob/main/vendor/github.com/russross/blackfriday/v2/README.md Use `go get` to install the Blackfriday v2 package. This command resolves and adds the package to your development module. ```bash go get github.com/russross/blackfriday/v2 ``` -------------------------------- ### Install GoDotEnv Command-Line Tool (Go >= 1.17) Source: https://github.com/datarhei/core/blob/main/vendor/github.com/joho/godotenv/README.md Install the godotenv command-line tool using 'go install' for Go versions 1.17 and above. ```shell go install github.com/joho/godotenv/cmd/godotenv@latest ``` -------------------------------- ### Canonical echo-swagger Example Source: https://github.com/datarhei/core/blob/main/vendor/github.com/swaggo/echo-swagger/README.md A complete example demonstrating how to integrate echo-swagger into an Echo application. Ensure the generated docs package is imported. ```go package main import ( "github.com/labstack/echo/v4" "github.com/swaggo/echo-swagger" _ "github.com/swaggo/echo-swagger/example/docs" // docs is generated by Swag CLI, you have to import it. ) // @title Swagger Example API // @version 1.0 // @description This is a sample server Petstore server. // @termsOfService http://swagger.io/terms/ // @contact.name API Support // @contact.url http://www.swagger.io/support // @contact.email support@swagger.io // @license.name Apache 2.0 // @license.url http://www.apache.org/licenses/LICENSE-2.0.html // @host petstore.swagger.io // @BasePath /v2 func main() { e := echo.New() e.GET("/swagger/*", echoSwagger.WrapHandler) e.Logger.Fatal(e.Start(":1323")) } ``` -------------------------------- ### Install Swag via Go Modules Source: https://github.com/datarhei/core/blob/main/vendor/github.com/swaggo/swag/README.md Install the Swag CLI tool using the go install command. Ensure you have Go 1.18 or newer. ```sh go install github.com/swaggo/swag/cmd/swag@latest ``` -------------------------------- ### Setup zap Repository Source: https://github.com/datarhei/core/blob/main/vendor/go.uber.org/zap/CONTRIBUTING.md Clone the zap repository and set up the upstream remote for contributing. ```bash mkdir -p $GOPATH/src/go.uber.org cd $GOPATH/src/go.uber.org git clone git@github.com:your_github_username/zap.git cd zap git remote add upstream https://github.com/uber-go/zap.git git fetch upstream ``` -------------------------------- ### Install s2 Commandline Tools Source: https://github.com/datarhei/core/blob/main/vendor/github.com/klauspost/compress/s2/README.md Installs the s2 compression and decompression command-line tools globally. Requires Go to be installed. ```bash go install github.com/klauspost/compress/s2/cmd/s2c@latest && go install github.com/klauspost/compress/s2/cmd/s2d@latest ``` -------------------------------- ### Install echo-swagger Source: https://github.com/datarhei/core/blob/main/vendor/github.com/swaggo/echo-swagger/README.md Download the echo-swagger middleware for your Go project. ```sh $ go get -u github.com/swaggo/echo-swagger ``` -------------------------------- ### Make Bucket Example Source: https://github.com/datarhei/core/blob/main/vendor/github.com/minio/minio-go/v7/README.md Demonstrates how to create a new bucket using the MinIO Go client library. ```go package main import ( "fmt" "log" "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" ) func main() { // All services are accessible via the S3 API. Endpoint // has to be described with endpoint in the form of // "play.min.io" or "192.168.1.210:9000". // NOTE: Dedicated endpoint is recommended. Use this only for development. endpoint := "localhost:9000" // A list of region names that are valid for MinIO. // For example "us-east-1". region := "" // Use a hard-coded access key and secret key for testing purposes. // For production, use environment variables or AWS credentials file. accessKeyID := "minioadmin" secretAccessKey := "minioadmin" // Force use of TLS (https) to communicate with MinIO Server. // Set to false if you are using HTTP instead of HTTPS. useSSL := true // Create a client with the MinIO Go SDK - it won't work without the IO object being initialized. minioClient, err := minio.New(endpoint, &minio.Options{ Creds: credentials.NewStaticV4(accessKeyID, secretAccessKey, ""), Secure: useSSL, }) if err != nil { log.Fatalln(err) } // Make a bucket with the MinIO Go object storage server, MakeBucket API is deprecated, use MakeBucketWithContext API instead. //bucketName := "mybucket" //location := "us-east-1" // Make a bucket with bucket-specific policies. err = minioClient.MakeBucket("mybucket", "us-east-1") if err != nil { // Indicate that we are using the object already. // See http://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html // for more error information. // if e, ok := err.(minio.ErrorResponse); ok && e.Code == "BucketAlreadyOwnedByYou" { // fmt.Printf("Bucket already exists and you own it, cannot create another bucket.") // } else { log.Fatalln(err) // } log.Fatalln(err) } fmt.Printf("Successfully created %s\n", "mybucket") } ``` -------------------------------- ### Struct Example Values Source: https://github.com/datarhei/core/blob/main/vendor/github.com/swaggo/swag/README_zh-CN.md Shows how to provide example values for struct fields directly within the Go struct definition. ```APIDOC ## Struct Example Values This section demonstrates how to add example values to struct fields using the `example` tag in Go. **Example Go Struct:** ```go type Account struct { ID int `json:"id" example:"1"` Name string `json:"name" example:"account name"` PhotoUrls []string `json:"photo_urls" example:"http://test/image/1.jpg,http://test/image/2.jpg"` } ``` This allows the documentation generator to include these examples in the API documentation for the `Account` struct. ``` -------------------------------- ### List Buckets Example Source: https://github.com/datarhei/core/blob/main/vendor/github.com/minio/minio-go/v7/README.md Demonstrates how to list all buckets in an MinIO storage system using the Go client. ```go package main import ( "fmt" "log" "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" ) func main() { // All services are accessible via the S3 API. Endpoint // has to be described with endpoint in the form of // "play.min.io" or "192.168.1.210:9000". // NOTE: Dedicated endpoint is recommended. Use this only for development. endpoint := "localhost:9000" // A list of region names that are valid for MinIO. // For example "us-east-1". region := "" // Use a hard-coded access key and secret key for testing purposes. // For production, use environment variables or AWS credentials file. accessKeyID := "minioadmin" secretAccessKey := "minioadmin" // Force use of TLS (https) to communicate with MinIO Server. // Set to false if you are using HTTP instead of HTTPS. useSSL := true // Create a client with the MinIO Go SDK - it won't work without the IO object being initialized. minioClient, err := minio.New(endpoint, &minio.Options{ Creds: credentials.NewStaticV4(accessKeyID, secretAccessKey, ""), Secure: useSSL, }) if err != nil { log.Fatalln(err) } // List buckets with the MinIO Go object storage server. // bucketLists, err := minioClient.ListBuckets() // if err != nil { // log.Fatalln(err) // } // for _, bucket := range bucketLists { // fmt.Printf("%+v\n", bucket) // } } ``` -------------------------------- ### Initialize Go Module Source: https://github.com/datarhei/core/blob/main/vendor/github.com/99designs/gqlgen/README.md Sets up a new Go module for your project. This is the first step before adding dependencies. ```bash mkdir example cd example go mod init example ``` -------------------------------- ### Basic CLI Application with Action Source: https://github.com/datarhei/core/blob/main/vendor/github.com/urfave/cli/v2/godoc-current.txt Shows how to create a functional CLI application with a name, usage description, and a simple action to be executed. The action prints a greeting and returns nil. ```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 Bytes Package Source: https://github.com/datarhei/core/blob/main/vendor/github.com/labstack/gommon/bytes/README.md Use 'go get' to install the bytes package from the gommon library. ```go go get github.com/labstack/gommon/bytes ``` -------------------------------- ### Show Command Help Source: https://github.com/datarhei/core/blob/main/vendor/github.com/urfave/cli/v2/godoc-current.txt Prints help information for the specified command. ```go func ShowCommandHelp(ctx *Context, command string) error ``` -------------------------------- ### Run MinIO Go File Upload Example Source: https://github.com/datarhei/core/blob/main/vendor/github.com/minio/minio-go/v7/README.md Execute these commands in your terminal to initialize the Go module, download the necessary MinIO SDK packages, and run the file upload 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 ``` -------------------------------- ### Minimal CLI Application Source: https://github.com/datarhei/core/blob/main/vendor/github.com/urfave/cli/v2/godoc-current.txt Demonstrates the most basic structure for a CLI application using the cli package. It initializes an empty app and runs it with provided arguments. ```go func main() { (&cli.App{}).Run(os.Args) } ``` -------------------------------- ### Initialize gqlgen Configuration Source: https://github.com/datarhei/core/blob/main/vendor/github.com/99designs/gqlgen/README.md Initializes the gqlgen configuration file and generates necessary models. Ensure you run 'go mod tidy' after this step. ```bash go run github.com/99designs/gqlgen init go mod tidy ``` -------------------------------- ### Run Benchmarks Source: https://github.com/datarhei/core/blob/main/vendor/github.com/goccy/go-json/README.md Navigate to the 'benchmarks' directory and run 'go test -bench .' to execute the performance benchmarks for the library. ```bash cd benchmarks go test -bench . ``` -------------------------------- ### Presigned Get Object Example Source: https://github.com/datarhei/core/blob/main/vendor/github.com/minio/minio-go/v7/README.md Generates a presigned URL for GET requests, allowing temporary access to an object without authentication. Requires an initialized MinIO client. ```go package main import ( "context" "log" "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" ) func main() { ctx := context.Background() // Initialize minio client object. minioClient, err := minio.New("localhost:9000", &minio.Options{ Creds: credentials.NewStaticV4("minioadmin", "minioadmin", ""), Secure: false, }) if err != nil { log.Fatalln(err) } // Generate a presigned GET object URL. // The URL will be valid for 1 hour. presignedURL, err := minioClient.PresignedGetObject(ctx, "my-bucket", "my-object", 60*60, nil) if err != nil { log.Fatalln(err) } log.Printf("Presigned URL for GET object: %s\n", presignedURL) } ``` -------------------------------- ### Show Subcommand Help Source: https://github.com/datarhei/core/blob/main/vendor/github.com/urfave/cli/v2/godoc-current.txt Prints help information for the specified subcommand. ```go func ShowSubcommandHelp(cCtx *Context) error ``` -------------------------------- ### Get Encrypted Object Example Source: https://github.com/datarhei/core/blob/main/vendor/github.com/minio/minio-go/v7/README.md Downloads an object from MinIO storage that was encrypted with server-side encryption. Requires an initialized MinIO client. ```go package main import ( "context" "log" "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" ) func main() { ctx := context.Background() // Initialize minio client object. minioClient, err := minio.New("localhost:9000", &minio.Options{ Creds: credentials.NewStaticV4("minioadmin", "minioadmin", ""), Secure: false, }) if err != nil { log.Fatalln(err) } // The object to be downloaded. objectName := "my-encrypted-object" // The file to save the object to. filePath := "./downloaded-encrypted-object.txt" // Download the object with FGetObject. // MinIO automatically handles decryption if server-side encryption was used. err = minioClient.FPutObject(ctx, "my-bucket", objectName, filePath, minio.PutObjectOptions{}) if err != nil { log.Fatalln(err) } log.Printf("Successfully downloaded %s to %s\n", objectName, filePath) } ``` -------------------------------- ### Get Bucket Policy Example Source: https://github.com/datarhei/core/blob/main/vendor/github.com/minio/minio-go/v7/README.md Retrieves the policy for a specified bucket from MinIO storage using the Go client. Returns an error if the bucket has no policy. ```go package main import ( "fmt" "log" "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" ) func main() { // All services are accessible via the S3 API. Endpoint // has to be described with endpoint in the form of // "play.min.io" or "192.168.1.210:9000". // NOTE: Dedicated endpoint is recommended. Use this only for development. endpoint := "localhost:9000" // A list of region names that are valid for MinIO. // For example "us-east-1". region := "" // Use a hard-coded access key and secret key for testing purposes. // For production, use environment variables or AWS credentials file. accessKeyID := "minioadmin" secretAccessKey := "minioadmin" // Force use of TLS (https) to communicate with MinIO Server. // Set to false if you are using HTTP instead of HTTPS. useSSL := true // Create a client with the MinIO Go SDK - it won't work without the IO object being initialized. minioClient, err := minio.New(endpoint, &minio.Options{ Creds: credentials.NewStaticV4(accessKeyID, secretAccessKey, ""), Secure: useSSL, }) if err != nil { log.Fatalln(err) } // Get bucket policy. // bucketName := "mybucket" // policy, err := minioClient.GetBucketPolicy(bucketName) // if err != nil { // log.Fatalln(err) // } // fmt.Printf("Bucket policy for %s: %s\n", bucketName, policy) } ``` -------------------------------- ### Put Object Example Source: https://github.com/datarhei/core/blob/main/vendor/github.com/minio/minio-go/v7/README.md Demonstrates how to upload an object to MinIO storage. Ensure the MinIO client is initialized. ```go package main import ( "context" "log" "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" ) func main() { // All bucket and object operations can be performed by creating a client object. // The client requires to be given your MinIO string endpoint // and access key. The region is optional. // A background context type, with the public error, deadline, value, and cancel types ctx := context.Background() // Initialize minio client object. // The default region is 'us-east-1'. // If you want to use MinIO, you need to replace the endpoint and credentials. // For example: // minioClient, err := minio.New("play.min.io", &minio.Options{ // Creds: credentials.NewStaticV4("YOUR-ACCESSKEYID", "YOURSECRETACCESSKEY", ""), // Secure: true, // }) // For local testing, you can use the following: minioClient, err := minio.New("localhost:9000", &minio.Options{ Creds: credentials.NewStaticV4("minioadmin", "minioadmin", ""), Secure: false, }) if err != nil { log.Fatalln(err) } // The object to be uploaded. objectName := "my-object" // The file to be uploaded. filePath := "./my-file.txt" // Upload the file with FPutObject // The object is uploaded with the same path as the file name. info, err := minioClient.FPutObject(ctx, "my-bucket", objectName, filePath, minio.PutObjectOptions{}) if err != nil { log.Fatalln(err) } log.Printf("Successfully uploaded %s of size %d\n", objectName, info.Size) } ``` -------------------------------- ### Get Bucket Notification Example Source: https://github.com/datarhei/core/blob/main/vendor/github.com/minio/minio-go/v7/README.md Retrieves the notification configuration for a specified bucket from MinIO storage using the Go client. Returns an error if no notification is configured. ```go package main import ( "fmt" "log" "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" ) func main() { // All services are accessible via the S3 API. Endpoint // has to be described with endpoint in the form of // "play.min.io" or "192.168.1.210:9000". // NOTE: Dedicated endpoint is recommended. Use this only for development. endpoint := "localhost:9000" // A list of region names that are valid for MinIO. // For example "us-east-1". region := "" // Use a hard-coded access key and secret key for testing purposes. // For production, use environment variables or AWS credentials file. accessKeyID := "minioadmin" secretAccessKey := "minioadmin" // Force use of TLS (https) to communicate with MinIO Server. // Set to false if you are using HTTP instead of HTTPS. useSSL := true // Create a client with the MinIO Go SDK - it won't work without the IO object being initialized. minioClient, err := minio.New(endpoint, &minio.Options{ Creds: credentials.NewStaticV4(accessKeyID, secretAccessKey, ""), Secure: useSSL, }) if err != nil { log.Fatalln(err) } // Get bucket notification configuration. // bucketName := "mybucket" // notificationConf, err := minioClient.GetBucketNotification(bucketName) // if err != nil { // log.Fatalln(err) // } // fmt.Printf("Bucket notification for %s: %s\n", bucketName, notificationConf) } ``` -------------------------------- ### Initialize Swag Documentation Source: https://github.com/datarhei/core/blob/main/vendor/github.com/swaggo/swag/README.md Run the swag init command in your project's root directory to parse Go annotations and generate Swagger documentation files. ```sh swag init ``` -------------------------------- ### Create and Use S2 Dictionary with Sample Data Source: https://github.com/datarhei/core/blob/main/vendor/github.com/klauspost/compress/s2/README.md Demonstrates how to create an S2 dictionary from a sample file and use it for encoding and decoding. Ensure the same dictionary is used for both operations. The dictionary can be saved and reloaded. ```Go // Read a sample sample, err := os.ReadFile("sample.json") // Create a dictionary. dict := s2.MakeDict(sample, nil) // b := dict.Bytes() will provide a dictionary that can be saved // and reloaded with s2.NewDict(b). // To encode: encoded := dict.Encode(nil, file) // To decode: decoded, err := dict.Decode(nil, file) ``` -------------------------------- ### Get Bucket Replication Example Source: https://github.com/datarhei/core/blob/main/vendor/github.com/minio/minio-go/v7/README.md Retrieves the replication configuration for a specified bucket from MinIO storage using the Go client. Returns an error if no replication is configured. ```go package main import ( "fmt" "log" "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" ) func main() { // All services are accessible via the S3 API. Endpoint // has to be described with endpoint in the form of // "play.min.io" or "192.168.1.210:9000". // NOTE: Dedicated endpoint is recommended. Use this only for development. endpoint := "localhost:9000" // A list of region names that are valid for MinIO. // For example "us-east-1". region := "" // Use a hard-coded access key and secret key for testing purposes. // For production, use environment variables or AWS credentials file. accessKeyID := "minioadmin" secretAccessKey := "minioadmin" // Force use of TLS (https) to communicate with MinIO Server. // Set to false if you are using HTTP instead of HTTPS. useSSL := true // Create a client with the MinIO Go SDK - it won't work without the IO object being initialized. minioClient, err := minio.New(endpoint, &minio.Options{ Creds: credentials.NewStaticV4(accessKeyID, secretAccessKey, ""), Secure: useSSL, }) if err != nil { log.Fatalln(err) } // Get bucket replication configuration. // bucketName := "mybucket" // replicationConf, err := minioClient.GetBucketReplication(bucketName) // if err != nil { // log.Fatalln(err) // } // fmt.Printf("Bucket replication for %s: %s\n", bucketName, replicationConf) } ``` -------------------------------- ### Get Bucket Encryption Example Source: https://github.com/datarhei/core/blob/main/vendor/github.com/minio/minio-go/v7/README.md Retrieves the encryption configuration for a specified bucket from MinIO storage using the Go client. Returns an error if no encryption is configured. ```go package main import ( "fmt" "log" "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" ) func main() { // All services are accessible via the S3 API. Endpoint // has to be described with endpoint in the form of // "play.min.io" or "192.168.1.210:9000". // NOTE: Dedicated endpoint is recommended. Use this only for development. endpoint := "localhost:9000" // A list of region names that are valid for MinIO. // For example "us-east-1". region := "" // Use a hard-coded access key and secret key for testing purposes. // For production, use environment variables or AWS credentials file. accessKeyID := "minioadmin" secretAccessKey := "minioadmin" // Force use of TLS (https) to communicate with MinIO Server. // Set to false if you are using HTTP instead of HTTPS. useSSL := true // Create a client with the MinIO Go SDK - it won't work without the IO object being initialized. minioClient, err := minio.New(endpoint, &minio.Options{ Creds: credentials.NewStaticV4(accessKeyID, secretAccessKey, ""), Secure: useSSL, }) if err != nil { log.Fatalln(err) } // Get bucket encryption configuration. // bucketName := "mybucket" // encryptionConf, err := minioClient.GetBucketEncryption(bucketName) // if err != nil { // log.Fatalln(err) // } // fmt.Printf("Bucket encryption for %s: %s\n", bucketName, encryptionConf) } ``` -------------------------------- ### Get Bucket Lifecycle Example Source: https://github.com/datarhei/core/blob/main/vendor/github.com/minio/minio-go/v7/README.md Retrieves the lifecycle configuration for a specified bucket from MinIO storage using the Go client. Returns an error if the bucket has no lifecycle configuration. ```go package main import ( "fmt" "log" "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" ) func main() { // All services are accessible via the S3 API. Endpoint // has to be described with endpoint in the form of // "play.min.io" or "192.168.1.210:9000". // NOTE: Dedicated endpoint is recommended. Use this only for development. endpoint := "localhost:9000" // A list of region names that are valid for MinIO. // For example "us-east-1". region := "" // Use a hard-coded access key and secret key for testing purposes. // For production, use environment variables or AWS credentials file. accessKeyID := "minioadmin" secretAccessKey := "minioadmin" // Force use of TLS (https) to communicate with MinIO Server. // Set to false if you are using HTTP instead of HTTPS. useSSL := true // Create a client with the MinIO Go SDK - it won't work without the IO object being initialized. minioClient, err := minio.New(endpoint, &minio.Options{ Creds: credentials.NewStaticV4(accessKeyID, secretAccessKey, ""), Secure: useSSL, }) if err != nil { log.Fatalln(err) } // Get bucket lifecycle configuration. // bucketName := "mybucket" // lifecycleConf, err := minioClient.GetBucketLifecycle(bucketName) // if err != nil { // log.Fatalln(err) // } // fmt.Printf("Bucket lifecycle for %s: %s\n", bucketName, lifecycleConf) } ``` -------------------------------- ### Set Bucket Replication Example Source: https://github.com/datarhei/core/blob/main/vendor/github.com/minio/minio-go/v7/README.md Configures replication rules for a bucket using the MinIO Go client. Requires a valid JSON configuration string. ```go package main import ( "fmt" "log" "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" ) func main() { // All services are accessible via the S3 API. Endpoint // has to be described with endpoint in the form of // "play.min.io" or "192.168.1.210:9000". // NOTE: Dedicated endpoint is recommended. Use this only for development. endpoint := "localhost:9000" // A list of region names that are valid for MinIO. // For example "us-east-1". region := "" // Use a hard-coded access key and secret key for testing purposes. // For production, use environment variables or AWS credentials file. accessKeyID := "minioadmin" secretAccessKey := "minioadmin" // Force use of TLS (https) to communicate with MinIO Server. // Set to false if you are using HTTP instead of HTTPS. useSSL := true // Create a client with the MinIO Go SDK - it won't work without the IO object being initialized. minioClient, err := minio.New(endpoint, &minio.Options{ Creds: credentials.NewStaticV4(accessKeyID, secretAccessKey, ""), Secure: useSSL, }) if err != nil { log.Fatalln(err) } // Set bucket replication configuration. // bucketName := "mybucket" // replicationConf := `{ // "Role": "arn:aws:iam::123456789012:role/myrole", // "Rules": [ // { // "Status": "Enabled", // "Destination": { // "Bucket": "arn:aws:s3:::destination-bucket" // } // } // ] // }` // err = minioClient.SetBucketReplication(bucketName, replicationConf) // if err != nil { // log.Fatalln(err) // } // fmt.Printf("Successfully set replication for bucket %s\n", bucketName) } ``` -------------------------------- ### Set Bucket Lifecycle Example Source: https://github.com/datarhei/core/blob/main/vendor/github.com/minio/minio-go/v7/README.md Configures lifecycle rules for a bucket using the MinIO Go client. Requires a valid JSON policy string. ```go package main import ( "fmt" "log" "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" ) func main() { // All services are accessible via the S3 API. Endpoint // has to be described with endpoint in the form of // "play.min.io" or "192.168.1.210:9000". // NOTE: Dedicated endpoint is recommended. Use this only for development. endpoint := "localhost:9000" // A list of region names that are valid for MinIO. // For example "us-east-1". region := "" // Use a hard-coded access key and secret key for testing purposes. // For production, use environment variables or AWS credentials file. accessKeyID := "minioadmin" secretAccessKey := "minioadmin" // Force use of TLS (https) to communicate with MinIO Server. // Set to false if you are using HTTP instead of HTTPS. useSSL := true // Create a client with the MinIO Go SDK - it won't work without the IO object being initialized. minioClient, err := minio.New(endpoint, &minio.Options{ Creds: credentials.NewStaticV4(accessKeyID, secretAccessKey, ""), Secure: useSSL, }) if err != nil { log.Fatalln(err) } // Set bucket lifecycle configuration. // bucketName := "mybucket" // lifecycleConf := `{ // "Version": "1", // "Rules": [ // { // "ID": "Delete old", // "Prefix": "logs/", // "Status": "Enabled", // "Expiration": { // "Days": 30 // } // } // ] // }` // err = minioClient.SetBucketLifecycle(bucketName, lifecycleConf) // if err != nil { // log.Fatalln(err) // } // fmt.Printf("Successfully set lifecycle for bucket %s\n", bucketName) } ``` -------------------------------- ### Example Value of Struct Source: https://github.com/datarhei/core/blob/main/vendor/github.com/swaggo/swag/README.md Shows how to provide example values for struct fields in the API documentation. ```APIDOC ## Example Value of Struct ### Description Provides example values for fields within a struct, aiding in understanding the expected data format. ### Request Body ```json { "id": 1, "name": "account name", "photo_urls": [ "http://test/image/1.jpg", "http://test/image/2.jpg" ] } ``` ### Response #### Success Response (200) - **id** (int) - Example: "1" - **name** (string) - Example: "account name" - **photo_urls** ([]string) - Example: ["http://test/image/1.jpg", "http://test/image/2.jpg"] ``` -------------------------------- ### Schema Example of Body Source: https://github.com/datarhei/core/blob/main/vendor/github.com/swaggo/swag/README.md Demonstrates how to provide a schema example for request body content, including specific formatting. ```APIDOC ## Schema Example of Body ### Description Provides a schema example for the request body, specifying content type and example values. ### Method POST ### Endpoint Any valid endpoint accepting a body. ### Parameters #### Request Body - **email** (string) - Required - Message in RFC 822 format. - Schema Example: `Subject: Testmail\r\n\r\nBody Message\r\n` ### Request Example `POST /api/send-email` with body: ``` Subject: Testmail Body Message ``` ### Response #### Success Response (200) - **field1** (type) - Description ``` -------------------------------- ### Default App Completion Method Source: https://github.com/datarhei/core/blob/main/vendor/github.com/urfave/cli/v2/godoc-current.txt Prints the list of subcommands as the default app completion method. ```go func DefaultAppComplete(cCtx *Context) ``` -------------------------------- ### Query String Example Value Parameter Annotation Source: https://github.com/datarhei/core/blob/main/vendor/github.com/swaggo/swag/README.md Defines a query parameter of type string with an example value. ```go // @Param example query string false "string example" example(string) ```