Parallel development led to a panic from registering a handler twice in http.ServeMux
The author describes a Go HTTP server that panicked[1] at startup after several parallel pull requests were merged. At the time, they ran five to seven coding agent sessions at once, each branching from main to build a different RPC of the same service. After one PR was merged, the others were updated with main and all automated tests passed, because the tests never started the server.
The cause was a slice[2] of handler definitions. Two PRs had each added the same OrderService entry at different positions, so the merge produced no conflict and the duplicate stayed. http.ServeMux[3] panics when the same path pattern is registered twice, and the startup loop passed it the same path twice. Go's language does not forbid duplicate slice elements, and the compiler cannot see the paths, which are only produced when the Build method runs.
The author replaced the slice with a map keyed by service name constants generated by connect-go[4], so a duplicate key now fails at compile time. The change to the registration function was one line: the parameter type.
Repository Go github.com
Go is an open source programming language from Google, used to write fast, simple servers and command-line tools.
Sources
-
JPZenn JA
並列開発していたら http.ServeMux の二重登録で panic した話



