Guest User

Untitled

a guest
Feb 24th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. package list
  2.  
  3. import (
  4. "github.com/cheekybits/genny/generic"
  5. )
  6.  
  7. // Something .
  8. type Something generic.Type
  9.  
  10. // SomethingList .
  11. type SomethingList []Something
  12.  
  13. func NewSomethingList(l []Something) SomethingList {
  14. if l == nil {
  15. return SomethingList([]Something{})
  16. }
  17. return SomethingList(l)
  18. }
  19.  
  20. type MappedType generic.Type
  21.  
  22. func (l *SomethingList) Map(f func(s Something) MappedType) []MappedType {
  23. result := []MappedType{}
  24. for _, item := range []Something(*l) {
  25. result = append(result, f(item))
  26. }
  27. return result
  28. }
  29.  
  30. // cat template.go | genny gen "Something=string MappedType=int" > list.go # fine
  31. // cat template.go | genny gen "Something=string MappedType=int,string" > list.go # error
Add Comment
Please, Sign In to add comment