diff --git a/pkg/captcha/captcha.go b/pkg/captcha/captcha.go index 774df00..6e3b746 100644 --- a/pkg/captcha/captcha.go +++ b/pkg/captcha/captcha.go @@ -36,12 +36,7 @@ type Captcha interface { // BaseCaptcha is a base implementation of a CAPTCHA. // // All derivatives that embed this struct only need to -// implement GetImage() and generateImage() methods. -// And GetImage() could simply be copied. -// -// You need to do that because in Go there is no inheritance, -// and if you won't do that, calling a base GetImage -// method will call an empty base generateImage() method. +// implement Image() method. type BaseCaptcha struct { Answer Answer Solved bool @@ -52,11 +47,6 @@ func (c *BaseCaptcha) Image(style string) *image.Image { return nil } -func (c *BaseCaptcha) Solve(answer Answer) bool { - c.Solved = c.Answer == answer - return c.Solved -} - func (c *BaseCaptcha) GetAnswer() Answer { if c.Answer == "" { c.Answer = NewIntAnswer() @@ -64,6 +54,11 @@ func (c *BaseCaptcha) GetAnswer() Answer { return c.Answer } +func (c *BaseCaptcha) Solve(answer Answer) bool { + c.Solved = c.Answer == answer + return c.Solved +} + func (c *BaseCaptcha) IsSolved() bool { return c.Solved }