diff --git a/prompts/CODE_STYLEGUIDE_GO.md b/prompts/CODE_STYLEGUIDE_GO.md index f859589..2051bda 100644 --- a/prompts/CODE_STYLEGUIDE_GO.md +++ b/prompts/CODE_STYLEGUIDE_GO.md @@ -423,6 +423,29 @@ last_modified: 2026-02-22 [github.com/bcicen/go-units](https://github.com/bcicen/go-units) for temperatures (and others). The type system is your friend, use it. +1. When defining custom string-based wrapper types (e.g. `type ImageID string`, + `type ContainerID string`), always implement the `fmt.Stringer` interface. + At SDK and library boundaries, use `.String()` instead of `string(v)` to + convert the value to a plain string. This makes the conversion explicit, + grep-able, and ensures a consistent pattern across the codebase. + + Example: + + ```go + type ImageID string + + func (id ImageID) String() string { + return string(id) + } + + // At SDK/library boundaries: + // Good: + client.PullImage(ctx, imageID.String()) + + // Bad: + client.PullImage(ctx, string(imageID)) + ``` + 1. Once you have a working program, run `go mod tidy` to clean up your `go.mod` and `go.sum` files. Tag a v0.0.1 or v1.0.0. Push your `main` branch and tag(s). Subsequent work should happen on branches so that `main` is "always