Quick actions

cmd+k|ctrl+k

Navigation

Languages

XML / Configuring XML parsing and serialization / Essential Go

Snippet info

Language

Go

Visibility

public

Author

kkowalczyk

Created

2019-03-26T09:43:35Z

Updated

2019-03-26T09:43:35Z

package main

import (
	"encoding/xml"
	"fmt"
	"log"
)

type ShowComment struct {
	Str string `xml:",comment"`
}

func printXML(v interface{}) {
	d, err := xml.Marshal(v)
	if err != nil {
		log.Fatalf("xml.Marshal failed with '%s'\n", err)
	}
	fmt.Printf("XML: %s\n\n", string(d))
}

func main() {
	v := &ShowComment{
		Str: "comment",
	}
	printXML(v)

}
INFO