Skip to content

Commit

Permalink
fix: linter errors
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Lewis <ianmlewis@gmail.com>
  • Loading branch information
ianlewis committed Nov 3, 2024
1 parent 3ace662 commit 55f8a7b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
6 changes: 5 additions & 1 deletion dict/dict.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,17 @@ type dictReader struct {
dz *dictzip.Reader
}

func (r *dictReader) ReadAt(p []byte, off int64) (n int, err error) {
func (r *dictReader) ReadAt(p []byte, off int64) (int, error) {
if r.dz != nil {
//nolint:wrapcheck // error wrapping is unnecessary.
return r.dz.ReadAt(p, off)
}
//nolint:wrapcheck // error wrapping is unnecessary.
return r.f.ReadAt(p, off)
}

func (r *dictReader) Close() error {
//nolint:wrapcheck // error wrapping is unnecessary.
return r.f.Close()
}

Expand Down Expand Up @@ -281,5 +284,6 @@ func (d *Dict) Word(e *idx.Word) (*Word, error) {

// Close closes the underlying reader for the .dict file.
func (d *Dict) Close() error {
//nolint:wrapcheck // error wrapping is unnecessary.
return d.r.Close()
}
2 changes: 1 addition & 1 deletion idx/idx.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func openIdxFile(ifoPath string) (*os.File, error) {
return nil, fmt.Errorf("opening .idx file: %w", err)
}

return f, err
return f, nil
}

// NewFromIfoPath returns a new in-memory index.
Expand Down
10 changes: 5 additions & 5 deletions stardict.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ type Stardict struct {
}

var (
errDictNotFound = errors.New("no dict file found")
errIdxNotFound = errors.New("no .idx file found")
errNoBookname = errors.New("missing bookname")
errInvalidVersion = errors.New("invalid version")
errInvalidMagic = errors.New("invalid magic data")
Expand Down Expand Up @@ -141,8 +139,10 @@ func Open(path string) (*Stardict, error) {
}

idxoffsetbits := s.ifo.Value("idxoffsetbits")
// TODO: version check should be > 3.0.0
if idxoffsetbits != "" && s.version == "3.0.0" {
idxoffsetbits64, err := strconv.ParseInt(idxoffsetbits, 10, 64)
var idxoffsetbits64 int64
idxoffsetbits64, err = strconv.ParseInt(idxoffsetbits, 10, 64)
if err != nil {
return nil, fmt.Errorf("invalid idxoffsetbits: %w", err)
}
Expand Down Expand Up @@ -268,7 +268,7 @@ func (s *Stardict) Index() (*idx.Idx, error) {
OffsetBits: s.idxoffsetbits,
})
if err != nil {
return nil, err
return nil, fmt.Errorf("opening index: %w", err)
}
s.idx = index

Expand All @@ -286,7 +286,7 @@ func (s *Stardict) Dict() (*dict.Dict, error) {
SameTypeSequence: s.sametypesequence,
})
if err != nil {
return nil, err
return nil, fmt.Errorf("opening dict: %w", err)
}
s.dict = d

Expand Down

0 comments on commit 55f8a7b

Please # to comment.