Last active
September 6, 2024 03:24
-
-
Save jackspirou/4477e37d1f1c043806e0 to your computer and use it in GitHub Desktop.
Revisions
-
jackspirou revised this gist
Aug 7, 2015 . 1 changed file with 4 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,16 +8,14 @@ func (s StringMap) MarshalXML(e *xml.Encoder, start xml.StartElement) error { tokens := []xml.Token{start} for key, value := range s { t := xml.StartElement{Name: xml.Name{"", key}} tokens = append(tokens, t, xml.CharData(value), xml.EndElement{t.Name}) } tokens = append(tokens, xml.EndElement{start.Name}) for _, t := range tokens { err := e.EncodeToken(t) if err != nil { return err } -
jackspirou revised this gist
Aug 6, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -30,4 +30,4 @@ func (s StringMap) MarshalXML(e *xml.Encoder, start xml.StartElement) error { } return nil } -
jackspirou revised this gist
Aug 6, 2015 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ // StringMap is a map[string]string. type StringMap map[string]string -
jackspirou renamed this gist
Aug 6, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
jackspirou revised this gist
Aug 6, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,7 +22,7 @@ func (s StringMap) MarshalXML(e *xml.Encoder, start xml.StartElement) error { } } // flush to ensure tokens are written err := e.Flush() if err != nil { return err -
jackspirou created this gist
Aug 6, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ // StringMap is a map[string]string. type StringMap map[string]string // StringMap marshals into XML. func (s StringMap) MarshalXML(e *xml.Encoder, start xml.StartElement) error { tokens := []xml.Token{start} for key, value := range s { tok := xml.StartElement{Name: xml.Name{"", key}} tokens = append(tokens, tok) tokens = append(tokens, xml.CharData(value)) tokens = append(tokens, xml.EndElement{tok.Name}) } tokens = append(tokens, xml.EndElement{start.Name}) for _, tok := range tokens { err := e.EncodeToken(tok) if err != nil { return err } } // flush to ensure tokens are written err := e.Flush() if err != nil { return err } return nil }