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)
[![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>

View File

@ -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)
}

View File

@ -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)

View File

@ -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,

View File

@ -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')