diff --git a/README.md b/README.md index 9fbeb54..92dd6cd 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ [![GoDoc](https://godoc.org/github.com/steambap/captcha?status.svg)](https://godoc.org/github.com/steambap/captcha) [![Build Status](https://travis-ci.org/steambap/captcha.svg)](https://travis-ci.org/steambap/captcha) +[![Go Report Card](https://goreportcard.com/badge/github.com/steambap/captcha)](https://goreportcard.com/report/github.com/steambap/captcha) diff --git a/captcha.go b/captcha.go index 1716fd2..2c88a51 100644 --- a/captcha.go +++ b/captcha.go @@ -72,7 +72,7 @@ func (data *Data) WriteTo(w io.Writer) error { func init() { var err error - ttfFont, err = freetype.ParseFont(TTF) + ttfFont, err = freetype.ParseFont(ttf) if err != nil { panic(err) } @@ -159,10 +159,10 @@ func drawSineCurve(img *image.NRGBA, opts *Options) { func randomDarkColor() hsva { hue := float64(rng.Intn(361)) / 360 - saturation := 0.6 + rng.Float64() * 0.2 - value := 0.25 + rng.Float64() * 0.2 + saturation := 0.6 + rng.Float64()*0.2 + value := 0.25 + rng.Float64()*0.2 - return hsva{h: hue, s:saturation, v:value, a:uint8(255)} + return hsva{h: hue, s: saturation, v: value, a: uint8(255)} } func drawText(text string, img *image.NRGBA, opts *Options) error { diff --git a/example/main.go b/example/main.go index 05b3f02..4cb66dc 100644 --- a/example/main.go +++ b/example/main.go @@ -8,8 +8,8 @@ import ( ) func main() { - http.HandleFunc("/", IndexHandle) - http.HandleFunc("/captcha", CaptchaHandle) + http.HandleFunc("/", indexHandle) + http.HandleFunc("/captcha", captchaHandle) fmt.Println("Server start at port 8080") err := http.ListenAndServe(":8080", nil) if err != nil { @@ -17,7 +17,7 @@ func main() { } } -func IndexHandle(w http.ResponseWriter, _ *http.Request) { +func indexHandle(w http.ResponseWriter, _ *http.Request) { doc, err := template.ParseFiles("index.html") if err != nil { fmt.Fprint(w, err.Error()) @@ -26,7 +26,7 @@ func IndexHandle(w http.ResponseWriter, _ *http.Request) { doc.Execute(w, nil) } -func CaptchaHandle(w http.ResponseWriter, _ *http.Request) { +func captchaHandle(w http.ResponseWriter, _ *http.Request) { img, err := captcha.New(150, 50) if err != nil { fmt.Fprint(w, nil) diff --git a/font.go b/font.go index 6439172..f35b407 100644 --- a/font.go +++ b/font.go @@ -3,7 +3,7 @@ package captcha // The following is Comismsh TrueType font data. -var TTF = []byte{ +var ttf = []byte{ 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x40, 0x00, 0x04, 0x00, 0xc0, 0x4f, 0x53, 0x2f, 0x32, 0x7f, 0x0c, 0x33, 0xcc, 0x00, 0x01, 0x37, 0xf8, 0x00, 0x00, 0x00, 0x56, 0x50, 0x43, 0x4c, 0x54, 0x61, 0x79, 0x01, 0xab, 0x00, 0x01, 0x38, 0x50, 0x00, 0x00, 0x00, 0x36, 0x63, 0x6d, 0x61, 0x70, diff --git a/fonts/gen.go b/fonts/gen.go index fbdb431..0ab103f 100644 --- a/fonts/gen.go +++ b/fonts/gen.go @@ -21,7 +21,7 @@ func main() { fmt.Fprint(buf, "// DO NOT EDIT. This file is generated.\n\n") fmt.Fprint(buf, "package captcha\n\n") fmt.Fprint(buf, "// The following is Comismsh TrueType font data.\n") - fmt.Fprint(buf, "var TTF = []byte{") + fmt.Fprint(buf, "var ttf = []byte{") for i, x := range src { if i&15 == 0 { buf.WriteByte('\n')