Skip to content

Commit

Permalink
Make id3Identifier a byte slice
Browse files Browse the repository at this point in the history
  • Loading branch information
n10v committed Jul 17, 2017
1 parent d79f1ee commit 2017222
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions header.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@ package id3v2

import (
"bufio"
"bytes"
"errors"
"io"

"github.com/bogem/id3v2/util"
)

const (
id3Identifier = "ID3"
tagHeaderSize = 10
)
const tagHeaderSize = 10

var (
id3Identifier = []byte("ID3")
errNoTag = errors.New("there is no tag in file")

var errNoTag = errors.New("there is no tag in file")
var ErrSmallHeaderSize = errors.New("size of tag header is less than expected")
ErrSmallHeaderSize = errors.New("size of tag header is less than expected")
)

type tagHeader struct {
FramesSize int64
Expand Down Expand Up @@ -58,12 +60,12 @@ func isID3Tag(data []byte) bool {
if len(data) != len(id3Identifier) {
return false
}
return string(data[0:3]) == id3Identifier
return bytes.Equal(data, id3Identifier)
}

func writeTagHeader(bw *bufio.Writer, framesSize int, version byte) error {
// Identifier
if _, err := bw.WriteString(id3Identifier); err != nil {
if _, err := bw.Write(id3Identifier); err != nil {
return err
}

Expand Down

0 comments on commit 2017222

Please sign in to comment.