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:24Z

Updated

2019-03-26T09:43:24Z

package main

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

type ShowAttr struct {
	B bool `xml:"n,attr"`
}

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 := &ShowAttr{
		B: true,
	}
	printXML(v)

}
INFO