feat!: rework the public API to json/v2-style variadic options
Test / test (push) Successful in 1m49s
Test / test (push) Successful in 1m49s
Assisted-by: GLM 5.3 Flash
This commit is contained in:
+9
-11
@@ -70,12 +70,11 @@ func ExampleMarshal() {
|
||||
// port = 9090
|
||||
}
|
||||
|
||||
func ExampleDecoder() {
|
||||
func ExampleNumbersAsLiterals() {
|
||||
var tree map[string]any
|
||||
err := interpres.NewDecoder().
|
||||
DisallowUnknownFields().
|
||||
UseNumber().
|
||||
Decode([]byte("rate = 1_000\n"), &tree)
|
||||
err := interpres.Unmarshal([]byte("rate = 1_000\n"), &tree,
|
||||
interpres.RejectUnknownFields(true),
|
||||
interpres.NumbersAsLiterals(true))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@@ -83,16 +82,15 @@ func ExampleDecoder() {
|
||||
// Output: 1_000 1_000
|
||||
}
|
||||
|
||||
func ExampleEncoder() {
|
||||
func ExampleInlineTables() {
|
||||
type Config struct {
|
||||
Title string `toml:"title"`
|
||||
Extras map[string]string `toml:"extras,inline"`
|
||||
}
|
||||
out, err := interpres.NewEncoder().
|
||||
Layout(interpres.LayoutKindDeclaration).
|
||||
LiteralMultiline(80).
|
||||
InlineTables(40).
|
||||
Marshal(Config{Title: "demo", Extras: map[string]string{"b": "two", "a": "one"}})
|
||||
out, err := interpres.Marshal(Config{Title: "demo", Extras: map[string]string{"b": "two", "a": "one"}},
|
||||
interpres.Layout(interpres.LayoutKindDeclaration),
|
||||
interpres.LiteralMultiline(80),
|
||||
interpres.InlineTables(40))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user