Assisted-by: GLM 5.3 Flash
This commit is contained in:
+23
@@ -50,6 +50,29 @@ tree, err := interpres.ParseMap([]byte("title = \"x\"\nport = 8080\n"))
|
||||
|
||||
The cancellable variant of `ParseMap`.
|
||||
|
||||
### `func ParseFile(path string) (*Document, error)`
|
||||
|
||||
Reads the file at `path` and parses it into a [Document](#documents), the shape
|
||||
`Parse` gives. Both a read failure and a parse failure come back with the file
|
||||
name as their first words, wrapped so `errors.AsType` still reaches the
|
||||
`SyntaxError` inside a parse failure.
|
||||
|
||||
```go
|
||||
doc, err := interpres.ParseFile("config.toml")
|
||||
```
|
||||
|
||||
### `func Valid(data []byte) error`
|
||||
|
||||
Reports whether `data` is a valid TOML document: `nil` when the parser accepts
|
||||
it, the parse error when it does not. It is the library call the `-validate`
|
||||
mode of interpres-decode is built on.
|
||||
|
||||
```go
|
||||
if err := interpres.Valid(data); err != nil {
|
||||
fmt.Println("invalid:", err)
|
||||
}
|
||||
```
|
||||
|
||||
## Documents
|
||||
|
||||
`Parse` returns a `Document`: the value tree together with what a map cannot
|
||||
|
||||
Reference in New Issue
Block a user