🚨 A bunch of small improvements from linter

This commit is contained in:
Dan Jones 2025-03-19 18:05:16 -05:00
commit 8f02956ecd
10 changed files with 51 additions and 47 deletions

View file

@ -2,14 +2,14 @@ package nomino
import (
"crypto"
"encoding/hex"
"errors"
"fmt"
"hash"
"github.com/gosimple/slug"
)
// ErrMissingOriginal is the error returned by Slug if there is no filename
// ErrMissingOriginal is the error returned by Slug if there is no filename.
var ErrMissingOriginal = errors.New("missing original filename")
func getOriginal(c *Config) (string, error) {
@ -37,10 +37,10 @@ func Slug(lang ...string) Generator {
}
}
// HashingFunc is a function that generates a hash.Hash
// HashingFunc is a function that generates a hash.Hash.
type HashingFunc func() hash.Hash
// New allows HashingFunc to be used as a Hasher
// New allows HashingFunc to be used as a Hasher.
func (hf HashingFunc) New() hash.Hash {
return hf()
}
@ -51,7 +51,7 @@ type Hasher interface {
New() hash.Hash
}
// ErrInvalidHash is returned by the Hash generator when an invalid HashType is passed
// ErrInvalidHash is returned by the Hash generator when an invalid HashType is passed.
var ErrInvalidHash = errors.New("invalid hash type")
// Hash generates a name from a hash of the filename.
@ -70,6 +70,6 @@ func Hash(h Hasher) Generator {
}
hs := h.New()
hs.Write([]byte(name))
return fmt.Sprintf("%x", hs.Sum(nil)), nil
return hex.EncodeToString(hs.Sum(nil)), nil
}
}