fix(blogo,prefixedsourcer): remove unused hex function

This commit is contained in:
Guz
2025-01-17 12:02:17 -03:00
parent 29d752da9b
commit 7af97b86d8

View File

@@ -16,8 +16,6 @@
package blogo package blogo
import ( import (
"crypto/rand"
"encoding/hex"
"fmt" "fmt"
"io" "io"
"io/fs" "io/fs"
@@ -40,12 +38,9 @@ type prefixedSourcer struct {
acceptDuplicated bool acceptDuplicated bool
panicOnInit bool panicOnInit bool
skipOnHexError bool
skipOnSourceError bool skipOnSourceError bool
skipOnFSError bool skipOnFSError bool
hexFunc HexFunc
log *slog.Logger log *slog.Logger
} }
@@ -58,21 +53,9 @@ type PrefixedSourcerOpts struct {
NotSkipOnSourceError bool NotSkipOnSourceError bool
NotSkipOnFSError bool NotSkipOnFSError bool
HexFunc HexFunc
Logger *slog.Logger Logger *slog.Logger
} }
type HexFunc = func(n int) (string, error)
func hexFunc(n int) (string, error) {
bytes := make([]byte, n)
if _, err := rand.Read(bytes); err != nil {
return "", err
}
return hex.EncodeToString(bytes), nil
}
func NewPrefixedSourcer(opts ...PrefixedSourcerOpts) PrefixedSourcer { func NewPrefixedSourcer(opts ...PrefixedSourcerOpts) PrefixedSourcer {
opt := PrefixedSourcerOpts{} opt := PrefixedSourcerOpts{}
if len(opts) > 0 { if len(opts) > 0 {
@@ -83,10 +66,6 @@ func NewPrefixedSourcer(opts ...PrefixedSourcerOpts) PrefixedSourcer {
opt.PrefixSeparator = "/" opt.PrefixSeparator = "/"
} }
if opt.HexFunc == nil {
opt.HexFunc = hexFunc
}
if opt.Logger == nil { if opt.Logger == nil {
opt.Logger = slog.New(slog.NewTextHandler(io.Discard, &slog.HandlerOptions{})) opt.Logger = slog.New(slog.NewTextHandler(io.Discard, &slog.HandlerOptions{}))
} }