8 // StringService provides operations on strings.
9 type StringService interface {
10 Uppercase(string) (string, error)
14 type stringService struct{}
16 func (stringService) Uppercase(s string) (string, error) {
20 return strings.ToUpper(s), nil
23 func (stringService) Count(s string) int {
27 // ErrEmpty is returned when an input string is empty.
28 var ErrEmpty = errors.New("empty string")
30 // ServiceMiddleware is a chainable behavior modifier for StringService.
31 type ServiceMiddleware func(StringService) StringService