Use dedicated readStringTrimNULL function in id3v1

This commit is contained in:
jo 2018-09-03 15:15:19 +02:00
parent 5cdccc9693
commit bcc288a50a
2 changed files with 11 additions and 3 deletions

View File

@ -54,17 +54,17 @@ func ReadID3v1Tags(r io.ReadSeeker) (Metadata, error) {
return nil, ErrNotID3v1
}
title, err := readString(r, 30)
title, err := readStringTrimNULL(r, 30)
if err != nil {
return nil, err
}
artist, err := readString(r, 30)
artist, err := readStringTrimNULL(r, 30)
if err != nil {
return nil, err
}
album, err := readString(r, 30)
album, err := readStringTrimNULL(r, 30)
if err != nil {
return nil, err
}

View File

@ -43,6 +43,14 @@ func readBytes(r io.Reader, n int) ([]byte, error) {
}
func readString(r io.Reader, n int) (string, error) {
b, err := readBytes(r, n)
if err != nil {
return "", err
}
return string(b), nil
}
func readStringTrimNULL(r io.Reader, n int) (string, error) {
b, err := readBytes(r, n)
if err != nil {
return "", err