Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: BurntSushi/toml
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 367083acb90725ee360b47901a89bff3b5ddea53
Choose a base ref
..
head repository: BurntSushi/toml
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 030ae5eb5f06d17fea31e002017c78e3e8121f03
Choose a head ref
Showing with 23 additions and 0 deletions.
  1. +23 −0 meta.go
23 changes: 23 additions & 0 deletions meta.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package toml

import "fmt"

// MetaData allows access to meta information about TOML.
//
// It allows determining whether a key has been defined, the TOML type of a
@@ -28,6 +30,27 @@ func NewMetaData() MetaData {
return MetaData{}
}

type (
Doc string
Comment string
)

func (enc *MetaData) Key(key string, args ...interface{}) *MetaData {
for _, a := range args {
switch aa := a.(type) {
default:
panic(fmt.Sprintf("toml.MetaData.Key: unsupported type: %T", a))
case tomlType:
enc.SetType(key, aa)
case Doc:
enc.Doc(key, string(aa))
case Comment:
enc.Comment(key, string(aa))
}
}
return enc
}

func (enc *MetaData) SetType(key string, t tomlType) *MetaData {
enc.types[key] = t
return enc