Browse Source

fix errors identified by staticcheck (#447)

Margaret Nolan 6 years ago
parent
commit
985cf9b4fd

+ 1
- 1
internal/driver/commands.go View File

@@ -385,7 +385,7 @@ func invokeDot(format string) PostProcessor {
385 385
 		cmd := exec.Command("dot", "-T"+format)
386 386
 		cmd.Stdin, cmd.Stdout, cmd.Stderr = input, output, os.Stderr
387 387
 		if err := cmd.Run(); err != nil {
388
-			return fmt.Errorf("Failed to execute dot. Is Graphviz installed? Error: %v", err)
388
+			return fmt.Errorf("failed to execute dot. Is Graphviz installed? Error: %v", err)
389 389
 		}
390 390
 		return nil
391 391
 	}

+ 2
- 2
internal/driver/driver_focus.go View File

@@ -173,7 +173,7 @@ func parseTagFilterRange(filter string) func(int64, string) bool {
173 173
 	}
174 174
 	v, err := strconv.ParseInt(ranges[0][1], 10, 64)
175 175
 	if err != nil {
176
-		panic(fmt.Errorf("Failed to parse int %s: %v", ranges[0][1], err))
176
+		panic(fmt.Errorf("failed to parse int %s: %v", ranges[0][1], err))
177 177
 	}
178 178
 	scaledValue, unit := measurement.Scale(v, ranges[0][2], ranges[0][2])
179 179
 	if len(ranges) == 1 {
@@ -200,7 +200,7 @@ func parseTagFilterRange(filter string) func(int64, string) bool {
200 200
 		return nil
201 201
 	}
202 202
 	if v, err = strconv.ParseInt(ranges[1][1], 10, 64); err != nil {
203
-		panic(fmt.Errorf("Failed to parse int %s: %v", ranges[1][1], err))
203
+		panic(fmt.Errorf("failed to parse int %s: %v", ranges[1][1], err))
204 204
 	}
205 205
 	scaledValue2, unit2 := measurement.Scale(v, ranges[1][2], unit)
206 206
 	if unit != unit2 {

+ 3
- 3
internal/driver/interactive.go View File

@@ -91,7 +91,7 @@ func interactive(p *profile.Profile, o *plugin.Options) error {
91 91
 					}
92 92
 					continue
93 93
 				} else if okValues := groups[name]; okValues != nil {
94
-					o.UI.PrintErr(fmt.Errorf("Unrecognized value for %s: %q. Use one of %s", name, value, strings.Join(okValues, ", ")))
94
+					o.UI.PrintErr(fmt.Errorf("unrecognized value for %s: %q. Use one of %s", name, value, strings.Join(okValues, ", ")))
95 95
 					continue
96 96
 				}
97 97
 			}
@@ -267,7 +267,7 @@ func parseCommandLine(input []string) ([]string, variables, error) {
267 267
 		}
268 268
 	}
269 269
 	if c == nil {
270
-		return nil, nil, fmt.Errorf("Unrecognized command: %q", name)
270
+		return nil, nil, fmt.Errorf("unrecognized command: %q", name)
271 271
 	}
272 272
 
