diff options
| -rw-r--r-- | .dockerignore | 3 | ||||
| -rw-r--r-- | .github/workflows/tigris-push.yml | 7 | ||||
| -rw-r--r-- | Brewfile.lock.json | 62 | ||||
| -rw-r--r-- | cmd/fabricate-generation/main.go | 9 | ||||
| -rw-r--r-- | dhall/jobHistory.dhall | 22 | ||||
| -rw-r--r-- | lume/src/notes/2024/go-pointer-constant.mdx | 98 |
6 files changed, 158 insertions, 43 deletions
diff --git a/.dockerignore b/.dockerignore index 5b1079c..db19b0c 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,4 +2,5 @@ backend frontend .env .git -manifest
\ No newline at end of file +manifest +lume diff --git a/.github/workflows/tigris-push.yml b/.github/workflows/tigris-push.yml index 9dd22f4..a9a1f12 100644 --- a/.github/workflows/tigris-push.yml +++ b/.github/workflows/tigris-push.yml @@ -44,13 +44,6 @@ jobs: path: | /home/runner/.cache/deno - - name: Tailscale - uses: tailscale/github-action@v2 - with: - oauth-client-id: ${{ secrets.TAILSCALE_CLIENT_ID }} - oauth-secret: ${{ secrets.TAILSCALE_CLIENT_SECRET }} - tags: tag:ci - - name: Build and deploy xesite run: | go run ./cmd/fabricate-generation diff --git a/Brewfile.lock.json b/Brewfile.lock.json index dcf976d..cdc1766 100644 --- a/Brewfile.lock.json +++ b/Brewfile.lock.json @@ -618,45 +618,45 @@ } }, "flyctl": { - "version": "0.2.114", + "version": "0.2.125", "bottle": { "rebuild": 0, "root_url": "https://ghcr.io/v2/homebrew/core", "files": { "arm64_sonoma": { "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/flyctl/blobs/sha256:bd5ebc9e5d62ae0bd61fc881e23b905b7c987cedf16f51c36224b798964c76b5", - "sha256": "bd5ebc9e5d62ae0bd61fc881e23b905b7c987cedf16f51c36224b798964c76b5" + "url": "https://ghcr.io/v2/homebrew/core/flyctl/blobs/sha256:54bfeca205000c73e6b4642f78acd49c24abb60e532189ed0549eec31c36f142", + "sha256": "54bfeca205000c73e6b4642f78acd49c24abb60e532189ed0549eec31c36f142" }, "arm64_ventura": { "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/flyctl/blobs/sha256:bd5ebc9e5d62ae0bd61fc881e23b905b7c987cedf16f51c36224b798964c76b5", - "sha256": "bd5ebc9e5d62ae0bd61fc881e23b905b7c987cedf16f51c36224b798964c76b5" + "url": "https://ghcr.io/v2/homebrew/core/flyctl/blobs/sha256:54bfeca205000c73e6b4642f78acd49c24abb60e532189ed0549eec31c36f142", + "sha256": "54bfeca205000c73e6b4642f78acd49c24abb60e532189ed0549eec31c36f142" }, "arm64_monterey": { "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/flyctl/blobs/sha256:bd5ebc9e5d62ae0bd61fc881e23b905b7c987cedf16f51c36224b798964c76b5", - "sha256": "bd5ebc9e5d62ae0bd61fc881e23b905b7c987cedf16f51c36224b798964c76b5" + "url": "https://ghcr.io/v2/homebrew/core/flyctl/blobs/sha256:54bfeca205000c73e6b4642f78acd49c24abb60e532189ed0549eec31c36f142", + "sha256": "54bfeca205000c73e6b4642f78acd49c24abb60e532189ed0549eec31c36f142" }, "sonoma": { "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/flyctl/blobs/sha256:55b2da7831031681b0680295073a382e0306cd8c4a3feac0d81b22b34e05b8fe", - "sha256": "55b2da7831031681b0680295073a382e0306cd8c4a3feac0d81b22b34e05b8fe" + "url": "https://ghcr.io/v2/homebrew/core/flyctl/blobs/sha256:a335cf7168b566f0d7fb67a1f954bdcde0c03df38e49787b5b73efdc5f6acd26", + "sha256": "a335cf7168b566f0d7fb67a1f954bdcde0c03df38e49787b5b73efdc5f6acd26" }, "ventura": { "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/flyctl/blobs/sha256:55b2da7831031681b0680295073a382e0306cd8c4a3feac0d81b22b34e05b8fe", - "sha256": "55b2da7831031681b0680295073a382e0306cd8c4a3feac0d81b22b34e05b8fe" + "url": "https://ghcr.io/v2/homebrew/core/flyctl/blobs/sha256:a335cf7168b566f0d7fb67a1f954bdcde0c03df38e49787b5b73efdc5f6acd26", + "sha256": "a335cf7168b566f0d7fb67a1f954bdcde0c03df38e49787b5b73efdc5f6acd26" }, "monterey": { "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/flyctl/blobs/sha256:55b2da7831031681b0680295073a382e0306cd8c4a3feac0d81b22b34e05b8fe", - "sha256": "55b2da7831031681b0680295073a382e0306cd8c4a3feac0d81b22b34e05b8fe" + "url": "https://ghcr.io/v2/homebrew/core/flyctl/blobs/sha256:a335cf7168b566f0d7fb67a1f954bdcde0c03df38e49787b5b73efdc5f6acd26", + "sha256": "a335cf7168b566f0d7fb67a1f954bdcde0c03df38e49787b5b73efdc5f6acd26" }, "x86_64_linux": { "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/flyctl/blobs/sha256:94fb1a2d402c31465879b6f5d04434a633f1a5b4b02edc0f17784c453bd7b71d", - "sha256": "94fb1a2d402c31465879b6f5d04434a633f1a5b4b02edc0f17784c453bd7b71d" + "url": "https://ghcr.io/v2/homebrew/core/flyctl/blobs/sha256:b61a528c47f2c3712619a73cbbec7d5be15980b5bee0ac712faac559b4c57877", + "sha256": "b61a528c47f2c3712619a73cbbec7d5be15980b5bee0ac712faac559b4c57877" } } } @@ -664,43 +664,43 @@ "go@1.23": { "version": "1.23.0", "bottle": { - "rebuild": 0, + "rebuild": 1, "root_url": "https://ghcr.io/v2/homebrew/core", "files": { "arm64_sonoma": { "cellar": "/opt/homebrew/Cellar", - "url": "https://ghcr.io/v2/homebrew/core/go/blobs/sha256:9ae04e3063ff69c93dff6e982d93ed8c07114cdd50db418ddbb514c0f3cbb0a2", - "sha256": "9ae04e3063ff69c93dff6e982d93ed8c07114cdd50db418ddbb514c0f3cbb0a2" + "url": "https://ghcr.io/v2/homebrew/core/go/blobs/sha256:5cc408349e666ae1c8ee789d057990f523a0cb8cc51919a913eb0df64e410d43", + "sha256": "5cc408349e666ae1c8ee789d057990f523a0cb8cc51919a913eb0df64e410d43" }, "arm64_ventura": { "cellar": "/opt/homebrew/Cellar", - "url": "https://ghcr.io/v2/homebrew/core/go/blobs/sha256:9ae04e3063ff69c93dff6e982d93ed8c07114cdd50db418ddbb514c0f3cbb0a2", - "sha256": "9ae04e3063ff69c93dff6e982d93ed8c07114cdd50db418ddbb514c0f3cbb0a2" + "url": "https://ghcr.io/v2/homebrew/core/go/blobs/sha256:5cc408349e666ae1c8ee789d057990f523a0cb8cc51919a913eb0df64e410d43", + "sha256": "5cc408349e666ae1c8ee789d057990f523a0cb8cc51919a913eb0df64e410d43" }, "arm64_monterey": { "cellar": "/opt/homebrew/Cellar", - "url": "https://ghcr.io/v2/homebrew/core/go/blobs/sha256:9ae04e3063ff69c93dff6e982d93ed8c07114cdd50db418ddbb514c0f3cbb0a2", - "sha256": "9ae04e3063ff69c93dff6e982d93ed8c07114cdd50db418ddbb514c0f3cbb0a2" + "url": "https://ghcr.io/v2/homebrew/core/go/blobs/sha256:5cc408349e666ae1c8ee789d057990f523a0cb8cc51919a913eb0df64e410d43", + "sha256": "5cc408349e666ae1c8ee789d057990f523a0cb8cc51919a913eb0df64e410d43" }, "sonoma": { "cellar": "/usr/local/Cellar", - "url": "https://ghcr.io/v2/homebrew/core/go/blobs/sha256:78c91083ca44ee58e1eeb70286ead1564f44f570aeba12c5a7a981c059cc28a2", - "sha256": "78c91083ca44ee58e1eeb70286ead1564f44f570aeba12c5a7a981c059cc28a2" + "url": "https://ghcr.io/v2/homebrew/core/go/blobs/sha256:68252d4fc1abb13c66c9ee088c1f97628beecac65b6c1223cf72dd517adab1b1", + "sha256": "68252d4fc1abb13c66c9ee088c1f97628beecac65b6c1223cf72dd517adab1b1" }, "ventura": { "cellar": "/usr/local/Cellar", - "url": "https://ghcr.io/v2/homebrew/core/go/blobs/sha256:78c91083ca44ee58e1eeb70286ead1564f44f570aeba12c5a7a981c059cc28a2", - "sha256": "78c91083ca44ee58e1eeb70286ead1564f44f570aeba12c5a7a981c059cc28a2" + "url": "https://ghcr.io/v2/homebrew/core/go/blobs/sha256:68252d4fc1abb13c66c9ee088c1f97628beecac65b6c1223cf72dd517adab1b1", + "sha256": "68252d4fc1abb13c66c9ee088c1f97628beecac65b6c1223cf72dd517adab1b1" }, "monterey": { "cellar": "/usr/local/Cellar", - "url": "https://ghcr.io/v2/homebrew/core/go/blobs/sha256:78c91083ca44ee58e1eeb70286ead1564f44f570aeba12c5a7a981c059cc28a2", - "sha256": "78c91083ca44ee58e1eeb70286ead1564f44f570aeba12c5a7a981c059cc28a2" + "url": "https://ghcr.io/v2/homebrew/core/go/blobs/sha256:68252d4fc1abb13c66c9ee088c1f97628beecac65b6c1223cf72dd517adab1b1", + "sha256": "68252d4fc1abb13c66c9ee088c1f97628beecac65b6c1223cf72dd517adab1b1" }, "x86_64_linux": { "cellar": "/home/linuxbrew/.linuxbrew/Cellar", - "url": "https://ghcr.io/v2/homebrew/core/go/blobs/sha256:7ce2a2f4ebb0c620f909da574fe88b8abcf09e1c7e6acd6eb5f486a1931697c4", - "sha256": "7ce2a2f4ebb0c620f909da574fe88b8abcf09e1c7e6acd6eb5f486a1931697c4" + "url": "https://ghcr.io/v2/homebrew/core/go/blobs/sha256:8dc5e2fbbb380bd1b1f41b2be7bd1faa61b8d071231d4b193a23f1e6353f28ef", + "sha256": "8dc5e2fbbb380bd1b1f41b2be7bd1faa61b8d071231d4b193a23f1e6353f28ef" } } } @@ -731,7 +731,7 @@ "GCC": "11.4.0" }, "Ubuntu 22.04.3 LTS (jammy)": { - "HOMEBREW_VERSION": "4.3.17", + "HOMEBREW_VERSION": "4.3.19", "HOMEBREW_PREFIX": "/home/linuxbrew/.linuxbrew", "Homebrew/homebrew-core": "api", "GCC": "11.4.0" diff --git a/cmd/fabricate-generation/main.go b/cmd/fabricate-generation/main.go index c77591d..fe78ce4 100644 --- a/cmd/fabricate-generation/main.go +++ b/cmd/fabricate-generation/main.go @@ -29,7 +29,7 @@ import ( var ( bucketName = flag.String("bucket-name", "xesite", "Name of the S3 bucket to upload to") githubSHA = flag.String("github-sha", "", "GitHub SHA to use for the site") - miURL = flag.String("mimi-announce-url", "", "Mi url (named mimi-announce-url for historical reasons)") + miURL = flag.String("mimi-announce-url", "", "Mi url") patreonSaasProxyURL = flag.String("patreon-saasproxy-url", "http://xesite-patreon-saasproxy.flycast", "URL to use for the patreon saasproxy") siteURL = flag.String("site-url", "https://xeiaso.net/", "URL to use for the site") ) @@ -52,6 +52,7 @@ func main() { if err != nil { log.Fatal(err) } + _ = s3c fs, err := lume.New(context.Background(), &lume.Options{ Branch: "main", @@ -69,9 +70,9 @@ func main() { defer fs.Close() - if err := uploadFolderToS3(context.Background(), s3c, "./var/repo/lume/_site", *bucketName); err != nil { - log.Fatal(err) - } + // if err := uploadFolderToS3(context.Background(), s3c, "./var/repo/lume/_site", *bucketName); err != nil { + // log.Fatal(err) + // } } func NewPatreonClient(hc *http.Client) (*patreon.Client, error) { diff --git a/dhall/jobHistory.dhall b/dhall/jobHistory.dhall index 43777d5..8f0a8f0 100644 --- a/dhall/jobHistory.dhall +++ b/dhall/jobHistory.dhall @@ -80,7 +80,29 @@ let flyio = } } +let xeserv = + Company::{ + , name = "Xeserv" + , url = Some "https://xeserv.us" + , tagline = "Uber for developer marketing consulting" + , location = ottawa + } + in [ Job::{ + , company = xeserv + , title = "Chief Executive Officer" + , startDate = "2024-08-30" + , salary = annualCAD 150000 + , locations = [ ottawa ] + , highlights = + [ "Developer relations" + , "Content creation" + , "Technical writing" + , "Video production" + , "Generative AI consulting" + ] + } + , Job::{ , company = flyio , title = "Senior Technophilosopher" , startDate = "2024-01-07" diff --git a/lume/src/notes/2024/go-pointer-constant.mdx b/lume/src/notes/2024/go-pointer-constant.mdx new file mode 100644 index 0000000..8f7855a --- /dev/null +++ b/lume/src/notes/2024/go-pointer-constant.mdx @@ -0,0 +1,98 @@ +--- +title: "Getting a pointer to a constant in Go" +desc: "From least to most hacky" +date: 2024-11-25 +--- + +In Go, sometimes you need to get a pointer to a constant value. This is normally easy, but only if you have a _value_, not a _constant_. Let's say you or a friend are dealing with the AWS S3 API and you need to pass a value to one of the parameters: + +```go +_, err = s3c.PutObject(ctx, &s3.PutObjectInput{ + Bucket: "mah-bukkit", + Key: "something", + Body: bytes.NewReader(fileContent), +}) +``` + +Doing this gets you a compile error, because you need a _pointer_ to the string. + +There's several ways to work around this. I'm going to go over them in order from least to most hacky. + +## Make those constants into values + +You can make a pointer to a value, but not a constant. Lift the bucket name and key values into variables: + +```go +bucketName := "mah-bukkit" +key := "something" + +_, err = s3c.PutObject(ctx, &s3.PutObjectInput{ + Bucket: &bucketName, + Key: &key, + Body: bytes.NewReader(fileContent), +}) +``` + +This works in most cases, but you have to declare variables every time. This can look odd. + +## The `aws.String` / `aws.Type` functions: + +The [`aws` package](https://pkg.go.dev/github.com/aws/aws-sdk-go-v2) exposes some [helper functions](https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/aws#hdr-Value_and_Pointer_Conversion_Utilities) that do this conversion for you. You'll see these in the example code: + +```go +_, err = s3c.PutObject(ctx, &s3.PutObjectInput{ + Bucket: aws.String("mah-bukkit"), + Key: aws.String("something"), + Body: bytes.NewReader(fileContent), +}) +``` + +This works because function arguments are treated as values: + +```go +package aws + +func String(val string) *string { + return &val +} +``` + +## Making your own generic pointer to anything function + +Something else you can do is use Go generics to make a "get me the pointer of this" function: + +```go +func p[T any](val T) (*T) { + return &val +} +``` + +Then you can use it as normal: + +```go +_, err = s3c.PutObject(ctx, &s3.PutObjectInput{ + Bucket: p("mah-bukkit"), + Key: p("something"), + Body: bytes.NewReader(fileContent), +}) +``` + +## The Kubernetes trick + +Making variables and passing things as arguments to functions aren't the only way to do this, there's also a trick I learned by reading Kubernetes source code. I'll paste an example and then explain how it works: + +```go +raised := &[]string{"foo"}[0] +``` + +This works by creating an anonymous string slice with one member `"foo"`, grabs the first element of that slice, and gets the pointer to it. This makes the code look kinda cursed: + +```go +_, err = s3c.PutObject(ctx, &s3.PutObjectInput{ + Bucket: &[]string{"mah-bukkit"}[0], + Key: &[]string{"something"}[0], + Body: bytes.NewReader(fileContent), +}) +``` + +However every step in this is perfectly logical. |
