@@ -29,7 +29,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
2929 callExpr := node .(* ast.CallExpr )
3030 if p , f , ok := getCallExprFunction (callExpr ); ok && p == "fmt" && f == "Sprintf" {
3131 if err := checkForHostPortConstruction (callExpr ); err != nil {
32- pass .Reportf (node .Pos (), err .Error ())
32+ pass .Reportf (node .Pos (), "%s" , err .Error ())
3333 }
3434 }
3535 })
@@ -52,7 +52,7 @@ func getCallExprFunction(callExpr *ast.CallExpr) (pkg string, fn string, result
5252
5353// getStringLiteral returns the value at a position if it's a string literal.
5454func getStringLiteral (args []ast.Expr , pos int ) (string , bool ) {
55- if len (args ) < pos + 1 {
55+ if len (args ) < pos + 1 {
5656 return "" , false
5757 }
5858
@@ -72,9 +72,9 @@ func getStringLiteral(args []ast.Expr, pos int) (string, bool) {
7272// essentially scheme://%s:<something else>, or scheme://user:pass@%s:<something else>.
7373//
7474// Matching requirements:
75- // - Scheme as per RFC3986 is ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
76- // - A format string substitution in the host portion, preceded by an optional username/password@
77- // - A colon indicating a port will be specified
75+ // - Scheme as per RFC3986 is ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
76+ // - A format string substitution in the host portion, preceded by an optional username/password@
77+ // - A colon indicating a port will be specified
7878func checkForHostPortConstruction (sprintf * ast.CallExpr ) error {
7979 fs , ok := getStringLiteral (sprintf .Args , 0 )
8080 if ! ok {
@@ -93,4 +93,4 @@ func checkForHostPortConstruction(sprintf *ast.CallExpr) error {
9393 }
9494
9595 return nil
96- }
96+ }
0 commit comments