Repository navigation
Fix module name and let response recorder unwrap - #96
Merged
Merged
Conversation
The module path github.com/raeperd/kickstart.go made go build write a binary named kickstart.go, which the go tool then parsed as a source file and failed vet and build until it was deleted. Drop the .go suffix, matching the ghcr.io/raeperd/kickstart image name, and update the goimports local prefix and the README rename step.
The recorder only forwarded SetWriteDeadline, so handlers could not flush, hijack, or set a read deadline through http.ResponseController, and type assertions for http.Flusher and http.Hijacker failed. Expose Unwrap for deadlines and intercept Flush and Hijack so the recorded status still matches what the client received: a flush commits the implicit 200, and a hijacked connection records no status and stops recovery from writing a 500 into it.
The debug handlers were mounted on the service port, so every deployment exposed pprof and expvar wherever the service was reachable. Serve them from a second listener bound to DEBUG_PORT, with the default left unset so nothing is exposed unless asked for. The second server starts and shuts down alongside the service server, and a failed debug bind stops the service the same way a failed service bind does.
TestMain runs main when KICKSTART_TEST_MAIN is set, and TestMainExit spawns the test binary that way to check the non-zero exit and stderr message for an invalid PORT and the clean exit after SIGINT. Statement coverage goes from 90.5% to 95.7%.
This reverts commit c0eac8c.
A separate DEBUG_PORT server needed its own lifecycle, shutdown, and bind-failure handling plus tests for all of it. Keep pprof and expvar on the service mux, registered only when DEBUG is set, so the default exposes nothing and the template stays one server.
Replacing raeperd/kickstart after raeperd/kickstart.go covers go.mod, the goimports prefix, and the image name in one instruction.
Intercepting Flush and Hijack only sharpened the access log for a panic after a flush or hijack, at the cost of four methods and a flag. Expose Unwrap and let http.ResponseController handle Flush, Hijack, and both deadlines.
Gating pprof and expvar behind DEBUG added a flag, a parameter, and a README paragraph to a template that aims to stay minimal. Restore the unconditional /debug/ route; restricting it is a deployment concern.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Go code review fixes, part 1 of 3. Dockerfile,
.dockerignore, Makefile, and workflows are left for the follow-up PRs.Net diff against
main: 14 insertions, 21 deletions across 5 files.Module name
go buildwith the module pathgithub.com/raeperd/kickstart.gowrites a binary namedkickstart.go. The go tool then parses that binary as a source file, andgo vet ./...andgo buildfail withillegal UTF-8 encodinguntil it is deleted. The Makefile avoids this with-o app, but anyone runninggo builddirectly hits it.The module is renamed to
github.com/raeperd/kickstart, matching theghcr.io/raeperd/kickstartimage name already in the Makefile. Nothing imports the module path, so the only other references were the goimports local prefix in.golangci.ymland the README rename step. The README step now says to replaceraeperd/kickstart.goand thenraeperd/kickstart, which covers go.mod, the lint config, and the image name in one instruction.Response recorder
responseRecorderforwarded onlySetWriteDeadline, sohttp.ResponseControllercould not reachFlush,Hijack, orSetReadDeadline. That blocks SSE, WebSocket upgrades, and streaming handlers in anything built on the template.The
SetWriteDeadlinemethod is replaced byUnwrap, which is allhttp.ResponseControllerneeds for every extension. Nothing else is intercepted. The trade-off: a panic after an explicit flush or a hijack is logged against the status the recorder saw rather than what the client received. That edge case did not seem worth extra methods in a template.Question for review: #93 kept hijacking unsupported on purpose ("connection takeover ... bypass response accounting"). This PR assumes the goal was log accuracy rather than a hard policy. If hijacking should stay blocked,
Unwrapcan be dropped again and onlySetReadDeadlineadded next toSetWriteDeadline.Debug endpoints: unchanged
pprof and expvar stay on the service port, as on
main. A separateDEBUG_PORTlistener and aDEBUGopt-in flag were both tried on this branch and reverted: each added configuration and code to a template that aims to stay minimal. Restricting/debug/is left to the deployment, and the README feature line now says so.Testing
make(build, golangci-lint v2.11.4, deadcode,go test -shuffle=on -race) passes with Go 1.26.1. Statement coverage is 88.4%, same asmain.http.ResponseControllerover a real connection.