You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

copier.go 865 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package tool
  2. import (
  3. "github.com/jinzhu/copier"
  4. "github.com/pkg/errors"
  5. "strconv"
  6. "time"
  7. )
  8. var Converters = []copier.TypeConverter{
  9. {
  10. SrcType: time.Time{},
  11. DstType: copier.String,
  12. Fn: func(src interface{}) (interface{}, error) {
  13. s, ok := src.(time.Time)
  14. if !ok {
  15. return nil, errors.New("src type not matching")
  16. }
  17. return s.Format(time.RFC3339), nil
  18. },
  19. },
  20. {
  21. SrcType: copier.String,
  22. DstType: copier.Int,
  23. Fn: func(src interface{}) (interface{}, error) {
  24. s, ok := src.(string)
  25. if !ok {
  26. return nil, errors.New("src type not matching")
  27. }
  28. return strconv.Atoi(s)
  29. },
  30. },
  31. {
  32. SrcType: copier.String,
  33. DstType: copier.Bool,
  34. Fn: func(src interface{}) (interface{}, error) {
  35. s, ok := src.(string)
  36. if !ok {
  37. return nil, errors.New("src type not matching")
  38. }
  39. return strconv.ParseBool(s)
  40. },
  41. },
  42. }

PCM is positioned as Software stack over Cloud, aiming to build the standards and ecology of heterogeneous cloud collaboration for JCC in a non intrusive and autonomous peer-to-peer manner.