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

83 lines
1.6 KiB

  1. package _generated
  2. import "errors"
  3. //go:generate msgp
  4. //msgp:shim ConvertStringVal as:string using:fromConvertStringVal/toConvertStringVal mode:convert
  5. //msgp:ignore ConvertStringVal
  6. func fromConvertStringVal(v ConvertStringVal) (string, error) {
  7. return string(v), nil
  8. }
  9. func toConvertStringVal(s string) (ConvertStringVal, error) {
  10. return ConvertStringVal(s), nil
  11. }
  12. type ConvertStringVal string
  13. type ConvertString struct {
  14. String ConvertStringVal
  15. }
  16. type ConvertStringSlice struct {
  17. Strings []ConvertStringVal
  18. }
  19. type ConvertStringMapValue struct {
  20. Strings map[string]ConvertStringVal
  21. }
  22. //msgp:shim ConvertIntfVal as:interface{} using:fromConvertIntfVal/toConvertIntfVal mode:convert
  23. //msgp:ignore ConvertIntfVal
  24. func fromConvertIntfVal(v ConvertIntfVal) (interface{}, error) {
  25. return v.Test, nil
  26. }
  27. func toConvertIntfVal(s interface{}) (ConvertIntfVal, error) {
  28. return ConvertIntfVal{Test: s.(string)}, nil
  29. }
  30. type ConvertIntfVal struct {
  31. Test string
  32. }
  33. type ConvertIntf struct {
  34. Intf ConvertIntfVal
  35. }
  36. //msgp:shim ConvertErrVal as:string using:fromConvertErrVal/toConvertErrVal mode:convert
  37. //msgp:ignore ConvertErrVal
  38. var (
  39. errConvertFrom = errors.New("error: convert from")
  40. errConvertTo = errors.New("error: convert to")
  41. )
  42. const (
  43. fromFailStr = "fromfail"
  44. toFailStr = "tofail"
  45. )
  46. func fromConvertErrVal(v ConvertErrVal) (string, error) {
  47. s := string(v)
  48. if s == fromFailStr {
  49. return "", errConvertFrom
  50. }
  51. return s, nil
  52. }
  53. func toConvertErrVal(s string) (ConvertErrVal, error) {
  54. if s == toFailStr {
  55. return ConvertErrVal(""), errConvertTo
  56. }
  57. return ConvertErrVal(s), nil
  58. }
  59. type ConvertErrVal string
  60. type ConvertErr struct {
  61. Err ConvertErrVal
  62. }