Are you maintaining dead code?
July 12, 2023
I’m taking a break from the Go spec today to talk about a new tool I just discovered, that saved me a bunch of work.
One of the clients I’m working with has a rather old codebase, filled with a bunch of retired features. It was a laborious task to go through all the thousands of files in the project to see which functions and types were no longer being used.
I tried using golangci-lint’s unused linter, but it only detects unexported symbols that aren’t used. I wanted something to detect exported symbols, as this isn’t a library that’s imported by anything else.
That’s when someone turned me on to a very recent addition to the
golang.org/x/tools repo: a command to report dead code in Go programs
It’s just what I needed!
And here’s the result:
I would love to see this new tool incorporated into
golangci-lint. Maybe that’ll come later. But even without that, it’s a great tool. Check it out, and see if you can’t remove some dead code from your project!
Watch my first ever Boldly Go Live stream
Next Monday, June 19, I’ll be doing my first ever Boldly Go Live stream on YouTube! I’ll be live coding on a real Go project, and answering audience questions. The event will begin at 3:00pm Central European Summer Time (or 13:00 UTC), and I’ll go for up to two hours, depending on the vibe. You can catch the event here. Drop by early, and click the “Notify Me” link, to be reminded when the event starts.
ChatGPT-4 vs ChatGPT-3 vs Go
ChatGPT didn't do so well when quizzed about Go. Can ChatGPT 4 do better?