Support literal multiline marshal (#485)

Use struct tag `multiline:"true" literal:"true"` to enable it.
This commit is contained in:
Thomas Pelletier
2021-03-25 20:57:38 -04:00
committed by GitHub
parent b59c12a70d
commit ce6fbd7bc0
4 changed files with 46 additions and 1 deletions
+4
View File
@@ -15,6 +15,7 @@ type tomlValue struct {
comment string
commented bool
multiline bool
literal bool
position Position
}
@@ -314,6 +315,7 @@ type SetOptions struct {
Comment string
Commented bool
Multiline bool
Literal bool
}
// SetWithOptions is the same as Set, but allows you to provide formatting
@@ -362,12 +364,14 @@ func (t *Tree) SetPathWithOptions(keys []string, opts SetOptions, value interfac
v.comment = opts.Comment
v.commented = opts.Commented
v.multiline = opts.Multiline
v.literal = opts.Literal
toInsert = v
default:
toInsert = &tomlValue{value: value,
comment: opts.Comment,
commented: opts.Commented,
multiline: opts.Multiline,
literal: opts.Literal,
position: Position{Line: subtree.position.Line + len(subtree.values) + 1, Col: subtree.position.Col}}
}