<pre class="notranslate">What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.
1. <a href="http://play.golang.org/p/o20RjaRdtQ" rel="nofollow">http://play.golang.org/p/o20RjaRdtQ</a>
2.
3.

What is the expected output?

It would be preferable to get
&lt;RPCElementTarget&gt;&lt;running/&gt;&lt;/RPCElementTarget&gt;

What do you see instead?

There is no way to do self terminating elements.  The best we can do is to do a start
and end element with no chardata.  This does not work for my application.  The closest
output is:
&lt;RPCElementTarget&gt;&lt;running&gt;&lt;/running&gt;&lt;/RPCElementTarget&gt;

Which compiler are you using (5g, 6g, 8g, gccgo)?
6g

Which operating system are you using?
OS X 10.9

Which version are you using?  (run 'go version')
go version go1.2 darwin/amd64

Please provide any additional information below.</pre>
<p dir="auto">Please answer these questions before submitting your issue. Thanks!</p>
<h3 dir="auto">What version of Go are you using (<code class="notranslate">go version</code>)?</h3>
<p dir="auto">go version go1.8.3 darwin/amd64</p>
<h3 dir="auto">What operating system and processor architecture are you using (<code class="notranslate">go env</code>)?</h3>
<p dir="auto">GOARCH="amd64"<br>
GOBIN=""<br>
GOEXE=""<br>
GOHOSTARCH="amd64"<br>
GOHOSTOS="darwin"<br>
GOOS="darwin"<br>
GOPATH="/Users/xxx/.go:/Users/xxx/workspace/goproject"<br>
GORACE=""<br>
GOROOT="/usr/local/Cellar/go/1.8.3/libexec"<br>
GOTOOLDIR="/usr/local/Cellar/go/1.8.3/libexec/pkg/tool/darwin_amd64"<br>
GCCGO="gccgo"<br>
CC="clang"<br>
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/53/r61bh2fj1hg9n0w03fs__7kc0000gn/T/go-build440341166=/tmp/go-build -gno-record-gcc-switches -fno-common"<br>
CXX="clang++"<br>
CGO_ENABLED="1"<br>
PKG_CONFIG="pkg-config"<br>
CGO_CFLAGS="-g -O2"<br>
CGO_CPPFLAGS=""<br>
CGO_CXXFLAGS="-g -O2"<br>
CGO_FFLAGS="-g -O2"<br>
CGO_LDFLAGS="-g -O2"</p>
<h3 dir="auto">What did you do?</h3>
<p dir="auto">I want to marshal a xml struct which has a self-closing tag field. After looking up in golang doc, there isn't an official support. In <a href="https://groups.google.com/forum/#!topic/golang-nuts/guG6iOCRu08" rel="nofollow">google group</a> they use string.Replace, it's ugly. It seems we could write marshal func for the custom struct, by i'm willing to see an official support like</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="	type Person struct {
		XMLName   xml.Name `xml:&quot;person&quot;`
		Id        int      `xml:&quot;id,attr&quot;`
		FirstName string   `xml:&quot;name&gt;first&quot;`
		LastName  string   `xml:&quot;name&gt;last&quot;`
		Age       int      `xml:&quot;age&quot;`
		Height    float32  `xml:&quot;height,omitempty&quot;`
		Married   bool
		Address
		Comment string `xml:&quot;,comment&quot;`
		Balabala string `xml:&quot;balabala,allowempty&quot;`  // i want something like this
	}"><pre class="notranslate"><code class="notranslate">	type Person struct {
		XMLName   xml.Name `xml:"person"`
		Id        int      `xml:"id,attr"`
		FirstName string   `xml:"name&gt;first"`
		LastName  string   `xml:"name&gt;last"`
		Age       int      `xml:"age"`
		Height    float32  `xml:"height,omitempty"`
		Married   bool
		Address
		Comment string `xml:",comment"`
		Balabala string `xml:"balabala,allowempty"`  // i want something like this
	}
</code></pre></div>
<p dir="auto">In xml standard, a self-closing tag is permitted.<br>
<a href="https://www.w3.org/TR/REC-xml/#dt-empty" rel="nofollow">https://www.w3.org/TR/REC-xml/#dt-empty</a></p>
<p dir="auto">And empty-element tag should be used, and should only be used, for elements which are declared EMPTY.<br>
<a href="https://www.w3.org/TR/REC-xml/#d0e2480" rel="nofollow">https://www.w3.org/TR/REC-xml/#d0e2480</a></p>