~/til/go-deadcode

Go: Check for unreachable code with Deadcode

Today I learned how to find unreachable code in a Go project using the deadcode tool.

Install deadcode:

go install golang.org/x/tools/cmd/deadcode@latest

Run deadcode on your Codebase:

go tool deadcode ./...

Example output:

example/foo.go:42:6: func unusedFunc

References

deadcode documentation [Official Go tools]

Dario Camargo

Software Engineer
Go, Java, Python

Currently at Mercado Livre
Proximity / Delivery Platforms

Location: São Paulo - Brazil - UTC-3

Languages:
- Portuguese (Native)
- English (Fluent)
- Spanish (B2)

Dario standing

Projects

Today I Learned