Skip to content

Instantly share code, notes, and snippets.

@derekperkins
derekperkins / aws_helpers.go
Last active April 5, 2024 23:51
How to use AWS WebIdentity to assume a role using GCP Workload Idenity in Go
package awshelpers
import (
"context"
"errors"
"github.com/aws/aws-sdk-go-v2/aws"
awsconfig "github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/credentials/stscreds"
"github.com/aws/aws-sdk-go-v2/service/sts"

MySQL

expandArgs

expandArgs expands any named args that are slices into multiple named args, one for each element in the slice. This is useful for queries that use the IN operator, e.g. SELECT * FROM table WHERE id IN (:id)

  • If there are no args, the original stmt and args are returned.
  • If there are no slices to expand, the original stmt and args are returned.
  • If the args are positional, the original stmt and args are returned, as we can't expand positional args.
  • Only slices of primitives are supported. Slices of structs or other types are not supported.
@derekperkins
derekperkins / README.md
Created May 14, 2024 21:16
Benchmarking string

Benchmarked on 2024-05-14 on a 2023 M3 Max MacBook Pro 36 GB, Go 1.22.3

BenchmarkStringConcat
BenchmarkStringConcat-14             	31729719	        36.95 ns/op	      16 B/op	       2 allocs/op
BenchmarkStringBuilder
BenchmarkStringBuilder-14            	44426755	        26.44 ns/op	      24 B/op	       2 allocs/op
BenchmarkStringBuilderFromPool
BenchmarkStringBuilderFromPool-14    	35302768	        33.49 ns/op	      24 B/op	       2 allocs/op
BenchmarkBytesBuffer