diff --git a/captcha.go b/captcha.go index 6048eb6..1ca77c0 100644 --- a/captcha.go +++ b/captcha.go @@ -79,7 +79,7 @@ var _ inject.FastInvoker = (*captchaInvoker)(nil) // `func(flamego.Context, session.Session)`. type captchaInvoker func(flamego.Context, session.Session) -func (invoke captchaInvoker) Invoke(args []interface{}) ([]reflect.Value, error) { +func (invoke captchaInvoker) Invoke(args []any) ([]reflect.Value, error) { invoke(args[0].(flamego.Context), args[1].(session.Session)) return nil, nil } diff --git a/internal/captchautil/captcha.go b/internal/captchautil/captcha.go index 33d028b..15963d8 100644 --- a/internal/captchautil/captcha.go +++ b/internal/captchautil/captcha.go @@ -80,7 +80,7 @@ func Noise(complex Complexity) Option { density = 8 } maxSize := (img.height * img.width) / density - for i := 0; i < maxSize; i++ { + for range maxSize { rw := r.Intn(img.width) rh := r.Intn(img.height) img.nrgba.Set(rw, rh, randomColor()) @@ -114,7 +114,7 @@ func TextNoise(complex Complexity) Option { c.SetHinting(font.HintingFull) rawFontSize := float64(img.height) / (1 + float64(r.Intn(7))/float64(10)) - for i := 0; i < maxSize; i++ { + for range maxSize { text, err := RandomText(1) if err != nil { return errors.Wrap(err, "TextNoise: get random text") @@ -231,7 +231,7 @@ func Curve() Option { } py := float64(0) - for px := 0; px < end; px++ { + for px := range end { if w != 0 { py = float64(a)*math.Sin(w*float64(px)+f) + b + (float64(img.width) / float64(5)) i := img.height / 5 diff --git a/internal/captchautil/random.go b/internal/captchautil/random.go index e4e7b18..21e8f03 100644 --- a/internal/captchautil/random.go +++ b/internal/captchautil/random.go @@ -72,7 +72,7 @@ func RandomText(n int) (string, error) { buffer := make([]byte, n) max := big.NewInt(int64(len(alphanum))) - for i := 0; i < n; i++ { + for i := range n { index, err := randomInt(max) if err != nil { return "", err