1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
package main type status struct { code int text string } type Status interface { Code() int Text() string } var ( Ok Status = &status{200, "OK"} NotFound Status = &status{404, "Not Found"} ) func (s *status) Code() int { return s.code } func (s *status) Text() string { return s.text }