### Install go-version Library Source: https://github.com/petoju/terraform-provider-mysql/blob/master/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 Match Library Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/tidwall/match/README.md Install the Match library using the go get command. ```bash go get -u github.com/tidwall/match ``` -------------------------------- ### Install go-colorable Source: https://github.com/petoju/terraform-provider-mysql/blob/master/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 ``` -------------------------------- ### hc-install Installation Output Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/hashicorp/hc-install/README.md Example output from hc-install after successfully installing a product, indicating the version and installation path. ```sh hc-install: will install terraform@1.3.7 installed terraform@1.3.7 to /current/working/dir/terraform ``` -------------------------------- ### Install Go Color Library Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/fatih/color/README.md Install the color library using the go get command. ```bash go get github.com/fatih/color ``` -------------------------------- ### Install msgpack/v5 Source: https://github.com/petoju/terraform-provider-mysql/blob/master/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. ```shell go mod init github.com/my/repo ``` ```shell go get github.com/vmihailenco/msgpack/v5 ``` -------------------------------- ### Install OpenCensus Go Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/go.opencensus.io/README.md Install the OpenCensus Go library using the go get command. Vendoring or a dependency management tool is recommended due to the evolving API. ```bash $ go get -u go.opencensus.io ``` -------------------------------- ### Install tagparser Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/vmihailenco/tagparser/v2/README.md Installs the tagparser library using go get. ```shell go get github.com/vmihailenco/tagparser/v2 ``` -------------------------------- ### Install msgpack Package Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/vmihailenco/msgpack/README.md Installs the msgpack package using the go get command. ```shell go get -u github.com/vmihailenco/msgpack ``` -------------------------------- ### Install go-isatty Package Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/mattn/go-isatty/README.md Shows the command to install the go-isatty package using go get. ```bash go get github.com/mattn/go-isatty ``` -------------------------------- ### Install GJSON Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/tidwall/gjson/README.md Install the GJSON library using the go get command. ```sh go get -u github.com/tidwall/gjson ``` -------------------------------- ### Install copystructure Go Library Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/mitchellh/copystructure/README.md Install the copystructure library using the standard Go get command. ```bash go get github.com/mitchellh/copystructure ``` -------------------------------- ### Install Compute Metadata Go Library Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/cloud.google.com/go/compute/metadata/README.md Install the utility library for communicating with the Google Cloud metadata service using go get. ```bash go get cloud.google.com/go/compute/metadata ``` -------------------------------- ### Install and Run Local Go Doc Site Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/go.opentelemetry.io/otel/CONTRIBUTING.md Installs and runs a local Go Doc site for viewing package documentation. Ensure you have Go installed and configured. ```sh go install golang.org/x/pkgsite/cmd/pkgsite@latest pkgsite ``` -------------------------------- ### Install Google Auth Library for Go Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/cloud.google.com/go/auth/README.md Installs the latest version of the Google Auth library for Go using the go get command. ```bash go get cloud.google.com/go/auth@latest ``` -------------------------------- ### Install Levenshtein Package Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/agext/levenshtein/README.md Use 'go get' to install the Levenshtein package for your Go project. ```go go get github.com/agext/levenshtein ``` -------------------------------- ### Install uuid Package Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/google/uuid/README.md Install the uuid package using the go get command. ```shell go get github.com/google/uuid ``` -------------------------------- ### Install Development Tools Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/go.opencensus.io/CONTRIBUTING.md Install necessary development tools for the project. This command only needs to be run once. ```bash $ make install-tools # Only first time. ``` -------------------------------- ### Install Pretty Go Package Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/tidwall/pretty/README.md Installs the Pretty package using the Go get command. This command retrieves the latest version of the library. ```sh go get -u github.com/tidwall/pretty ``` -------------------------------- ### Quickstart: Marshal and Unmarshal Structs Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/vmihailenco/msgpack/v5/README.md Demonstrates basic usage of msgpack for encoding (Marshal) and decoding (Unmarshal) a Go struct. This example shows how to serialize a struct to MessagePack format and then deserialize it back. ```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 } ``` -------------------------------- ### Basic Pattern Matching Examples Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/tidwall/match/README.md Demonstrates the usage of the Match function with different wildcard patterns. ```go match.Match("hello", "*llo") match.Match("jello", "?ello") match.Match("hello", "h*o") ``` -------------------------------- ### Install mapstructure Go Library Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/mitchellh/mapstructure/README.md Use 'go get' to install the mapstructure library. This is the standard method for obtaining Go packages. ```bash go get github.com/mitchellh/mapstructure ``` -------------------------------- ### Install Cloud SQL Go Connector Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/cloud.google.com/go/cloudsqlconn/README.md Install the Cloud SQL Go Connector package using go get. This command fetches and installs the latest version of the package. ```sh go get cloud.google.com/go/cloudsqlconn ``` -------------------------------- ### Install Go-MySQL-Driver Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/go-sql-driver/mysql/README.md Install the Go-MySQL-Driver using the go tool. Ensure Git is installed and in your system's PATH. ```bash go get -u github.com/go-sql-driver/mysql ``` -------------------------------- ### Install Terraform using hc-install Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/hashicorp/hc-install/README.md Example command to install a specific version of Terraform using the hc-install tool. ```sh hc-install install -version 1.3.7 terraform ``` -------------------------------- ### Install gofrs/uuid Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/gofrs/uuid/README.md Use the go get command to download the package directly if you are unable to use a dependency manager. ```Shell $ go get github.com/gofrs/uuid ``` -------------------------------- ### Create a MySQL Database Source: https://github.com/petoju/terraform-provider-mysql/blob/master/website/docs/r/database.html.markdown Example of how to create a new MySQL database named 'my_awesome_app' using the `mysql_database` resource. ```hcl resource "mysql_database" "app" { name = "my_awesome_app" } ``` -------------------------------- ### Basic GJSON Path Examples Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/tidwall/gjson/SYNTAX.md Demonstrates basic retrieval of values from JSON using object keys and array indices. ```go name.last "Anderson" name.first "Tom" age 37 children ["Sara","Alex","Jack"] children.0 "Sara" children.1 "Alex" friends.1 {"first": "Roger", "last": "Craig", "age": 68} friends.1.first "Roger" ``` -------------------------------- ### Go Client Code Generation Configuration Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/aws/smithy-go/README.md Example configuration for the `go-codegen` build plugin in `smithy-build.json`. This setup applies the plugin to a Smithy model, specifying the service, module, and Go version. ```json { "version": "1.0", "sources": [ "models" ], "maven": { "dependencies": [ "software.amazon.smithy.go:smithy-go-codegen:0.1.0" ] }, "plugins": { "go-codegen": { "service": "example.weather#Weather", "module": "github.com/example/weather", "generateGoMod": true, "goDirective": "1.24" } } } ``` -------------------------------- ### Use the Global Logger Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/hashicorp/go-hclog/README.md Access and use the default logger instance to log messages. This is the simplest way to start logging. ```go hclog.Default().Info("hello world") ``` -------------------------------- ### HCL Native Syntax Example Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/hashicorp/hcl/v2/README.md Demonstrates the native HCL syntax with attributes and nested blocks for a hypothetical service configuration. ```hcl io_mode = "async" service "http" "web_proxy" { listen_addr = "127.0.0.1:8080" process "main" { command = ["/usr/local/bin/awesome-app", "server"] } process "mgmt" { command = ["/usr/local/bin/awesome-app", "mgmt"] } } ``` -------------------------------- ### Get the Project using Go Modules Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/go.opentelemetry.io/otel/CONTRIBUTING.md Use `go get` to download the project source code into your GOPATH. This command may produce warnings that can be ignored. ```go go get -d go.opentelemetry.io/otel ``` -------------------------------- ### DSN Format Example Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/go-sql-driver/mysql/README.md Illustrates the general format of a Data Source Name (DSN) for the Go MySQL driver. ```text username:password@protocol(address)/dbname?param=value ``` -------------------------------- ### hc-install Usage Information Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/hashicorp/hc-install/README.md Displays the command-line usage instructions for the hc-install tool, detailing available options for installing HashiCorp products. ```text Usage: hc-install install [options] -version This command installs a HashiCorp product. Options: -version [REQUIRED] Version of product to install. -path Path to directory where the product will be installed. Defaults to current working directory. -log-file Path to file where logs will be written. /dev/stdout or /dev/stderr can be used to log to STDOUT/STDERR. ``` -------------------------------- ### Install gRPC-Go Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/google.golang.org/grpc/README.md Add this import to your Go code to automatically fetch gRPC-Go dependencies during build, run, or test. ```go import "google.golang.org/grpc" ``` -------------------------------- ### Minimal DSN Example Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/go-sql-driver/mysql/README.md Shows the minimal DSN format when only the database name is required. ```text /dbname ``` -------------------------------- ### RGB Color Examples Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/fatih/color/README.md Shows how to use 24-bit RGB color codes for foreground and background colors if the terminal supports them. ```go color.RGB(255, 128, 0).Println("foreground orange") color.RGB(230, 42, 42).Println("foreground red") color.BgRGB(255, 128, 0).Println("background orange") color.BgRGB(230, 42, 42).Println("background red") ``` -------------------------------- ### Create a MySQL role Source: https://github.com/petoju/terraform-provider-mysql/blob/master/website/docs/r/role.html.markdown This is a basic example of how to create a MySQL role. The name argument is required. ```hcl resource "mysql_role" "developer" { name = "developer" } ``` -------------------------------- ### mysql_user with caching_sha2_password and Hex Hash Source: https://github.com/petoju/terraform-provider-mysql/blob/master/website/docs/r/user.html.markdown This example shows how to create a user with the 'caching_sha2_password' plugin using a hexadecimal representation of the password hash. ```hcl resource "mysql_user" "nologin" { user = "nologin" host = "example.com" auth_plugin = "caching_sha2_password" auth_string_hex = "0x244124303035246C4F1E0D5D1631594F5C56701F3D327D073A724C706273307A5965516C7756" } ``` -------------------------------- ### Yamux Server Setup Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/hashicorp/yamux/README.md Illustrates how to set up a Yamux server session to accept incoming connections and streams. This includes accepting a TCP connection, initializing the server session, and accepting a new stream for communication. ```go func server() { // Accept a TCP connection conn, err := listener.Accept() if err != nil { panic(err) } // Setup server side of yamux session, err := yamux.Server(conn, nil) if err != nil { panic(err) } // Accept a stream stream, err := session.Accept() if err != nil { panic(err) } // Listen for a message buf := make([]byte, 4) stream.Read(buf) } ``` -------------------------------- ### Quickstart: Marshal and Unmarshal Struct Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/vmihailenco/msgpack/README.md Demonstrates basic usage of msgpack.Marshal and msgpack.Unmarshal to encode and decode a Go struct. Ensure error handling for production code. ```go 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 } ``` -------------------------------- ### Yamux Client Setup Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/hashicorp/yamux/README.md Demonstrates how to set up a Yamux client session over an existing TCP connection. This involves dialing the connection, initializing the client session, and opening a new stream for communication. ```go func client() { // Get a TCP connection conn, err := net.Dial(...) if err != nil { panic(err) } // Setup client side of yamux session, err := yamux.Client(conn, nil) if err != nil { panic(err) } // Open a new stream stream, err := session.Open() if err != nil { panic(err) } // Stream implements net.Conn stream.Write([]byte("ping")) } ``` -------------------------------- ### Terraform Init, Plan, and Apply Source: https://github.com/petoju/terraform-provider-mysql/blob/master/examples/aws-rds-role-arn/README.md Standard Terraform commands to initialize the project, review changes, and apply the configuration. Ensure your main.tf is updated with correct values before running. ```bash terraform init terraform plan terraform apply ``` -------------------------------- ### Install jwt-go Package Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/golang-jwt/jwt/v5/README.md Install the jwt package using go get. This command adds jwt-go as a dependency to your Go program. ```sh go get -u github.com/golang-jwt/jwt/v5 ``` -------------------------------- ### Create Root Logger in Go Application Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/go-logr/logr/README.md Demonstrates how to create the initial 'root' logger in a Go application using a specific logging implementation (e.g., 'logimpl'). This is typically done early in the application's lifecycle. ```go func main() { // ... other setup code ... // Create the "root" logger. We have chosen the "logimpl" implementation, // which takes some initial parameters and returns a logr.Logger. logger := logimpl.New(param1, param2) // ... other setup code ... ``` -------------------------------- ### Install hc-install via Homebrew Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/hashicorp/hc-install/README.md Install the hc-install CLI tool using Homebrew on macOS or Linux systems. ```shell brew install hashicorp/tap/hc-install ``` -------------------------------- ### Install Azure Identity Module Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/Azure/azure-sdk-for-go/sdk/azidentity/README.md Installs the Azure Identity module using Go modules for versioning and dependency management. ```sh go get -u github.com/Azure/azure-sdk-for-go/sdk/azidentity ``` -------------------------------- ### HCL JSON Representation Example Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/hashicorp/hcl/v2/README.md Shows the JSON equivalent of the HCL native syntax example, representing the same configuration structure. ```json { "io_mode": "async", "service": { "http": { "web_proxy": { "listen_addr": "127.0.0.1:8080", "process": { "main": { "command": ["/usr/local/bin/awesome-app", "server"] }, "mgmt": { "command": ["/usr/local/bin/awesome-app", "mgmt"] }, } } } } } ``` -------------------------------- ### New Function with Options Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/go.opentelemetry.io/otel/CONTRIBUTING.md Demonstrates the typical signature for a constructor function that accepts variadic options. ```go func NewT(options ...Option) T {…} ``` -------------------------------- ### Chained Get Operations Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/tidwall/gjson/README.md Illustrates multiple ways to access nested JSON values using chained `Get` calls or a single path. ```Go gjson.Parse(json).Get("name").Get("last") gjson.Get(json, "name").Get("last") gjson.Get(json, "name.last") ``` -------------------------------- ### Client Secret Authentication with azidentity Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/Azure/azure-sdk-for-go/sdk/azidentity/MIGRATION.md This example shows client secret authentication using the modern azidentity package. It creates a credential and then uses it to initialize a new subscriptions client. ```go import ( "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions" ) cred, err := azidentity.NewClientSecretCredential(tenantID, clientID, secret, nil) handle(err) client, err := armsubscriptions.NewClient(cred, nil) handle(err) ``` -------------------------------- ### Simple GET Request with go-retryablehttp Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/hashicorp/go-retryablehttp/README.md Demonstrates a basic GET request using the retryablehttp client. The call will automatically retry on errors or 500-range status codes with exponential backoff. ```go resp, err := retryablehttp.Get("/foo") if err != nil { panic(err) } ``` -------------------------------- ### Register a View with Distribution Aggregation in Go Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/go.opencensus.io/README.md Shows how to register a new view named 'example.com/video_size_distribution' with a description and a DistributionAggregation. This view will collect data for the 'videoSize' measure. ```go if err := view.Register(&view.View{ Name: "example.com/video_size_distribution", Description: "distribution of processed video size over time", Measure: videoSize, Aggregation: view.Distribution(1<<32, 2<<32, 3<<32), }); err != nil { log.Fatalf("Failed to register view: %v", err) } ``` -------------------------------- ### Start and End a Span for Cache Operations in Go Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/go.opencensus.io/README.md Illustrates how to start a new span named 'cache.Get' and defer its ending. This is used to measure the duration of cache retrieval operations. ```go ctx, span := trace.StartSpan(ctx, "cache.Get") defer span.End() // Do work to get from cache. ``` -------------------------------- ### GJSON Path Syntax Examples Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/tidwall/gjson/README.md Illustrates various GJSON path syntax examples for accessing data within a JSON structure, including nested objects, arrays, wildcards, and counts. ```json { "name": {"first": "Tom", "last": "Anderson"}, "age":37, "children": ["Sara","Alex","Jack"], "fav.movie": "Deer Hunter", "friends": [ {"first": "Dale", "last": "Murphy", "age": 44, "nets": ["ig", "fb", "tw"]}, {"first": "Roger", "last": "Craig", "age": 68, "nets": ["fb", "tw"]}, {"first": "Jane", "last": "Murphy", "age": 47, "nets": ["ig", "tw"]} ] } ``` ```text "name.last" >> "Anderson" "age" >> 37 "children" >> ["Sara","Alex","Jack"] "children.#" >> 3 "children.1" >> "Alex" "child*.2" >> "Jack" "c?ildren.0" >> "Sara" "fav\.movie" >> "Deer Hunter" "friends.#.first" >> ["Dale","Roger","Jane"] "friends.1.last" >> "Craig" ``` -------------------------------- ### Tuple For Expression Example Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/hashicorp/hcl/v2/hclsyntax/spec.md Constructs a new tuple by iterating over a list and using each element as a value. ```hcl [for v in ["a", "b"]: v] ``` -------------------------------- ### Enable LOAD DATA LOCAL INFILE Support Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/go-sql-driver/mysql/README.md Example of how to import the driver to enable LOAD DATA LOCAL INFILE support. Requires registering local files or disabling the allowlist check. ```go import "github.com/go-sql-driver/mysql" ``` -------------------------------- ### GJSON Custom Modifier Usage Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/tidwall/gjson/README.md Examples of using the custom `@case` modifier with path chaining. ```go "children|@case:upper" >> ["SARA","ALEX","JACK"] "children|@case:lower|@reverse" >> ["jack","alex","sara"] ``` -------------------------------- ### Creating Dialer with Default Options Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/cloud.google.com/go/cloudsqlconn/README.md Shows how to create a new Dialer instance with default connection options that will be applied to all subsequent connections. ```go d, err := cloudsqlconn.NewDialer( ctx, cloudsqlconn.WithDefaultDialOptions( cloudsqlconn.WithPrivateIP(), ), ) ``` -------------------------------- ### Get JSON from Bytes Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/tidwall/gjson/README.md Uses `gjson.GetBytes` for efficient JSON querying when the input is a byte slice. ```Go var json []byte = ... result := gjson.GetBytes(json, path) ``` -------------------------------- ### Import jwt-go Package Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/golang-jwt/jwt/v5/README.md Import the jwt package into your Go code to start using its functionalities. ```go import "github.com/golang-jwt/jwt/v5" ``` -------------------------------- ### Enable Datastore Key Conversion for Basic/Manual Scaling Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/google.golang.org/appengine/README.md Enables automatic conversion of datastore keys when using basic or manual scaling. This handler should be registered for the /_ah/start path. ```go http.HandleFunc("/_ah/start", func(w http.ResponseWriter, r *http.Request) { datastore.EnableKeyConversion(appengine.NewContext(r)) }) ``` -------------------------------- ### Enable and Configure Logging for azidentity Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/Azure/azure-sdk-for-go/sdk/azidentity/TROUBLESHOOTING.md This snippet shows how to set up a listener to print authentication logs to standard output and filter logs to include only those from `azidentity`. ```go import azlog "github.com/Azure/azure-sdk-for-go/sdk/azcore/log" // print log output to stdout azlog.SetListener(func(event azlog.Event, s string) { fmt.Println(s) }) // include only azidentity credential logs azlog.SetEvents(azidentity.EventAuthentication) ``` -------------------------------- ### Object For Expression Example Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/hashicorp/hcl/v2/hclsyntax/spec.md Constructs a new object by iterating over a list and mapping elements to their indices as values. ```hcl {for i, v in ["a", "b"]: v => i} ``` -------------------------------- ### Configuring Dialer for IAM Authentication Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/cloud.google.com/go/cloudsqlconn/README.md Illustrates how to initialize a Dialer to use automatic IAM database authentication, which is recommended for secure connections. ```go d, err := cloudsqlconn.NewDialer(ctx, cloudsqlconn.WithIAMAuthN()) ``` -------------------------------- ### Import Basic Grant Source: https://github.com/petoju/terraform-provider-mysql/blob/master/website/docs/r/grant.html.markdown A basic example of importing a grant using the user, host, database, and table as the identifier. ```shell terraform import mysql_grant.example user@host@database@table ``` -------------------------------- ### Apply Profiler Labels using Tags in Go Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/go.opencensus.io/README.md Shows how to create a context with tags (OS and User ID) and then use tag.Do to execute a function. When profiling is enabled, samples recorded within this function will include these tag key/values. ```go ctx, err = tag.New(ctx, tag.Insert(osKey, "macOS-10.12.5"), tag.Insert(userIDKey, "fff0989878"), ) if err != nil { log.Fatal(err) } tag.Do(ctx, func(ctx context.Context) { // Do work. // When profiling is on, samples will be // recorded with the key/values from the tag map. }) ``` -------------------------------- ### Create a New Logger Instance Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/hashicorp/go-hclog/README.md Instantiate a new logger with custom options, including name and log level. Set the desired log level using `LevelFromString`. ```go appLogger := hclog.New(&hclog.LoggerOptions{ Name: "my-app", Level: hclog.LevelFromString("DEBUG"), }) ``` -------------------------------- ### Get OpenCensus Go Dependency Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/go.opencensus.io/CONTRIBUTING.md Fetch the upstream OpenCensus Go repository to your GOPATH. This is a prerequisite for local development. ```bash $ go get -d go.opencensus.io ``` -------------------------------- ### Prepare and Commit Changes Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/go.opentelemetry.io/otel/CONTRIBUTING.md Create a new branch, make your modifications, run precommit checks, stage changes, commit, and push to your fork. Remember to update CHANGELOG.md. ```sh git checkout -b # edit files # update changelog make precommit git add -p git commit git push ``` -------------------------------- ### Get Nested Array Values Source: https://github.com/petoju/terraform-provider-mysql/blob/master/vendor/github.com/tidwall/gjson/README.md Retrieves all last names from a JSON array of objects using the 'programmers.#.lastName' path. ```Go result := gjson.Get(json, "programmers.#.lastName") for _, name := range result.Array() { println(name.String()) } ```