Use fmt.Errorf, error strings should start lowercase

This commit is contained in:
Philipp Wolfer 2023-12-05 08:17:46 +01:00
parent a9e07915ce
commit 28ed1183e4
No known key found for this signature in database
GPG key ID: 8FDF744D4919943B
4 changed files with 10 additions and 15 deletions

View file

@ -24,7 +24,6 @@ package scrobblerlog
import (
"bufio"
"encoding/csv"
"errors"
"fmt"
"io"
"strconv"
@ -71,8 +70,7 @@ func Parse(data io.Reader, includeSkipped bool) (ScrobblerLog, error) {
// We consider only the last field (recording MBID) optional
if len(row) < 7 {
line, _ := tsvReader.FieldPos(0)
return result, errors.New(fmt.Sprintf(
"Invalid record in scrobblerlog line %v", line))
return result, fmt.Errorf("invalid record in scrobblerlog line %v", line)
}
rating := row[5]
@ -132,15 +130,15 @@ func ReadHeader(reader *bufio.Reader, log *ScrobblerLog) error {
}
if len(line) == 0 || line[0] != '#' {
err = errors.New(fmt.Sprintf("Unexpected header (line %v)", i))
err = fmt.Errorf("unexpected header (line %v)", i)
} else {
text := string(line)
if i == 0 && !strings.HasPrefix(text, "#AUDIOSCROBBLER/1") {
err = errors.New(fmt.Sprintf("Not a scrobbler log file"))
err = fmt.Errorf("not a scrobbler log file")
}
timezone, found := strings.CutPrefix(text, "#TZ/")
if strings.HasPrefix(text, "#TZ/") {
if found {
log.Timezone = timezone
}