all: fix staticcheck warnings

This is a loose collection of small fixes flagged by staticcheck:

  - dead code
  - regexp expressions not using backticks (`foobar` / "foobar")
  - redundant types of slice and map initializers
  - misc other fixes

Not all of these seem very useful to me, but in particular dead code is
nice to fix. I've fixed them all just so that if there are problems,
they aren't hidden in the noise of less useful issues.
This commit is contained in:
Ayke van Laethem
2021-09-22 21:51:19 +02:00
committed by Ron Evans
parent 7df8e8db42
commit 49dd2ce393
11 changed files with 49 additions and 78 deletions
+1 -1
View File
@@ -27,7 +27,7 @@ func makeArchive(archivePath string, objs []string) error {
arwriter := ar.NewWriter(arfile)
err = arwriter.WriteGlobalHeader()
if err != nil {
return &os.PathError{"write ar header", archivePath, err}
return &os.PathError{Op: "write ar header", Path: archivePath, Err: err}
}
// Open all object files and read the symbols for the symbol table.
+3 -1
View File
@@ -141,11 +141,13 @@ func split(input []byte, limit int) [][]byte {
var block []byte
output := make([][]byte, 0, len(input)/limit+1)
for len(input) >= limit {
// add all blocks
block, input = input[:limit], input[limit:]
output = append(output, block)
}
if len(input) > 0 {
output = append(output, input[:len(input)])
// add remaining block (that isn't full sized)
output = append(output, input)
}
return output
}