nfx/go-ownfunc
go-ownfunc
nfx/go-ownfunc
go-ownfunc
Go linter that reports unexported package-level functions whose direct calls all come from methods of one named type, suggesting conversion to a method.
Visit project- First shared
- Nov 2, 2026
- HN activity
- 10
Show HN@nf-xNov 2, 2026
Show HN: Go (style) linter for dangling package-level functions
I'm one of those who doesn't like dangling top-level functions polluting the package namespace and has to belong to some type via receiver to make some logical sense and "feel less cluttered" after decade in the other language ecosystems. After leaving this exact complaint (among others) in hundreds of PR reviews, I thought it's going to be fun automating this, as wanted to dig through golang.org/x/tools/go/analysis for quite a while now. It turned out that analysis.TextEdit is more fun than the linter itself, so that fixes could happen automatically and funcs undangle as pointer receiver methods if a concrete func is used just within one type. Give it a spin and tell me what you think. My two hours of internet search didn't yield any similar things out there. As the most of the linters, it's a stylistic choice, that may or may not fit your orgs. Maybe it'll make your life easier. CAUTION: Don't run with `-fix` on non-staged changes yet. PRs are very welcome, especially with more corner-case fixtures.