mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-30 05:37:05 +02:00
Use fmt.Errorf, error strings should start lowercase
This commit is contained in:
parent
a9e07915ce
commit
28ed1183e4
4 changed files with 10 additions and 15 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue