Use dedicated readStringTrimNULL function in id3v1
This commit is contained in:
parent
5cdccc9693
commit
bcc288a50a
6
id3v1.go
6
id3v1.go
@ -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
|
||||
}
|
||||
|
8
util.go
8
util.go
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user