refactor: follow the google go style guide

Document every package and exported identifier, return the log level
from NewLogger instead of keeping it in a package variable, and stop
tests from mutating the argon2 parameters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-22 00:18:02 +01:00
1 parent 048e114fd9
commit d20225982a
21 files changed
+147 -36

No files matched your search

+3
View File
@@ -7,10 +7,12 @@ import (
"github.com/redis/go-redis/v9"
)
// Limiter counts attempts per key in fixed windows stored in Redis.
type Limiter struct {
rdb redis.UniversalClient
}
// NewLimiter returns a Limiter backed by rdb.
func NewLimiter(rdb redis.UniversalClient) *Limiter { return &Limiter{rdb: rdb} }
var incrWithTTL = redis.NewScript(`
@@ -27,6 +29,7 @@ func (l *Limiter) Allow(ctx context.Context, key string, limit int, window time.
return n <= limit, nil
}
// Reset clears the counter for key, e.g. after a successful login.
func (l *Limiter) Reset(ctx context.Context, key string) error {
return l.rdb.Del(ctx, "rl:"+key).Err()
}