From ef48fb2be1f74d1ba19ca69b2e70b5e50ec7a244 Mon Sep 17 00:00:00 2001 From: Thomas Pelletier Date: Tue, 2 Feb 2021 12:12:10 -0500 Subject: [PATCH] Expose MarshalOrder (#470) It is needed as argument to some already public function. Fixes #459 Ref #469 --- marshal.go | 8 ++++---- tomltree_write.go | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/marshal.go b/marshal.go index 365543a..1d8932e 100644 --- a/marshal.go +++ b/marshal.go @@ -57,12 +57,12 @@ var annotationDefault = annotation{ defaultValue: tagDefault, } -type marshalOrder int +type MarshalOrder int // Orders the Encoder can write the fields to the output stream. const ( // Sort fields alphabetically. - OrderAlphabetical marshalOrder = iota + 1 + OrderAlphabetical MarshalOrder = iota + 1 // Preserve the order the fields are encountered. For example, the order of fields in // a struct. OrderPreserve @@ -256,7 +256,7 @@ type Encoder struct { annotation line int col int - order marshalOrder + order MarshalOrder promoteAnon bool indentation string } @@ -317,7 +317,7 @@ func (e *Encoder) ArraysWithOneElementPerLine(v bool) *Encoder { } // Order allows to change in which order fields will be written to the output stream. -func (e *Encoder) Order(ord marshalOrder) *Encoder { +func (e *Encoder) Order(ord MarshalOrder) *Encoder { e.order = ord return e } diff --git a/tomltree_write.go b/tomltree_write.go index 0586122..1d13217 100644 --- a/tomltree_write.go +++ b/tomltree_write.go @@ -103,7 +103,7 @@ func encodeTomlString(value string) string { return b.String() } -func tomlTreeStringRepresentation(t *Tree, ord marshalOrder) (string, error) { +func tomlTreeStringRepresentation(t *Tree, ord MarshalOrder) (string, error) { var orderedVals []sortNode switch ord { case OrderPreserve: @@ -126,7 +126,7 @@ func tomlTreeStringRepresentation(t *Tree, ord marshalOrder) (string, error) { return "{ " + strings.Join(values, ", ") + " }", nil } -func tomlValueStringRepresentation(v interface{}, commented string, indent string, ord marshalOrder, arraysOneElementPerLine bool) (string, error) { +func tomlValueStringRepresentation(v interface{}, commented string, indent string, ord MarshalOrder, arraysOneElementPerLine bool) (string, error) { // this interface check is added to dereference the change made in the writeTo function. // That change was made to allow this function to see formatting options. tv, ok := v.(*tomlValue) @@ -310,7 +310,7 @@ func (t *Tree) writeTo(w io.Writer, indent, keyspace string, bytesCount int64, a return t.writeToOrdered(w, indent, keyspace, bytesCount, arraysOneElementPerLine, OrderAlphabetical, " ", false) } -func (t *Tree) writeToOrdered(w io.Writer, indent, keyspace string, bytesCount int64, arraysOneElementPerLine bool, ord marshalOrder, indentString string, parentCommented bool) (int64, error) { +func (t *Tree) writeToOrdered(w io.Writer, indent, keyspace string, bytesCount int64, arraysOneElementPerLine bool, ord MarshalOrder, indentString string, parentCommented bool) (int64, error) { var orderedVals []sortNode switch ord {