File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,9 @@ type Element interface {
3838 xml.Marshaler
3939}
4040
41+ // An EmptyElement is an empty KML element.
42+ type EmptyElement struct {}
43+
4144// A ParentElement is a KML element with children.
4245type ParentElement interface {
4346 Element
@@ -61,6 +64,16 @@ func MakeElements[S []T, T Element](s S) []Element {
6164 return elements
6265}
6366
67+ // Empty returns a new EmptyElement.
68+ func Empty () * EmptyElement {
69+ return & EmptyElement {}
70+ }
71+
72+ // MarshalXML implements encoding/xml.Marshaler.MarshalXML.
73+ func (e * EmptyElement ) MarshalXML (* xml.Encoder , xml.StartElement ) error {
74+ return nil
75+ }
76+
6477func encodeElement (encoder * xml.Encoder , startElement xml.StartElement ) error {
6578 if err := encoder .EncodeToken (startElement ); err != nil {
6679 return err
Original file line number Diff line number Diff line change @@ -294,6 +294,11 @@ func TestSimpleElements(t *testing.T) {
294294 element : kml .GxIntValue (1 ),
295295 expected : "<gx:value>1</gx:value>" ,
296296 },
297+ {
298+ name : "Empty" ,
299+ element : kml .Empty (),
300+ expected : "" ,
301+ },
297302 } {
298303 t .Run (tc .name , func (t * testing.T ) {
299304 var builder strings.Builder
You can’t perform that action at this time.
0 commit comments