@@ -133,13 +133,13 @@ func (c *Checker) ProgramSSA(prog *ssa.Program) {
133133 c .prog = prog
134134}
135135
136- // Algo supplies Checker with the call graph construction algorithm.
137- func (c * Checker ) Algo (algo string ) {
136+ // CallgraphAlgorithm supplies Checker with the call graph construction algorithm.
137+ func (c * Checker ) CallgraphAlgorithm (algo string ) {
138138 c .algo = algo
139139}
140140
141- // Algo supplies Checker with the exported setting.
142- func (c * Checker ) Exported (exported bool ) {
141+ // CheckExportedFuncs sets whether to inspect exported functions
142+ func (c * Checker ) CheckExportedFuncs (exported bool ) {
143143 c .exported = exported
144144}
145145
@@ -255,6 +255,16 @@ func (c *Checker) addIssue(fn *ssa.Function, pos token.Pos, format string, args
255255 })
256256}
257257
258+ // constantValueToString returns string representation for constant value
259+ func constantValueToString (val constant.Value ) string {
260+ valStr := "nil" // an untyped nil is a nil constant.Value
261+ if val != nil {
262+ valStr = val .String ()
263+ }
264+
265+ return valStr
266+ }
267+
258268// checkFunc checks a single function for unused parameters.
259269func (c * Checker ) checkFunc (fn * ssa.Function , pkgInfo * loader.PackageInfo ) {
260270 c .debug ("func %s\n " , fn .RelString (fn .Package ().Pkg ))
@@ -310,10 +320,7 @@ func (c *Checker) checkFunc(fn *ssa.Function, pkgInfo *loader.PackageInfo) {
310320 // just one non-nil return (too many false positives)
311321 continue
312322 }
313- valStr := "nil" // an untyped nil is a nil constant.Value
314- if val != nil {
315- valStr = val .String ()
316- }
323+ valStr := constantValueToString (val )
317324 if calledInReturn (inboundCalls ) {
318325 continue
319326 }
@@ -497,10 +504,11 @@ func (c *Checker) alwaysReceivedConst(in []*callgraph.Edge, par *ssa.Parameter,
497504 seenOrig = ""
498505 }
499506 }
500- if seenOrig != "" && seenOrig != seen .String () {
507+ seenStr := constantValueToString (seen )
508+ if seenOrig != "" && seenOrig != seenStr {
501509 return fmt .Sprintf ("%s (%v)" , seenOrig , seen )
502510 }
503- return seen . String ()
511+ return seenStr
504512}
505513
506514// anyRealUse reports whether a parameter has any relevant use within its
0 commit comments