80f3bb27074b417abae4186accb6893d147bcde4.svn-base 561 B

12345678910111213141516171819202122232425262728293031323334
  1. package service
  2. import (
  3. "errors"
  4. )
  5. const (
  6. StrMaxSize = 1024
  7. )
  8. // Service errors
  9. var (
  10. ErrMaxSize = errors.New("maximum size of 1024 bytes exceeded")
  11. ErrStrValue = errors.New("maximum size of 1024 bytes exceeded")
  12. )
  13. type Service interface {
  14. // Concat a and b
  15. Concat(req StringRequest, ret *string) error
  16. }
  17. type StringService struct {
  18. }
  19. func (s StringService) Concat(req StringRequest, ret *string) error {
  20. // test for length overflow
  21. if len(req.A)+len(req.B) > StrMaxSize {
  22. *ret = ""
  23. return ErrMaxSize
  24. }
  25. *ret = req.A + req.B
  26. return nil
  27. }