Skip to content

Commit

Permalink
update to use new io.Seek consts, require min go1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
dhowden committed Apr 2, 2018
1 parent 1264d43 commit e80a3fa
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: go

go:
- 1.4
- 1.7
- tip
3 changes: 2 additions & 1 deletion cmd/check/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package main
import (
"flag"
"fmt"
"io"
"net/url"
"os"
"path/filepath"
Expand Down Expand Up @@ -175,7 +176,7 @@ func (p *processor) do(ch <-chan string) {
}

if *sum {
_, err = tf.Seek(0, os.SEEK_SET)
_, err = tf.Seek(0, io.SeekStart)
if err != nil {
fmt.Println("DIED:", path, "error seeking back to 0:", err)
return
Expand Down
3 changes: 1 addition & 2 deletions flac.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package tag
import (
"errors"
"io"
"os"
)

// blockType is a type which represents an enumeration of valid FLAC blocks
Expand Down Expand Up @@ -80,7 +79,7 @@ func (m *metadataFLAC) readFLACMetadataBlock(r io.ReadSeeker) (last bool, err er
err = m.readPictureBlock(r)

default:
_, err = r.Seek(int64(blockLen), os.SEEK_CUR)
_, err = r.Seek(int64(blockLen), io.SeekCurrent)
}
return
}
Expand Down
7 changes: 3 additions & 4 deletions id.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package tag
import (
"fmt"
"io"
"os"
)

// Identify identifies the format and file type of the data in the ReadSeeker.
Expand All @@ -13,7 +12,7 @@ func Identify(r io.ReadSeeker) (format Format, fileType FileType, err error) {
return
}

_, err = r.Seek(-11, os.SEEK_CUR)
_, err = r.Seek(-11, io.SeekCurrent)
if err != nil {
err = fmt.Errorf("could not seek back to original position: %v", err)
return
Expand Down Expand Up @@ -59,7 +58,7 @@ func Identify(r io.ReadSeeker) (format Format, fileType FileType, err error) {
return format, MP3, nil
}

n, err := r.Seek(-128, os.SEEK_END)
n, err := r.Seek(-128, io.SeekEnd)
if err != nil {
return
}
Expand All @@ -69,7 +68,7 @@ func Identify(r io.ReadSeeker) (format Format, fileType FileType, err error) {
return
}

_, err = r.Seek(-n, os.SEEK_CUR)
_, err = r.Seek(-n, io.SeekCurrent)
if err != nil {
return
}
Expand Down
3 changes: 1 addition & 2 deletions id3v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package tag
import (
"errors"
"io"
"os"
"strconv"
"strings"
)
Expand Down Expand Up @@ -44,7 +43,7 @@ var ErrNotID3v1 = errors.New("invalid ID3v1 header")
// ReadID3v1Tags reads ID3v1 tags from the io.ReadSeeker. Returns ErrNotID3v1
// if there are no ID3v1 tags, otherwise non-nil error if there was a problem.
func ReadID3v1Tags(r io.ReadSeeker) (Metadata, error) {
_, err := r.Seek(-128, os.SEEK_END)
_, err := r.Seek(-128, io.SeekEnd)
if err != nil {
return nil, err
}
Expand Down
5 changes: 2 additions & 3 deletions mp4.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"errors"
"fmt"
"io"
"os"
"strconv"
)

Expand Down Expand Up @@ -113,7 +112,7 @@ func (m metadataMP4) readAtoms(r io.ReadSeeker) error {
}

if !ok {
_, err := r.Seek(int64(size-8), os.SEEK_CUR)
_, err := r.Seek(int64(size-8), io.SeekCurrent)
if err != nil {
return err
}
Expand Down Expand Up @@ -246,7 +245,7 @@ func readCustomAtom(r io.ReadSeeker, size uint32) (string, uint32, error) {
case "data":
// Found the "data" atom, rewind
dataSize = subSize + 8 // will need to re-read "data" + size (4 + 4)
_, err := r.Seek(-8, os.SEEK_CUR)
_, err := r.Seek(-8, io.SeekCurrent)
if err != nil {
return "", 0, err
}
Expand Down
13 changes: 6 additions & 7 deletions ogg.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package tag
import (
"errors"
"io"
"os"
)

const (
Expand All @@ -30,7 +29,7 @@ func ReadOGGTags(r io.ReadSeeker) (Metadata, error) {

// Skip 22 bytes of Page header to read page_segments length byte at position 26
// See http://www.xiph.org/ogg/doc/framing.html
_, err = r.Seek(22, os.SEEK_CUR)
_, err = r.Seek(22, io.SeekCurrent)
if err != nil {
return nil, err
}
Expand All @@ -41,7 +40,7 @@ func ReadOGGTags(r io.ReadSeeker) (Metadata, error) {
}

// Seek and discard the segments
_, err = r.Seek(int64(nS), os.SEEK_CUR)
_, err = r.Seek(int64(nS), io.SeekCurrent)
if err != nil {
return nil, err
}
Expand All @@ -57,7 +56,7 @@ func ReadOGGTags(r io.ReadSeeker) (Metadata, error) {

// Seek and discard 29 bytes from common and identification header
// See http://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-610004.2
_, err = r.Seek(29, os.SEEK_CUR)
_, err = r.Seek(29, io.SeekCurrent)
if err != nil {
return nil, err
}
Expand All @@ -73,7 +72,7 @@ func ReadOGGTags(r io.ReadSeeker) (Metadata, error) {
}

// Skip page 2 header, same as line 30
_, err = r.Seek(22, os.SEEK_CUR)
_, err = r.Seek(22, io.SeekCurrent)
if err != nil {
return nil, err
}
Expand All @@ -83,7 +82,7 @@ func ReadOGGTags(r io.ReadSeeker) (Metadata, error) {
return nil, err
}

_, err = r.Seek(int64(nS), os.SEEK_CUR)
_, err = r.Seek(int64(nS), io.SeekCurrent)
if err != nil {
return nil, err
}
Expand All @@ -98,7 +97,7 @@ func ReadOGGTags(r io.ReadSeeker) (Metadata, error) {
}

// Seek and discard 6 bytes from common header
_, err = r.Seek(6, os.SEEK_CUR)
_, err = r.Seek(6, io.SeekCurrent)
if err != nil {
return nil, err
}
Expand Down
15 changes: 7 additions & 8 deletions sum.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"fmt"
"hash"
"io"
"os"
)

// Sum creates a checksum of the audio file data provided by the io.ReadSeeker which is metadata
Expand All @@ -18,7 +17,7 @@ func Sum(r io.ReadSeeker) (string, error) {
return "", err
}

_, err = r.Seek(-11, os.SEEK_CUR)
_, err = r.Seek(-11, io.SeekCurrent)
if err != nil {
return "", fmt.Errorf("could not seek back to original position: %v", err)
}
Expand Down Expand Up @@ -75,7 +74,7 @@ func SumAtoms(r io.ReadSeeker) (string, error) {
switch name {
case "meta":
// next_item_id (int32)
_, err := r.Seek(4, os.SEEK_CUR)
_, err := r.Seek(4, io.SeekCurrent)
if err != nil {
return "", err
}
Expand All @@ -93,20 +92,20 @@ func SumAtoms(r io.ReadSeeker) (string, error) {
return hashSum(h), nil
}

_, err = r.Seek(int64(size-8), os.SEEK_CUR)
_, err = r.Seek(int64(size-8), io.SeekCurrent)
if err != nil {
return "", fmt.Errorf("error reading '%v' tag: %v", name, err)
}
}
}

func sizeToEndOffset(r io.ReadSeeker, offset int64) (int64, error) {
n, err := r.Seek(-128, os.SEEK_END)
n, err := r.Seek(-128, io.SeekEnd)
if err != nil {
return 0, fmt.Errorf("error seeking end offset (%d bytes): %v", offset, err)
}

_, err = r.Seek(-n, os.SEEK_CUR)
_, err = r.Seek(-n, io.SeekCurrent)
if err != nil {
return 0, fmt.Errorf("error seeking back to original position: %v", err)
}
Expand Down Expand Up @@ -142,7 +141,7 @@ func SumID3v2(r io.ReadSeeker) (string, error) {
return "", fmt.Errorf("error reading ID3v2 header: %v", err)
}

_, err = r.Seek(int64(header.Size), os.SEEK_CUR)
_, err = r.Seek(int64(header.Size), io.SeekCurrent)
if err != nil {
return "", fmt.Errorf("error seeking to end of ID3V2 header: %v", err)
}
Expand Down Expand Up @@ -211,7 +210,7 @@ func skipFLACMetadataBlock(r io.ReadSeeker) (last bool, err error) {
return
}

_, err = r.Seek(int64(blockLen), os.SEEK_CUR)
_, err = r.Seek(int64(blockLen), io.SeekCurrent)
return
}

Expand Down
3 changes: 1 addition & 2 deletions tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"errors"
"fmt"
"io"
"os"
)

// ErrNoTagsFound is the error returned by ReadFrom when the metadata format
Expand All @@ -34,7 +33,7 @@ func ReadFrom(r io.ReadSeeker) (Metadata, error) {
return nil, err
}

_, err = r.Seek(-11, os.SEEK_CUR)
_, err = r.Seek(-11, io.SeekCurrent)
if err != nil {
return nil, fmt.Errorf("could not seek back to original position: %v", err)
}
Expand Down

0 comments on commit e80a3fa

Please sign in to comment.