What is the reason for including the unused parameter in the function signature? If it was a method and the reason was to comply with an interface signature then you can assert the interface to get unparam to ignore:
var _ InterfaceType = (*MyType)(nil) or if not a pointer receiver var _ InterfaceType = MyType{} Usually I would declare an unused parameter with the underscore name: func foo( name string, _ int, // age ) { Duncan On Monday, 6 March 2023 at 20:14:25 UTC Sergei Dyshel wrote: Hello all, I'm incorporating golangci-lint <https://golangci-lint.run/usage/linters/> linter aggregator in my codebase and facing a dilemma on how to mark false positives for these 2 linters: - errcheck - reports unchecked errors. - unparam - reports unused function parameters. The "official" way is to use special comment directives that make linter ignore the line: func foo( name string, //nolint:unparam age int, ) { //nolint:errcheck file, _ := os.Open(name) .... Another, may be more portable way, would be using special functions which do nothing: // defined in some library utilities package func IgnoreErr(err error) {} func Unused(a any) {} func foo( name string, age int, ) { Unused(age) file, err := os.Open(name) IgnoreErr(err) ... What do you think the proper/idiomatic/better way among these two? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/ab7e726b-ac16-48d3-8093-36d24d08db5dn%40googlegroups.com.