Skip to content

chore: replace rakyll/statik with stdlib //go:embed#82

Merged
SyniRon merged 1 commit into
developfrom
chore/statik-to-embed
May 20, 2026
Merged

chore: replace rakyll/statik with stdlib //go:embed#82
SyniRon merged 1 commit into
developfrom
chore/statik-to-embed

Conversation

@SyniRon
Copy link
Copy Markdown
Collaborator

@SyniRon SyniRon commented May 20, 2026

Summary

  • Replace the rakyll/statik static-asset toolchain with Go's stdlib //go:embed (available since Go 1.16, Feb 2021).
  • Move third_party/OpenAPI/openapi/assets/. New openapi package with //go:embed assets exposing the bundle as an embed.FS. Gateway serves it via fs.Sub + http.FS.
  • Drop rakyll/statik from go.mod, tools.go, the Makefile generate + install targets, and magefile.go. Delete statik/statik.go.
  • buf.gen.yaml's openapiv2 output path updated to openapi/assets.

Why now

rakyll/statik has been functionally obsolete since stdlib embed shipped. The blank-import _ "github.com/7cav/api/statik" was also the root cause of Dependabot's go_modules scan silently failing on this repo (PR #59 worked around this by checking in the generated statik/statik.go). With the blank import gone, that stopgap retires — statik/statik.go is deleted in this PR.

Closes #58.

Test plan

  • go vet ./... clean
  • go build ./... clean
  • make generate succeeds; swagger.json files land in openapi/assets/ at the new path
  • rg statik returns zero hits in the working tree
  • Local OpenAPI handler smoke at http://localhost:11000/: Swagger UI renders, zero console errors, all 13 embedded files (index, oauth2-redirect, both swagger.json, CSS, four JS bundles, two favicons, LICENSE) return 200
  • Insomnia test suite 61/61 green against the local stack
  • CI Build + Lint pass

🤖 Generated with Claude Code

`rakyll/statik` has been functionally obsolete since Go 1.16 (Feb 2021)
landed `//go:embed`. Replace the whole chain: blank import + generated
3 MB statik/statik.go + manual `make generate-statik` step are all
gone, and the OpenAPI Swagger UI assets are now bundled into the
binary directly via the stdlib `embed` package.

Changes:

- Move third_party/OpenAPI/ -> openapi/assets/. Delete the now-empty
  third_party/ tree. buf.gen.yaml's openapiv2 output path updated to
  match (`out: openapi/assets`).

- New openapi/ package with `//go:embed assets` exposing `embed.FS`.
  servers/gateway/gateway.go uses `fs.Sub` + `http.FS` to serve.

- Drop rakyll/statik from go.mod (and tools.go's blank import — without
  that, `go mod tidy` would have kept the dep). Makefile's `generate`
  target loses the `statik` invocation; `install` target loses the
  rakyll/statik entry. magefile.go gets the parallel edits.

- statik/statik.go deleted from disk; the directory is empty and gone.

Side effect: the blank import `_ "github.com/7cav/api/statik"` that
broke Dependabot's gomod scan on clean clones (the gitignored target
made `go list` fail) is gone at the root. PR #59's check-in of the
generated statik file was a stopgap for exactly this — that stopgap
now retires.

Verified:
- go vet ./... clean
- go build ./... clean
- make generate succeeds (only buf runs now); swagger.json output
  lands in openapi/assets/ at the new path
- rg statik returns zero hits in the working tree
- Container OpenAPI handler smoke at http://localhost:11000/:
  Swagger UI renders, zero console errors, all 13 embedded files
  (index, oauth2-redirect, both swagger.json, CSS, four JS bundles,
  two favicons, LICENSE) return 200
- Insomnia suite 61/61 green against the local stack

Closes #58

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator Author

@SyniRon SyniRon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@SyniRon SyniRon merged commit 4e7feeb into develop May 20, 2026
2 checks passed
@SyniRon SyniRon deleted the chore/statik-to-embed branch May 20, 2026 01:49
@SyniRon SyniRon mentioned this pull request May 20, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace rakyll/statik with Go's stdlib //go:embed

1 participant