add: go report in readme

update: minor fix for go report
This commit is contained in:
Weilin Shi 2017-09-19 14:10:49 +08:00
parent f5e32fac77
commit 25375da284
5 changed files with 11 additions and 10 deletions

View File

@ -4,6 +4,7 @@
[![GoDoc](https://godoc.org/github.com/steambap/captcha?status.svg)](https://godoc.org/github.com/steambap/captcha) [![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) [![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)
</div> </div>

View File

@ -72,7 +72,7 @@ func (data *Data) WriteTo(w io.Writer) error {
func init() { func init() {
var err error var err error
ttfFont, err = freetype.ParseFont(TTF) ttfFont, err = freetype.ParseFont(ttf)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@ -159,10 +159,10 @@ func drawSineCurve(img *image.NRGBA, opts *Options) {
func randomDarkColor() hsva { func randomDarkColor() hsva {
hue := float64(rng.Intn(361)) / 360 hue := float64(rng.Intn(361)) / 360
saturation := 0.6 + rng.Float64() * 0.2 saturation := 0.6 + rng.Float64()*0.2
value := 0.25 + 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 { func drawText(text string, img *image.NRGBA, opts *Options) error {

View File

@ -8,8 +8,8 @@ import (
) )
func main() { func main() {
http.HandleFunc("/", IndexHandle) http.HandleFunc("/", indexHandle)
http.HandleFunc("/captcha", CaptchaHandle) http.HandleFunc("/captcha", captchaHandle)
fmt.Println("Server start at port 8080") fmt.Println("Server start at port 8080")
err := http.ListenAndServe(":8080", nil) err := http.ListenAndServe(":8080", nil)
if err != 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") doc, err := template.ParseFiles("index.html")
if err != nil { if err != nil {
fmt.Fprint(w, err.Error()) fmt.Fprint(w, err.Error())
@ -26,7 +26,7 @@ func IndexHandle(w http.ResponseWriter, _ *http.Request) {
doc.Execute(w, nil) doc.Execute(w, nil)
} }
func CaptchaHandle(w http.ResponseWriter, _ *http.Request) { func captchaHandle(w http.ResponseWriter, _ *http.Request) {
img, err := captcha.New(150, 50) img, err := captcha.New(150, 50)
if err != nil { if err != nil {
fmt.Fprint(w, nil) fmt.Fprint(w, nil)

View File

@ -3,7 +3,7 @@
package captcha package captcha
// The following is Comismsh TrueType font data. // 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, 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, 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, 0x61, 0x79, 0x01, 0xab, 0x00, 0x01, 0x38, 0x50, 0x00, 0x00, 0x00, 0x36, 0x63, 0x6d, 0x61, 0x70,

View File

@ -21,7 +21,7 @@ func main() {
fmt.Fprint(buf, "// DO NOT EDIT. This file is generated.\n\n") fmt.Fprint(buf, "// DO NOT EDIT. This file is generated.\n\n")
fmt.Fprint(buf, "package captcha\n\n") fmt.Fprint(buf, "package captcha\n\n")
fmt.Fprint(buf, "// The following is Comismsh TrueType font data.\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 { for i, x := range src {
if i&15 == 0 { if i&15 == 0 {
buf.WriteByte('\n') buf.WriteByte('\n')