Fix linter warnings

This commit is contained in:
Alex Yatskov 2023-11-11 11:04:37 -08:00
parent 56cef06332
commit 7f13496b6f
3 changed files with 10 additions and 11 deletions

View File

@ -4,6 +4,7 @@ import (
"encoding/binary" "encoding/binary"
"fmt" "fmt"
"hash/crc32" "hash/crc32"
"io"
"os" "os"
"path/filepath" "path/filepath"
"sort" "sort"
@ -47,12 +48,12 @@ func (self *cache) storeFile(context *Context, outputFile *File, inputFiles []*F
} }
defer fp.Close() defer fp.Close()
offset, err := outputFile.Seek(0, os.SEEK_CUR) offset, err := outputFile.Seek(0, io.SeekCurrent)
if err != nil { if err != nil {
return err return err
} }
if _, err := outputFile.Seek(0, os.SEEK_SET); err != nil { if _, err := outputFile.Seek(0, io.SeekStart); err != nil {
return err return err
} }
@ -60,7 +61,7 @@ func (self *cache) storeFile(context *Context, outputFile *File, inputFiles []*F
return err return err
} }
if _, err := outputFile.Seek(offset, os.SEEK_SET); err != nil { if _, err := outputFile.Seek(offset, io.SeekStart); err != nil {
return err return err
} }

View File

@ -4,7 +4,6 @@ import (
"bytes" "bytes"
"errors" "errors"
"io" "io"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"runtime" "runtime"
@ -31,7 +30,7 @@ type Context struct {
// CreateFileFrom data creates a new file instance from the provided data buffer. // CreateFileFrom data creates a new file instance from the provided data buffer.
func (self *Context) CreateFileFromReader(sourcePath string, reader io.Reader) (*File, error) { func (self *Context) CreateFileFromReader(sourcePath string, reader io.Reader) (*File, error) {
data, err := ioutil.ReadAll(reader) data, err := io.ReadAll(reader)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -146,7 +145,7 @@ func (self *Context) step() {
defer wg.Done() defer wg.Done()
for inputFile := range self.filesIn { for inputFile := range self.filesIn {
if processor != nil && self.filtersInt.accept(inputFile) && self.filtersExt.accept(inputFile) { if processor != nil && self.filtersInt.accept(inputFile) && self.filtersExt.accept(inputFile) {
if _, err := inputFile.Seek(0, os.SEEK_SET); err != nil { if _, err := inputFile.Seek(0, io.SeekStart); err != nil {
self.goldsmith.fault("core", inputFile, err) self.goldsmith.fault("core", inputFile, err)
} }
if err := processor.Process(self, inputFile); err != nil { if err := processor.Process(self, inputFile); err != nil {

View File

@ -3,7 +3,6 @@ package goldsmith
import ( import (
"bytes" "bytes"
"io" "io"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"time" "time"
@ -31,7 +30,7 @@ func (self *File) Rename(path string) {
} }
func (self *File) Rewrite(reader io.Reader) error { func (self *File) Rewrite(reader io.Reader) error {
data, err := ioutil.ReadAll(reader) data, err := io.ReadAll(reader)
if err != nil { if err != nil {
return err return err
} }
@ -92,7 +91,7 @@ func (self *File) WriteTo(writer io.Writer) (int64, error) {
// Seek updates the file pointer to the desired position. // Seek updates the file pointer to the desired position.
func (self *File) Seek(offset int64, whence int) (int64, error) { func (self *File) Seek(offset int64, whence int) (int64, error) {
if self.reader == nil && offset == 0 && (whence == os.SEEK_SET || whence == os.SEEK_CUR) { if self.reader == nil && offset == 0 && (whence == io.SeekStart || whence == io.SeekCurrent) {
return 0, nil return 0, nil
} }
@ -163,7 +162,7 @@ func (self *File) export(targetDir string) error {
return err return err
} }
} else { } else {
if _, err := self.Seek(0, os.SEEK_SET); err != nil { if _, err := self.Seek(0, io.SeekStart); err != nil {
return err return err
} }
@ -180,7 +179,7 @@ func (self *File) load() error {
return nil return nil
} }
data, err := ioutil.ReadFile(self.dataPath) data, err := os.ReadFile(self.dataPath)
if err != nil { if err != nil {
return err return err
} }