273 273
 	if c.hasParam {
@@ -294,7 +294,7 @@ func parseCommandLine(input []string) ([]string, variables, error) {
294 294
 			if outputFile == "" {
295 295
 				i++
296 296
 				if i >= len(args) {
297
-					return nil, nil, fmt.Errorf("Unexpected end of line after >")
297
+					return nil, nil, fmt.Errorf("unexpected end of line after >")
298 298
 				}
299 299
 				outputFile = args[i]
300 300
 			}

+ 1
- 1
internal/driver/interactive_test.go View File

@@ -79,7 +79,7 @@ func TestShell(t *testing.T) {
79 79
 	ui := &proftest.TestUI{
80 80
 		T:       t,
81 81
 		Input:   []string{"cumulative=this"},
82
-		AllowRx: `Unrecognized value for cumulative: "this". Use one of cum, flat`,
82
+		AllowRx: `unrecognized value for cumulative: "this". Use one of cum, flat`,
83 83
 	}
84 84
 	o.UI = ui
85 85
 	if err := interactive(p, o); err != nil {

+ 3
- 3
internal/elfexec/elfexec.go View File

@@ -241,10 +241,10 @@ func GetBase(fh *elf.FileHeader, loadSegment *elf.ProgHeader, stextOffset *uint6
241 241
 			return start - *stextOffset, nil
242 242
 		}
243 243
 
244
-		return 0, fmt.Errorf("Don't know how to handle EXEC segment: %v start=0x%x limit=0x%x offset=0x%x", *loadSegment, start, limit, offset)
244
+		return 0, fmt.Errorf("don't know how to handle EXEC segment: %v start=0x%x limit=0x%x offset=0x%x", *loadSegment, start, limit, offset)
245 245
 	case elf.ET_REL:
246 246
 		if offset != 0 {
247
-			return 0, fmt.Errorf("Don't know how to handle mapping.Offset")
247
+			return 0, fmt.Errorf("don't know how to handle mapping.Offset")
248 248
 		}
249 249
 		return start, nil
250 250
 	case elf.ET_DYN:
@@ -265,7 +265,7 @@ func GetBase(fh *elf.FileHeader, loadSegment *elf.ProgHeader, stextOffset *uint6
265 265
 		// sx = x - start + offset - loadSegment.Off + loadSegment.Vaddr.
266 266
 		return start - offset + loadSegment.Off - loadSegment.Vaddr, nil
267 267
 	}
268
-	return 0, fmt.Errorf("Don't know how to handle FileHeader.Type %v", fh.Type)
268
+	return 0, fmt.Errorf("don't know how to handle FileHeader.Type %v", fh.Type)
269 269
 }
270 270
 
271 271
 // FindTextProgHeader finds the program segment header containing the .text

+ 1
- 2
internal/measurement/measurement.go View File

@@ -321,8 +321,7 @@ func timeLabel(value int64, fromUnit, toUnit string) (v float64, u string, ok bo
321 321
 	case "year", "yr":
322 322
 		output, toUnit = dd/float64(365*24*time.Hour), "yrs"
323 323
 	default:
324
-		fallthrough
325
-	case "sec", "second", "s":
324
+		// "sec", "second", "s" handled by default case.
326 325
 		output, toUnit = dd/float64(time.Second), "s"
327 326
 	}
328 327
 	return output, toUnit, true

+ 1
- 1
internal/proftest/proftest.go View File

@@ -93,7 +93,7 @@ func (ui *TestUI) ReadLine(_ string) (string, error) {
93 93
 	input := ui.Input[ui.index]
94 94
 	ui.index++
95 95
 	if input == "**error**" {
96
-		return "", fmt.Errorf("Error: %s", input)
96
+		return "", fmt.Errorf("error: %s", input)
97 97
 	}
98 98
 	return input, nil
99 99
 }

+ 4
- 4
internal/report/source.go View File

@@ -59,7 +59,7 @@ func printSource(w io.Writer, rpt *Report) error {
59 59
 	if sourcePath == "" {
60 60
 		wd, err := os.Getwd()
61 61
 		if err != nil {
62
-			return fmt.Errorf("Could not stat current dir: %v", err)
62
+			return fmt.Errorf("could not stat current dir: %v", err)
63 63
 		}
64 64
 		sourcePath = wd
65 65
 	}
@@ -142,7 +142,7 @@ func PrintWebList(w io.Writer, rpt *Report, obj plugin.ObjTool, maxFiles int) er
142 142
 	if sourcePath == "" {
143 143
 		wd, err := os.Getwd()
144 144
 		if err != nil {
145
-			return fmt.Errorf("Could not stat current dir: %v", err)
145
+			return fmt.Errorf("could not stat current dir: %v", err)
146 146
 		}
147 147
 		sourcePath = wd
148 148
 	}
@@ -180,7 +180,7 @@ func PrintWebList(w io.Writer, rpt *Report, obj plugin.ObjTool, maxFiles int) er
180 180
 	}
181 181
 
182 182
 	if len(fileNodes) == 0 {
183
-		return fmt.Errorf("No source information for %s", o.Symbol.String())
183
+		return fmt.Errorf("no source information for %s", o.Symbol.String())
184 184
 	}
185 185
 
186 186
 	sourceFiles := make(graph.Nodes, 0, len(fileNodes))
@@ -598,7 +598,7 @@ func openSourceFile(path, searchPath, trim string) (*os.File, error) {
598 598
 		}
599 599
 	}
600 600
 
601
-	return nil, fmt.Errorf("Could not find file %s on path %s", path, searchPath)
601
+	return nil, fmt.Errorf("could not find file %s on path %s", path, searchPath)
602 602
 }
603 603
 
604 604
 // trimPath cleans up a path by removing prefixes that are commonly