瀏覽代碼

fix errors identified by staticcheck (#447)

Margaret Nolan 6 年之前
父節點
當前提交
985cf9b4fd

+ 1
- 1
internal/driver/commands.go 查看文件

385
 		cmd := exec.Command("dot", "-T"+format)
385
 		cmd := exec.Command("dot", "-T"+format)
386
 		cmd.Stdin, cmd.Stdout, cmd.Stderr = input, output, os.Stderr
386
 		cmd.Stdin, cmd.Stdout, cmd.Stderr = input, output, os.Stderr
387
 		if err := cmd.Run(); err != nil {
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
 		return nil
390
 		return nil
391
 	}
391
 	}

+ 2
- 2
internal/driver/driver_focus.go 查看文件

173
 	}
173
 	}
174
 	v, err := strconv.ParseInt(ranges[0][1], 10, 64)
174
 	v, err := strconv.ParseInt(ranges[0][1], 10, 64)
175
 	if err != nil {
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
 	scaledValue, unit := measurement.Scale(v, ranges[0][2], ranges[0][2])
178
 	scaledValue, unit := measurement.Scale(v, ranges[0][2], ranges[0][2])
179
 	if len(ranges) == 1 {
179
 	if len(ranges) == 1 {
200
 		return nil
200
 		return nil
201
 	}
201
 	}
202
 	if v, err = strconv.ParseInt(ranges[1][1], 10, 64); err != nil {
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
 	scaledValue2, unit2 := measurement.Scale(v, ranges[1][2], unit)
205
 	scaledValue2, unit2 := measurement.Scale(v, ranges[1][2], unit)
206
 	if unit != unit2 {
206
 	if unit != unit2 {

+ 3
- 3
internal/driver/interactive.go 查看文件

91
 					}
91
 					}
92
 					continue
92
 					continue
93
 				} else if okValues := groups[name]; okValues != nil {
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
 					continue
95
 					continue
96
 				}
96
 				}
97
 			}
97
 			}
267
 		}
267
 		}
268
 	}
268
 	}
269
 	if c == nil {
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
 	if c.hasParam {
273
 	if c.hasParam {
294
 			if outputFile == "" {
294
 			if outputFile == "" {
295
 				i++
295
 				i++
296
 				if i >= len(args) {
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
 				outputFile = args[i]
299
 				outputFile = args[i]
300
 			}
300
 			}

+ 1
- 1
internal/driver/interactive_test.go 查看文件

79
 	ui := &proftest.TestUI{
79
 	ui := &proftest.TestUI{
80
 		T:       t,
80
 		T:       t,
81
 		Input:   []string{"cumulative=this"},
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
 	o.UI = ui
84
 	o.UI = ui
85
 	if err := interactive(p, o); err != nil {
85
 	if err := interactive(p, o); err != nil {

+ 3
- 3
internal/elfexec/elfexec.go 查看文件

241
 			return start - *stextOffset, nil
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
 	case elf.ET_REL:
245
 	case elf.ET_REL:
246
 		if offset != 0 {
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
 		return start, nil
249
 		return start, nil
250
 	case elf.ET_DYN:
250
 	case elf.ET_DYN:
265
 		// sx = x - start + offset - loadSegment.Off + loadSegment.Vaddr.
265
 		// sx = x - start + offset - loadSegment.Off + loadSegment.Vaddr.
266
 		return start - offset + loadSegment.Off - loadSegment.Vaddr, nil
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
 // FindTextProgHeader finds the program segment header containing the .text
271
 // FindTextProgHeader finds the program segment header containing the .text

+ 1
- 2
internal/measurement/measurement.go 查看文件

321
 	case "year", "yr":
321
 	case "year", "yr":
322
 		output, toUnit = dd/float64(365*24*time.Hour), "yrs"
322
 		output, toUnit = dd/float64(365*24*time.Hour), "yrs"
323
 	default:
323
 	default:
324
-		fallthrough
325
-	case "sec", "second", "s":
324
+		// "sec", "second", "s" handled by default case.
326
 		output, toUnit = dd/float64(time.Second), "s"
325
 		output, toUnit = dd/float64(time.Second), "s"
327
 	}
326
 	}
328
 	return output, toUnit, true
327
 	return output, toUnit, true

+ 1
- 1
internal/proftest/proftest.go 查看文件

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

+ 4
- 4
internal/report/source.go 查看文件

59
 	if sourcePath == "" {
59
 	if sourcePath == "" {
60
 		wd, err := os.Getwd()
60
 		wd, err := os.Getwd()
61
 		if err != nil {
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
 		sourcePath = wd
64
 		sourcePath = wd
65
 	}
65
 	}
142
 	if sourcePath == "" {
142
 	if sourcePath == "" {
143
 		wd, err := os.Getwd()
143
 		wd, err := os.Getwd()
144
 		if err != nil {
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
 		sourcePath = wd
147
 		sourcePath = wd
148
 	}
148
 	}
180
 	}
180
 	}
181
 
181
 
182
 	if len(fileNodes) == 0 {
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
 	sourceFiles := make(graph.Nodes, 0, len(fileNodes))
186
 	sourceFiles := make(graph.Nodes, 0, len(fileNodes))
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
 // trimPath cleans up a path by removing prefixes that are commonly
604
 // trimPath cleans up a path by removing prefixes that are commonly