@@ -23,8 +23,8 @@ import (
2323 "path"
2424 "strings"
2525
26- "github.com/unknwon/com"
2726 "github.com/go-macaron/cache"
27+ "github.com/unknwon/com"
2828 "gopkg.in/macaron.v1"
2929)
3030
@@ -91,7 +91,7 @@ func (c *Captcha) CreateCaptcha() (string, error) {
9191
9292// verify from a request
9393func (c * Captcha ) VerifyReq (req macaron.Request ) bool {
94- req .ParseForm ()
94+ _ = req .ParseForm ()
9595 return c .Verify (req .Form .Get (c .FieldIdName ), req .Form .Get (c .FieldCaptchaName ))
9696}
9797
@@ -111,7 +111,9 @@ func (c *Captcha) Verify(id string, challenge string) bool {
111111 return false
112112 }
113113
114- defer c .store .Delete (key )
114+ defer func () {
115+ _ = c .store .Delete (key )
116+ }()
115117
116118 if len (chars ) != len (challenge ) {
117119 return false
@@ -227,15 +229,15 @@ func Captchaer(options ...Options) macaron.Handler {
227229 chars = cpt .genRandChars ()
228230 if err := cpt .store .Put (key , chars , cpt .Expiration ); err != nil {
229231 ctx .Status (500 )
230- ctx .Write ([]byte ("captcha reload error" ))
232+ _ , _ = ctx .Write ([]byte ("captcha reload error" ))
231233 panic (fmt .Errorf ("reload captcha: %v" , err ))
232234 }
233235 } else {
234236 if v , ok := cpt .store .Get (key ).(string ); ok {
235237 chars = v
236238 } else {
237239 ctx .Status (404 )
238- ctx .Write ([]byte ("captcha not found" ))
240+ _ , _ = ctx .Write ([]byte ("captcha not found" ))
239241 return
240242 }
241243 }
0 commit comments