Add positions in README

This commit is contained in:
Thomas Pelletier
2014-08-29 17:31:58 +02:00
parent e118479061
commit a2495b4806
+24
View File
@@ -14,6 +14,8 @@ This library supports TOML version
## Usage
### Example
Say you have a TOML file that looks like this:
```toml
@@ -46,6 +48,28 @@ if err != nil {
}
```
### Dealing with values
Here are some important functions you need to know in order to work with the
values in a TOML tree:
* `tree.Get("comma.separated.path")` Returns the value at the given path in the
tree as an `interface{}`. It's up to you to cast the result into the right
type.
* `tree.Set("comma.separated.path", value)` Sets the value at the given path in
the tree, creating all necessary intermediate subtrees.
### Dealing with positions
Since
[e118479061](https://github.com/pelletier/go-toml/commit/e1184790610b20d0541fc9f57c181cc5b1fc78be),
go-toml supports positions. This feature allows you to track the positions of
the values inside the source document, for example to provide better feedback in
your application. Using positions works much like values:
* `tree.GetPosition("comma.separated.path")` Returns the position of the given
path in the source.
## Documentation
The documentation is available at