Guest User

Untitled

a guest
Jul 23rd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. type Timestamp time.Time
  2. func (t *Timestamp) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
  3. return xml.Attr{Name: name, Value: t.time2str()}, nil
  4. }
  5.  
  6. func (t *Timestamp) UnmarshalXMLAttr(attr xml.Attr) (err error) {
  7. return t.str2time(attr.Value)
  8. }
  9.  
  10. type MyStruct struct {
  11. Start Timestamp `xml:"start,attr"`
  12. }
  13.  
  14. import MyPkg "github.com/user/pkg"
  15. ...
  16.  
  17. var MyStructDefinition MyPkg.MyStruct
  18.  
  19. MyStructDefinition.Timestamp = MyPkg.Timestamp{}
  20.  
  21. marshalled, err := xml.Marshal(run)
  22. if err != nil {
  23. fmt.Println(err)
  24. }
  25.  
  26. xml: unsupported type: MyPkg.Timestamp
Add Comment
Please, Sign In to add comment