Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 34765b4a9e | |||
| 358c8d2c23 | |||
| fd8d0bf4d9 | |||
| a76e18e8c5 | |||
| dff0c128d0 | |||
| 3573ce3770 | |||
| ae933f2e2a | |||
| 3175efb395 | |||
| 9dd7f1af78 | |||
| 4a5c27c299 | |||
| 76cc96f6d8 | |||
| 4835627845 | |||
| cef80b96a4 | |||
| 4040373cfd | |||
| bb026cae89 | |||
| f7d9b9ba53 | |||
| fac33d6fa8 |
@@ -35,7 +35,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ jobs:
|
|||||||
runs-on: "ubuntu-latest"
|
runs-on: "ubuntu-latest"
|
||||||
name: report
|
name: report
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Setup go
|
- name: Setup go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: "1.20"
|
go-version: "1.21"
|
||||||
- name: Run tests with coverage
|
- name: Run tests with coverage
|
||||||
run: ./ci.sh coverage -d "${GITHUB_BASE_REF-HEAD}"
|
run: ./ci.sh coverage -d "${GITHUB_BASE_REF-HEAD}"
|
||||||
|
|||||||
@@ -16,15 +16,15 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: "1.20"
|
go-version: "1.21"
|
||||||
- name: Login to GitHub Container Registry
|
- name: Login to GitHub Container Registry
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
|
|||||||
@@ -11,12 +11,12 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ 'ubuntu-latest', 'windows-latest', 'macos-latest']
|
os: [ 'ubuntu-latest', 'windows-latest', 'macos-latest' ]
|
||||||
go: [ '1.19', '1.20' ]
|
go: [ '1.20', '1.21' ]
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
name: ${{ matrix.go }}/${{ matrix.os }}
|
name: ${{ matrix.go }}/${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Setup go ${{ matrix.go }}
|
- name: Setup go ${{ matrix.go }}
|
||||||
|
|||||||
@@ -4,3 +4,4 @@ cmd/tomll/tomll
|
|||||||
cmd/tomljson/tomljson
|
cmd/tomljson/tomljson
|
||||||
cmd/tomltestgen/tomltestgen
|
cmd/tomltestgen/tomltestgen
|
||||||
dist
|
dist
|
||||||
|
tests/
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ builds:
|
|||||||
- linux_amd64
|
- linux_amd64
|
||||||
- linux_arm64
|
- linux_arm64
|
||||||
- linux_arm
|
- linux_arm
|
||||||
|
- linux_riscv64
|
||||||
- windows_amd64
|
- windows_amd64
|
||||||
- windows_arm64
|
- windows_arm64
|
||||||
- windows_arm
|
- windows_arm
|
||||||
@@ -37,6 +38,7 @@ builds:
|
|||||||
- linux_amd64
|
- linux_amd64
|
||||||
- linux_arm64
|
- linux_arm64
|
||||||
- linux_arm
|
- linux_arm
|
||||||
|
- linux_riscv64
|
||||||
- windows_amd64
|
- windows_amd64
|
||||||
- windows_arm64
|
- windows_arm64
|
||||||
- windows_arm
|
- windows_arm
|
||||||
@@ -55,6 +57,7 @@ builds:
|
|||||||
targets:
|
targets:
|
||||||
- linux_amd64
|
- linux_amd64
|
||||||
- linux_arm64
|
- linux_arm64
|
||||||
|
- linux_riscv64
|
||||||
- linux_arm
|
- linux_arm
|
||||||
- windows_amd64
|
- windows_amd64
|
||||||
- windows_arm64
|
- windows_arm64
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2013 - 2022 Thomas Pelletier, Eric Anderton
|
go-toml v2
|
||||||
|
Copyright (c) 2021 - 2023 Thomas Pelletier
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -45,16 +45,15 @@ to check for typos. [See example in the documentation][strict].
|
|||||||
|
|
||||||
### Contextualized errors
|
### Contextualized errors
|
||||||
|
|
||||||
When most decoding errors occur, go-toml returns [`DecodeError`][decode-err]),
|
When most decoding errors occur, go-toml returns [`DecodeError`][decode-err],
|
||||||
which contains a human readable contextualized version of the error. For
|
which contains a human readable contextualized version of the error. For
|
||||||
example:
|
example:
|
||||||
|
|
||||||
```
|
```
|
||||||
2| key1 = "value1"
|
1| [server]
|
||||||
3| key2 = "missing2"
|
2| path = 100
|
||||||
| ~~~~ missing field
|
| ~~~ cannot decode TOML integer into struct field toml_test.Server.Path of type string
|
||||||
4| key3 = "missing3"
|
3| port = 50
|
||||||
5| key4 = "value4"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
[decode-err]: https://pkg.go.dev/github.com/pelletier/go-toml/v2#DecodeError
|
[decode-err]: https://pkg.go.dev/github.com/pelletier/go-toml/v2#DecodeError
|
||||||
@@ -73,6 +72,26 @@ representation.
|
|||||||
[tlt]: https://pkg.go.dev/github.com/pelletier/go-toml/v2#LocalTime
|
[tlt]: https://pkg.go.dev/github.com/pelletier/go-toml/v2#LocalTime
|
||||||
[tldt]: https://pkg.go.dev/github.com/pelletier/go-toml/v2#LocalDateTime
|
[tldt]: https://pkg.go.dev/github.com/pelletier/go-toml/v2#LocalDateTime
|
||||||
|
|
||||||
|
### Commented config
|
||||||
|
|
||||||
|
Since TOML is often used for configuration files, go-toml can emit documents
|
||||||
|
annotated with [comments and commented-out values][comments-example]. For
|
||||||
|
example, it can generate the following file:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
# Host IP to connect to.
|
||||||
|
host = '127.0.0.1'
|
||||||
|
# Port of the remote server.
|
||||||
|
port = 4242
|
||||||
|
|
||||||
|
# Encryption parameters (optional)
|
||||||
|
# [TLS]
|
||||||
|
# cipher = 'AEAD-AES128-GCM-SHA256'
|
||||||
|
# version = 'TLS 1.3'
|
||||||
|
```
|
||||||
|
|
||||||
|
[comments-example]: https://pkg.go.dev/github.com/pelletier/go-toml/v2#example-Marshal-Commented
|
||||||
|
|
||||||
## Getting started
|
## Getting started
|
||||||
|
|
||||||
Given the following struct, let's see how to read it and write it as TOML:
|
Given the following struct, let's see how to read it and write it as TOML:
|
||||||
@@ -160,12 +179,12 @@ Execution time speedup compared to other Go TOML libraries:
|
|||||||
<tr><th>Benchmark</th><th>go-toml v1</th><th>BurntSushi/toml</th></tr>
|
<tr><th>Benchmark</th><th>go-toml v1</th><th>BurntSushi/toml</th></tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr><td>Marshal/HugoFrontMatter-2</td><td>1.9x</td><td>1.9x</td></tr>
|
<tr><td>Marshal/HugoFrontMatter-2</td><td>1.9x</td><td>2.2x</td></tr>
|
||||||
<tr><td>Marshal/ReferenceFile/map-2</td><td>1.7x</td><td>1.8x</td></tr>
|
<tr><td>Marshal/ReferenceFile/map-2</td><td>1.7x</td><td>2.1x</td></tr>
|
||||||
<tr><td>Marshal/ReferenceFile/struct-2</td><td>2.2x</td><td>2.5x</td></tr>
|
<tr><td>Marshal/ReferenceFile/struct-2</td><td>2.2x</td><td>3.0x</td></tr>
|
||||||
<tr><td>Unmarshal/HugoFrontMatter-2</td><td>2.9x</td><td>2.9x</td></tr>
|
<tr><td>Unmarshal/HugoFrontMatter-2</td><td>2.9x</td><td>2.7x</td></tr>
|
||||||
<tr><td>Unmarshal/ReferenceFile/map-2</td><td>2.6x</td><td>2.9x</td></tr>
|
<tr><td>Unmarshal/ReferenceFile/map-2</td><td>2.6x</td><td>2.7x</td></tr>
|
||||||
<tr><td>Unmarshal/ReferenceFile/struct-2</td><td>4.4x</td><td>5.3x</td></tr>
|
<tr><td>Unmarshal/ReferenceFile/struct-2</td><td>4.6x</td><td>5.1x</td></tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<details><summary>See more</summary>
|
<details><summary>See more</summary>
|
||||||
@@ -178,17 +197,17 @@ provided for completeness.</p>
|
|||||||
<tr><th>Benchmark</th><th>go-toml v1</th><th>BurntSushi/toml</th></tr>
|
<tr><th>Benchmark</th><th>go-toml v1</th><th>BurntSushi/toml</th></tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr><td>Marshal/SimpleDocument/map-2</td><td>1.8x</td><td>2.9x</td></tr>
|
<tr><td>Marshal/SimpleDocument/map-2</td><td>1.8x</td><td>2.7x</td></tr>
|
||||||
<tr><td>Marshal/SimpleDocument/struct-2</td><td>2.7x</td><td>4.2x</td></tr>
|
<tr><td>Marshal/SimpleDocument/struct-2</td><td>2.7x</td><td>3.8x</td></tr>
|
||||||
<tr><td>Unmarshal/SimpleDocument/map-2</td><td>4.5x</td><td>3.1x</td></tr>
|
<tr><td>Unmarshal/SimpleDocument/map-2</td><td>3.8x</td><td>3.0x</td></tr>
|
||||||
<tr><td>Unmarshal/SimpleDocument/struct-2</td><td>6.2x</td><td>3.9x</td></tr>
|
<tr><td>Unmarshal/SimpleDocument/struct-2</td><td>5.6x</td><td>4.1x</td></tr>
|
||||||
<tr><td>UnmarshalDataset/example-2</td><td>3.1x</td><td>3.5x</td></tr>
|
<tr><td>UnmarshalDataset/example-2</td><td>3.0x</td><td>3.2x</td></tr>
|
||||||
<tr><td>UnmarshalDataset/code-2</td><td>2.3x</td><td>3.1x</td></tr>
|
<tr><td>UnmarshalDataset/code-2</td><td>2.3x</td><td>2.9x</td></tr>
|
||||||
<tr><td>UnmarshalDataset/twitter-2</td><td>2.5x</td><td>2.6x</td></tr>
|
<tr><td>UnmarshalDataset/twitter-2</td><td>2.6x</td><td>2.7x</td></tr>
|
||||||
<tr><td>UnmarshalDataset/citm_catalog-2</td><td>2.1x</td><td>2.2x</td></tr>
|
<tr><td>UnmarshalDataset/citm_catalog-2</td><td>2.2x</td><td>2.3x</td></tr>
|
||||||
<tr><td>UnmarshalDataset/canada-2</td><td>1.6x</td><td>1.3x</td></tr>
|
<tr><td>UnmarshalDataset/canada-2</td><td>1.8x</td><td>1.5x</td></tr>
|
||||||
<tr><td>UnmarshalDataset/config-2</td><td>4.3x</td><td>3.2x</td></tr>
|
<tr><td>UnmarshalDataset/config-2</td><td>4.1x</td><td>2.9x</td></tr>
|
||||||
<tr><td>[Geo mean]</td><td>2.7x</td><td>2.8x</td></tr>
|
<tr><td>geomean</td><td>2.7x</td><td>2.8x</td></tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<p>This table can be generated with <code>./ci.sh benchmark -a -html</code>.</p>
|
<p>This table can be generated with <code>./ci.sh benchmark -a -html</code>.</p>
|
||||||
@@ -497,27 +516,20 @@ is not necessary anymore.
|
|||||||
|
|
||||||
V1 used to provide multiple struct tags: `comment`, `commented`, `multiline`,
|
V1 used to provide multiple struct tags: `comment`, `commented`, `multiline`,
|
||||||
`toml`, and `omitempty`. To behave more like the standard library, v2 has merged
|
`toml`, and `omitempty`. To behave more like the standard library, v2 has merged
|
||||||
`toml`, `multiline`, and `omitempty`. For example:
|
`toml`, `multiline`, `commented`, and `omitempty`. For example:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
type doc struct {
|
type doc struct {
|
||||||
// v1
|
// v1
|
||||||
F string `toml:"field" multiline:"true" omitempty:"true"`
|
F string `toml:"field" multiline:"true" omitempty:"true" commented:"true"`
|
||||||
// v2
|
// v2
|
||||||
F string `toml:"field,multiline,omitempty"`
|
F string `toml:"field,multiline,omitempty,commented"`
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Has a result, the `Encoder.SetTag*` methods have been removed, as there is just
|
Has a result, the `Encoder.SetTag*` methods have been removed, as there is just
|
||||||
one tag now.
|
one tag now.
|
||||||
|
|
||||||
|
|
||||||
#### `commented` tag has been removed
|
|
||||||
|
|
||||||
There is no replacement for the `commented` tag. This feature would be better
|
|
||||||
suited in a proper document model for go-toml v2, which has been [cut from
|
|
||||||
scope][nodoc] at the moment.
|
|
||||||
|
|
||||||
#### `Encoder.ArraysWithOneElementPerLine` has been renamed
|
#### `Encoder.ArraysWithOneElementPerLine` has been renamed
|
||||||
|
|
||||||
The new name is `Encoder.SetArraysMultiline`. The behavior should be the same.
|
The new name is `Encoder.SetArraysMultiline`. The behavior should be the same.
|
||||||
|
|||||||
@@ -2,9 +2,6 @@
|
|||||||
|
|
||||||
## Supported Versions
|
## Supported Versions
|
||||||
|
|
||||||
Use this section to tell people about which versions of your project are
|
|
||||||
currently being supported with security updates.
|
|
||||||
|
|
||||||
| Version | Supported |
|
| Version | Supported |
|
||||||
| ---------- | ------------------ |
|
| ---------- | ------------------ |
|
||||||
| Latest 2.x | :white_check_mark: |
|
| Latest 2.x | :white_check_mark: |
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ cover() {
|
|||||||
|
|
||||||
pushd "$dir"
|
pushd "$dir"
|
||||||
go test -covermode=atomic -coverpkg=./... -coverprofile=coverage.out.tmp ./...
|
go test -covermode=atomic -coverpkg=./... -coverprofile=coverage.out.tmp ./...
|
||||||
cat coverage.out.tmp | grep -v fuzz | grep -v testsuite | grep -v tomltestgen | grep -v gotoml-test-decoder > coverage.out
|
grep -Ev '(fuzz|testsuite|tomltestgen|gotoml-test-decoder|gotoml-test-encoder)' coverage.out.tmp > coverage.out
|
||||||
go tool cover -func=coverage.out
|
go tool cover -func=coverage.out
|
||||||
echo "Coverage profile for ${branch}: ${dir}/coverage.out" >&2
|
echo "Coverage profile for ${branch}: ${dir}/coverage.out" >&2
|
||||||
popd
|
popd
|
||||||
@@ -152,7 +152,7 @@ bench() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
export GOMAXPROCS=2
|
export GOMAXPROCS=2
|
||||||
nice -n -19 taskset --cpu-list 0,1 go test '-bench=^Benchmark(Un)?[mM]arshal' -count=5 -run=Nothing ./... | tee "${out}"
|
go test '-bench=^Benchmark(Un)?[mM]arshal' -count=10 -run=Nothing ./... | tee "${out}"
|
||||||
popd
|
popd
|
||||||
|
|
||||||
if [ "${branch}" != "HEAD" ]; then
|
if [ "${branch}" != "HEAD" ]; then
|
||||||
@@ -161,10 +161,12 @@ bench() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fmktemp() {
|
fmktemp() {
|
||||||
if mktemp --version|grep GNU >/dev/null; then
|
if mktemp --version &> /dev/null; then
|
||||||
mktemp --suffix=-$1;
|
# GNU
|
||||||
|
mktemp --suffix=-$1
|
||||||
else
|
else
|
||||||
mktemp -t $1;
|
# BSD
|
||||||
|
mktemp -t $1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,12 +186,14 @@ with open(sys.argv[1]) as f:
|
|||||||
lines.append(line.split(','))
|
lines.append(line.split(','))
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
for line in reversed(lines[1:]):
|
for line in reversed(lines[2:]):
|
||||||
|
if len(line) < 8 or line[0] == "":
|
||||||
|
continue
|
||||||
v2 = float(line[1])
|
v2 = float(line[1])
|
||||||
results.append([
|
results.append([
|
||||||
line[0].replace("-32", ""),
|
line[0].replace("-32", ""),
|
||||||
"%.1fx" % (float(line[3])/v2), # v1
|
"%.1fx" % (float(line[3])/v2), # v1
|
||||||
"%.1fx" % (float(line[5])/v2), # bs
|
"%.1fx" % (float(line[7])/v2), # bs
|
||||||
])
|
])
|
||||||
# move geomean to the end
|
# move geomean to the end
|
||||||
results.append(results[0])
|
results.append(results[0])
|
||||||
@@ -260,10 +264,10 @@ benchmark() {
|
|||||||
|
|
||||||
if [ "$1" = "-html" ]; then
|
if [ "$1" = "-html" ]; then
|
||||||
tmpcsv=`fmktemp csv`
|
tmpcsv=`fmktemp csv`
|
||||||
benchstat -csv -geomean go-toml-v2.txt go-toml-v1.txt bs-toml.txt > $tmpcsv
|
benchstat -format csv go-toml-v2.txt go-toml-v1.txt bs-toml.txt > $tmpcsv
|
||||||
benchstathtml $tmpcsv
|
benchstathtml $tmpcsv
|
||||||
else
|
else
|
||||||
benchstat -geomean go-toml-v2.txt go-toml-v1.txt bs-toml.txt
|
benchstat go-toml-v2.txt go-toml-v1.txt bs-toml.txt
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -f go-toml-v2.txt go-toml-v1.txt bs-toml.txt
|
rm -f go-toml-v2.txt go-toml-v1.txt bs-toml.txt
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"flag"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
|
|
||||||
|
"github.com/pelletier/go-toml/v2/internal/testsuite"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
log.SetFlags(0)
|
||||||
|
flag.Usage = usage
|
||||||
|
flag.Parse()
|
||||||
|
if flag.NArg() != 0 {
|
||||||
|
flag.Usage()
|
||||||
|
}
|
||||||
|
|
||||||
|
err := testsuite.EncodeStdin()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func usage() {
|
||||||
|
log.Printf("Usage: %s < toml-file\n", path.Base(os.Args[0]))
|
||||||
|
flag.PrintDefaults()
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
+43
-88
@@ -7,17 +7,13 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"archive/zip"
|
|
||||||
"bytes"
|
"bytes"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/format"
|
"go/format"
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
@@ -64,30 +60,6 @@ const srcTemplate = "// Generated by tomltestgen for toml-test ref {{.Ref}} on {
|
|||||||
"}\n" +
|
"}\n" +
|
||||||
"{{end}}\n"
|
"{{end}}\n"
|
||||||
|
|
||||||
func downloadTmpFile(url string) string {
|
|
||||||
log.Println("starting to download file from", url)
|
|
||||||
resp, err := http.Get(url)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
tmpfile, err := ioutil.TempFile("", "toml-test-*.zip")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
defer tmpfile.Close()
|
|
||||||
|
|
||||||
copiedLen, err := io.Copy(tmpfile, resp.Body)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
if resp.ContentLength > 0 && copiedLen != resp.ContentLength {
|
|
||||||
panic(fmt.Errorf("copied %d bytes, request body had %d", copiedLen, resp.ContentLength))
|
|
||||||
}
|
|
||||||
return tmpfile.Name()
|
|
||||||
}
|
|
||||||
|
|
||||||
func kebabToCamel(kebab string) string {
|
func kebabToCamel(kebab string) string {
|
||||||
camel := ""
|
camel := ""
|
||||||
nextUpper := true
|
nextUpper := true
|
||||||
@@ -107,19 +79,6 @@ func kebabToCamel(kebab string) string {
|
|||||||
return camel
|
return camel
|
||||||
}
|
}
|
||||||
|
|
||||||
func readFileFromZip(f *zip.File) string {
|
|
||||||
reader, err := f.Open()
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
defer reader.Close()
|
|
||||||
bytes, err := ioutil.ReadAll(reader)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return string(bytes)
|
|
||||||
}
|
|
||||||
|
|
||||||
func templateGoStr(input string) string {
|
func templateGoStr(input string) string {
|
||||||
return strconv.Quote(input)
|
return strconv.Quote(input)
|
||||||
}
|
}
|
||||||
@@ -138,61 +97,57 @@ func main() {
|
|||||||
flag.Usage = usage
|
flag.Usage = usage
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
url := "https://codeload.github.com/BurntSushi/toml-test/zip/" + *ref
|
|
||||||
resultFile := downloadTmpFile(url)
|
|
||||||
defer os.Remove(resultFile)
|
|
||||||
log.Println("file written to", resultFile)
|
|
||||||
|
|
||||||
zipReader, err := zip.OpenReader(resultFile)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
defer zipReader.Close()
|
|
||||||
|
|
||||||
collection := testsCollection{
|
collection := testsCollection{
|
||||||
Ref: *ref,
|
Ref: *ref,
|
||||||
Timestamp: time.Now().Format(time.RFC3339),
|
Timestamp: time.Now().Format(time.RFC3339),
|
||||||
}
|
}
|
||||||
|
|
||||||
zipFilesMap := map[string]*zip.File{}
|
dirContent, _ := filepath.Glob("tests/invalid/**/*.toml")
|
||||||
|
for _, f := range dirContent {
|
||||||
|
filename := strings.TrimPrefix(f, "tests/valid/")
|
||||||
|
name := kebabToCamel(strings.TrimSuffix(filename, ".toml"))
|
||||||
|
|
||||||
for _, f := range zipReader.File {
|
log.Printf("> [%s] %s\n", "invalid", name)
|
||||||
zipFilesMap[f.Name] = f
|
|
||||||
|
tomlContent, err := os.ReadFile(f)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("failed to read test file: %s\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
collection.Invalid = append(collection.Invalid, invalid{
|
||||||
|
Name: name,
|
||||||
|
Input: string(tomlContent),
|
||||||
|
})
|
||||||
|
collection.Count++
|
||||||
}
|
}
|
||||||
|
|
||||||
testFileRegexp := regexp.MustCompile(`([^/]+/tests/(valid|invalid)/(.+))\.(toml)`)
|
dirContent, _ = filepath.Glob("tests/valid/**/*.toml")
|
||||||
for _, f := range zipReader.File {
|
for _, f := range dirContent {
|
||||||
groups := testFileRegexp.FindStringSubmatch(f.Name)
|
filename := strings.TrimPrefix(f, "tests/valid/")
|
||||||
if len(groups) > 0 {
|
name := kebabToCamel(strings.TrimSuffix(filename, ".toml"))
|
||||||
name := kebabToCamel(groups[3])
|
|
||||||
testType := groups[2]
|
|
||||||
|
|
||||||
log.Printf("> [%s] %s\n", testType, name)
|
log.Printf("> [%s] %s\n", "valid", name)
|
||||||
|
|
||||||
tomlContent := readFileFromZip(f)
|
tomlContent, err := os.ReadFile(f)
|
||||||
|
if err != nil {
|
||||||
switch testType {
|
fmt.Printf("failed reading test file: %s\n", err)
|
||||||
case "invalid":
|
os.Exit(1)
|
||||||
collection.Invalid = append(collection.Invalid, invalid{
|
|
||||||
Name: name,
|
|
||||||
Input: tomlContent,
|
|
||||||
})
|
|
||||||
collection.Count++
|
|
||||||
case "valid":
|
|
||||||
baseFilePath := groups[1]
|
|
||||||
jsonFilePath := baseFilePath + ".json"
|
|
||||||
jsonContent := readFileFromZip(zipFilesMap[jsonFilePath])
|
|
||||||
|
|
||||||
collection.Valid = append(collection.Valid, valid{
|
|
||||||
Name: name,
|
|
||||||
Input: tomlContent,
|
|
||||||
JsonRef: jsonContent,
|
|
||||||
})
|
|
||||||
collection.Count++
|
|
||||||
default:
|
|
||||||
panic(fmt.Sprintf("unknown test type: %s", testType))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filename = strings.TrimSuffix(f, ".toml")
|
||||||
|
jsonContent, err := os.ReadFile(filename + ".json")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("failed reading validation json: %s\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
collection.Valid = append(collection.Valid, valid{
|
||||||
|
Name: name,
|
||||||
|
Input: string(tomlContent),
|
||||||
|
JsonRef: string(jsonContent),
|
||||||
|
})
|
||||||
|
collection.Count++
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Collected %d tests from toml-test\n", collection.Count)
|
log.Printf("Collected %d tests from toml-test\n", collection.Count)
|
||||||
@@ -202,7 +157,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
t := template.Must(template.New("src").Funcs(funcMap).Parse(srcTemplate))
|
t := template.Must(template.New("src").Funcs(funcMap).Parse(srcTemplate))
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
err = t.Execute(buf, collection)
|
err := t.Execute(buf, collection)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@@ -216,7 +171,7 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = os.WriteFile(*out, outputBytes, 0644)
|
err = os.WriteFile(*out, outputBytes, 0o644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -318,7 +318,7 @@ func parseFloat(b []byte) (float64, error) {
|
|||||||
if cleaned[0] == '+' || cleaned[0] == '-' {
|
if cleaned[0] == '+' || cleaned[0] == '-' {
|
||||||
start = 1
|
start = 1
|
||||||
}
|
}
|
||||||
if cleaned[start] == '0' && isDigit(cleaned[start+1]) {
|
if cleaned[start] == '0' && len(cleaned) > start+1 && isDigit(cleaned[start+1]) {
|
||||||
return 0, unstable.NewParserError(b, "float integer part cannot have leading zeroes")
|
return 0, unstable.NewParserError(b, "float integer part cannot have leading zeroes")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
//go:build go1.18 || go1.19 || go1.20
|
//go:build go1.18 || go1.19 || go1.20 || go1.21
|
||||||
// +build go1.18 go1.19 go1.20
|
// +build go1.18 go1.19 go1.20 go1.21
|
||||||
|
|
||||||
package toml_test
|
package toml_test
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/pelletier/go-toml/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Remove JSON tags to a data structure as returned by toml-test.
|
// Remove JSON tags to a data structure as returned by toml-test.
|
||||||
@@ -76,14 +78,31 @@ func untag(typed map[string]interface{}) (interface{}, error) {
|
|||||||
return nil, fmt.Errorf("untag: %w", err)
|
return nil, fmt.Errorf("untag: %w", err)
|
||||||
}
|
}
|
||||||
return f, nil
|
return f, nil
|
||||||
|
|
||||||
|
//toml.LocalDate{Year:2020, Month:12, Day:12}
|
||||||
case "datetime":
|
case "datetime":
|
||||||
return parseTime(v, "2006-01-02T15:04:05.999999999Z07:00", false)
|
return time.Parse("2006-01-02T15:04:05.999999999Z07:00", v)
|
||||||
case "datetime-local":
|
case "datetime-local":
|
||||||
return parseTime(v, "2006-01-02T15:04:05.999999999", true)
|
var t toml.LocalDateTime
|
||||||
|
err := t.UnmarshalText([]byte(v))
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("untag: %w", err)
|
||||||
|
}
|
||||||
|
return t, nil
|
||||||
case "date-local":
|
case "date-local":
|
||||||
return parseTime(v, "2006-01-02", true)
|
var t toml.LocalDate
|
||||||
|
err := t.UnmarshalText([]byte(v))
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("untag: %w", err)
|
||||||
|
}
|
||||||
|
return t, nil
|
||||||
case "time-local":
|
case "time-local":
|
||||||
return parseTime(v, "15:04:05.999999999", true)
|
var t toml.LocalTime
|
||||||
|
err := t.UnmarshalText([]byte(v))
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("untag: %w", err)
|
||||||
|
}
|
||||||
|
return t, nil
|
||||||
case "bool":
|
case "bool":
|
||||||
switch v {
|
switch v {
|
||||||
case "true":
|
case "true":
|
||||||
|
|||||||
@@ -48,3 +48,21 @@ func DecodeStdin() error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EncodeStdin is a helper function for the toml-test binary interface. Tagged
|
||||||
|
// JSON is read from STDIN and a resulting TOML representation is written to
|
||||||
|
// STDOUT.
|
||||||
|
func EncodeStdin() error {
|
||||||
|
var j interface{}
|
||||||
|
err := json.NewDecoder(os.Stdin).Decode(&j)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
rm, err := rmTag(j)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("removing tags: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return toml.NewEncoder(os.Stdout).Encode(rm)
|
||||||
|
}
|
||||||
|
|||||||
+34
-2
@@ -148,6 +148,9 @@ func (enc *Encoder) SetIndentTables(indent bool) *Encoder {
|
|||||||
//
|
//
|
||||||
// The "omitempty" option prevents empty values or groups from being emitted.
|
// The "omitempty" option prevents empty values or groups from being emitted.
|
||||||
//
|
//
|
||||||
|
// The "commented" option prefixes the value and all its children with a comment
|
||||||
|
// symbol.
|
||||||
|
//
|
||||||
// In addition to the "toml" tag struct tag, a "comment" tag can be used to emit
|
// In addition to the "toml" tag struct tag, a "comment" tag can be used to emit
|
||||||
// a TOML comment before the value being annotated. Comments are ignored inside
|
// a TOML comment before the value being annotated. Comments are ignored inside
|
||||||
// inline tables. For array tables, the comment is only present before the first
|
// inline tables. For array tables, the comment is only present before the first
|
||||||
@@ -180,6 +183,7 @@ func (enc *Encoder) Encode(v interface{}) error {
|
|||||||
type valueOptions struct {
|
type valueOptions struct {
|
||||||
multiline bool
|
multiline bool
|
||||||
omitempty bool
|
omitempty bool
|
||||||
|
commented bool
|
||||||
comment string
|
comment string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,6 +209,9 @@ type encoderCtx struct {
|
|||||||
// Indentation level
|
// Indentation level
|
||||||
indent int
|
indent int
|
||||||
|
|
||||||
|
// Prefix the current value with a comment.
|
||||||
|
commented bool
|
||||||
|
|
||||||
// Options coming from struct tags
|
// Options coming from struct tags
|
||||||
options valueOptions
|
options valueOptions
|
||||||
}
|
}
|
||||||
@@ -357,6 +364,7 @@ func (enc *Encoder) encodeKv(b []byte, ctx encoderCtx, options valueOptions, v r
|
|||||||
|
|
||||||
if !ctx.inline {
|
if !ctx.inline {
|
||||||
b = enc.encodeComment(ctx.indent, options.comment, b)
|
b = enc.encodeComment(ctx.indent, options.comment, b)
|
||||||
|
b = enc.commented(ctx.commented, b)
|
||||||
b = enc.indent(ctx.indent, b)
|
b = enc.indent(ctx.indent, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -378,6 +386,13 @@ func (enc *Encoder) encodeKv(b []byte, ctx encoderCtx, options valueOptions, v r
|
|||||||
return b, nil
|
return b, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (enc *Encoder) commented(commented bool, b []byte) []byte {
|
||||||
|
if commented {
|
||||||
|
return append(b, "# "...)
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
func isEmptyValue(v reflect.Value) bool {
|
func isEmptyValue(v reflect.Value) bool {
|
||||||
switch v.Kind() {
|
switch v.Kind() {
|
||||||
case reflect.Struct:
|
case reflect.Struct:
|
||||||
@@ -526,6 +541,8 @@ func (enc *Encoder) encodeTableHeader(ctx encoderCtx, b []byte) ([]byte, error)
|
|||||||
|
|
||||||
b = enc.encodeComment(ctx.indent, ctx.options.comment, b)
|
b = enc.encodeComment(ctx.indent, ctx.options.comment, b)
|
||||||
|
|
||||||
|
b = enc.commented(ctx.commented, b)
|
||||||
|
|
||||||
b = enc.indent(ctx.indent, b)
|
b = enc.indent(ctx.indent, b)
|
||||||
|
|
||||||
b = append(b, '[')
|
b = append(b, '[')
|
||||||
@@ -704,6 +721,7 @@ func walkStruct(ctx encoderCtx, t *table, v reflect.Value) {
|
|||||||
options := valueOptions{
|
options := valueOptions{
|
||||||
multiline: opts.multiline,
|
multiline: opts.multiline,
|
||||||
omitempty: opts.omitempty,
|
omitempty: opts.omitempty,
|
||||||
|
commented: opts.commented,
|
||||||
comment: fieldType.Tag.Get("comment"),
|
comment: fieldType.Tag.Get("comment"),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -763,6 +781,7 @@ type tagOptions struct {
|
|||||||
multiline bool
|
multiline bool
|
||||||
inline bool
|
inline bool
|
||||||
omitempty bool
|
omitempty bool
|
||||||
|
commented bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseTag(tag string) (string, tagOptions) {
|
func parseTag(tag string) (string, tagOptions) {
|
||||||
@@ -790,6 +809,8 @@ func parseTag(tag string) (string, tagOptions) {
|
|||||||
opts.inline = true
|
opts.inline = true
|
||||||
case "omitempty":
|
case "omitempty":
|
||||||
opts.omitempty = true
|
opts.omitempty = true
|
||||||
|
case "commented":
|
||||||
|
opts.commented = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -825,8 +846,10 @@ func (enc *Encoder) encodeTable(b []byte, ctx encoderCtx, t table) ([]byte, erro
|
|||||||
hasNonEmptyKV = true
|
hasNonEmptyKV = true
|
||||||
|
|
||||||
ctx.setKey(kv.Key)
|
ctx.setKey(kv.Key)
|
||||||
|
ctx2 := ctx
|
||||||
|
ctx2.commented = kv.Options.commented || ctx2.commented
|
||||||
|
|
||||||
b, err = enc.encodeKv(b, ctx, kv.Options, kv.Value)
|
b, err = enc.encodeKv(b, ctx2, kv.Options, kv.Value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -851,8 +874,10 @@ func (enc *Encoder) encodeTable(b []byte, ctx encoderCtx, t table) ([]byte, erro
|
|||||||
ctx.setKey(table.Key)
|
ctx.setKey(table.Key)
|
||||||
|
|
||||||
ctx.options = table.Options
|
ctx.options = table.Options
|
||||||
|
ctx2 := ctx
|
||||||
|
ctx2.commented = ctx2.commented || ctx.options.commented
|
||||||
|
|
||||||
b, err = enc.encode(b, ctx, table.Value)
|
b, err = enc.encode(b, ctx2, table.Value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -970,6 +995,9 @@ func (enc *Encoder) encodeSliceAsArrayTable(b []byte, ctx encoderCtx, v reflect.
|
|||||||
ctx.shiftKey()
|
ctx.shiftKey()
|
||||||
|
|
||||||
scratch := make([]byte, 0, 64)
|
scratch := make([]byte, 0, 64)
|
||||||
|
|
||||||
|
scratch = enc.commented(ctx.commented, scratch)
|
||||||
|
|
||||||
scratch = append(scratch, "[["...)
|
scratch = append(scratch, "[["...)
|
||||||
|
|
||||||
for i, k := range ctx.parentKey {
|
for i, k := range ctx.parentKey {
|
||||||
@@ -985,6 +1013,10 @@ func (enc *Encoder) encodeSliceAsArrayTable(b []byte, ctx encoderCtx, v reflect.
|
|||||||
|
|
||||||
b = enc.encodeComment(ctx.indent, ctx.options.comment, b)
|
b = enc.encodeComment(ctx.indent, ctx.options.comment, b)
|
||||||
|
|
||||||
|
if enc.indentTables {
|
||||||
|
ctx.indent++
|
||||||
|
}
|
||||||
|
|
||||||
for i := 0; i < v.Len(); i++ {
|
for i := 0; i < v.Len(); i++ {
|
||||||
if i != 0 {
|
if i != 0 {
|
||||||
b = append(b, "\n"...)
|
b = append(b, "\n"...)
|
||||||
|
|||||||
+286
-1
@@ -1201,6 +1201,45 @@ randomize = true
|
|||||||
require.Equal(t, expected, buf.String())
|
require.Equal(t, expected, buf.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMarhsalIssue888(t *testing.T) {
|
||||||
|
type Thing struct {
|
||||||
|
FieldA string `comment:"my field A"`
|
||||||
|
FieldB string `comment:"my field B"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Cfg struct {
|
||||||
|
Custom []Thing `comment:"custom config"`
|
||||||
|
}
|
||||||
|
|
||||||
|
buf := new(bytes.Buffer)
|
||||||
|
|
||||||
|
config := Cfg{
|
||||||
|
Custom: []Thing{
|
||||||
|
{FieldA: "field a 1", FieldB: "field b 1"},
|
||||||
|
{FieldA: "field a 2", FieldB: "field b 2"},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
encoder := toml.NewEncoder(buf).SetIndentTables(true)
|
||||||
|
encoder.Encode(config)
|
||||||
|
|
||||||
|
expected := `# custom config
|
||||||
|
[[Custom]]
|
||||||
|
# my field A
|
||||||
|
FieldA = 'field a 1'
|
||||||
|
# my field B
|
||||||
|
FieldB = 'field b 1'
|
||||||
|
|
||||||
|
[[Custom]]
|
||||||
|
# my field A
|
||||||
|
FieldA = 'field a 2'
|
||||||
|
# my field B
|
||||||
|
FieldB = 'field b 2'
|
||||||
|
`
|
||||||
|
|
||||||
|
require.Equal(t, expected, buf.String())
|
||||||
|
}
|
||||||
|
|
||||||
func TestMarshalNestedAnonymousStructs(t *testing.T) {
|
func TestMarshalNestedAnonymousStructs(t *testing.T) {
|
||||||
type Embedded struct {
|
type Embedded struct {
|
||||||
Value string `toml:"value" json:"value"`
|
Value string `toml:"value" json:"value"`
|
||||||
@@ -1298,7 +1337,7 @@ func TestMarshalUint64Overflow(t *testing.T) {
|
|||||||
|
|
||||||
func TestIndentWithInlineTable(t *testing.T) {
|
func TestIndentWithInlineTable(t *testing.T) {
|
||||||
x := map[string][]map[string]string{
|
x := map[string][]map[string]string{
|
||||||
"one": []map[string]string{
|
"one": {
|
||||||
{"0": "0"},
|
{"0": "0"},
|
||||||
{"1": "1"},
|
{"1": "1"},
|
||||||
},
|
},
|
||||||
@@ -1317,6 +1356,94 @@ func TestIndentWithInlineTable(t *testing.T) {
|
|||||||
assert.Equal(t, expected, buf.String())
|
assert.Equal(t, expected, buf.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type C3 struct {
|
||||||
|
Value int `toml:",commented"`
|
||||||
|
Values []int `toml:",commented"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type C2 struct {
|
||||||
|
Int int64
|
||||||
|
String string
|
||||||
|
ArrayInts []int
|
||||||
|
Structs []C3
|
||||||
|
}
|
||||||
|
|
||||||
|
type C1 struct {
|
||||||
|
Int int64 `toml:",commented"`
|
||||||
|
String string `toml:",commented"`
|
||||||
|
ArrayInts []int `toml:",commented"`
|
||||||
|
Structs []C3 `toml:",commented"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Commented struct {
|
||||||
|
Int int64 `toml:",commented"`
|
||||||
|
String string `toml:",commented"`
|
||||||
|
|
||||||
|
C1 C1
|
||||||
|
C2 C2 `toml:",commented"` // same as C1, but commented at top level
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMarshalCommented(t *testing.T) {
|
||||||
|
c := Commented{
|
||||||
|
Int: 42,
|
||||||
|
String: "root",
|
||||||
|
|
||||||
|
C1: C1{
|
||||||
|
Int: 11,
|
||||||
|
String: "C1",
|
||||||
|
ArrayInts: []int{1, 2, 3},
|
||||||
|
Structs: []C3{
|
||||||
|
{Value: 100},
|
||||||
|
{Values: []int{4, 5, 6}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
C2: C2{
|
||||||
|
Int: 22,
|
||||||
|
String: "C2",
|
||||||
|
ArrayInts: []int{1, 2, 3},
|
||||||
|
Structs: []C3{
|
||||||
|
{Value: 100},
|
||||||
|
{Values: []int{4, 5, 6}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
out, err := toml.Marshal(c)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
expected := `# Int = 42
|
||||||
|
# String = 'root'
|
||||||
|
|
||||||
|
[C1]
|
||||||
|
# Int = 11
|
||||||
|
# String = 'C1'
|
||||||
|
# ArrayInts = [1, 2, 3]
|
||||||
|
|
||||||
|
# [[C1.Structs]]
|
||||||
|
# Value = 100
|
||||||
|
# Values = []
|
||||||
|
|
||||||
|
# [[C1.Structs]]
|
||||||
|
# Value = 0
|
||||||
|
# Values = [4, 5, 6]
|
||||||
|
|
||||||
|
# [C2]
|
||||||
|
# Int = 22
|
||||||
|
# String = 'C2'
|
||||||
|
# ArrayInts = [1, 2, 3]
|
||||||
|
|
||||||
|
# [[C2.Structs]]
|
||||||
|
# Value = 100
|
||||||
|
# Values = []
|
||||||
|
|
||||||
|
# [[C2.Structs]]
|
||||||
|
# Value = 0
|
||||||
|
# Values = [4, 5, 6]
|
||||||
|
`
|
||||||
|
|
||||||
|
require.Equal(t, expected, string(out))
|
||||||
|
}
|
||||||
|
|
||||||
func ExampleMarshal() {
|
func ExampleMarshal() {
|
||||||
type MyConfig struct {
|
type MyConfig struct {
|
||||||
Version int
|
Version int
|
||||||
@@ -1341,3 +1468,161 @@ func ExampleMarshal() {
|
|||||||
// Name = 'go-toml'
|
// Name = 'go-toml'
|
||||||
// Tags = ['go', 'toml']
|
// Tags = ['go', 'toml']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Example that uses the 'commented' field tag option to generate an example
|
||||||
|
// configuration file that has commented out sections (example from
|
||||||
|
// go-graphite/graphite-clickhouse).
|
||||||
|
func ExampleMarshal_commented() {
|
||||||
|
|
||||||
|
type Common struct {
|
||||||
|
Listen string `toml:"listen" comment:"general listener"`
|
||||||
|
PprofListen string `toml:"pprof-listen" comment:"listener to serve /debug/pprof requests. '-pprof' argument overrides it"`
|
||||||
|
MaxMetricsPerTarget int `toml:"max-metrics-per-target" comment:"limit numbers of queried metrics per target in /render requests, 0 or negative = unlimited"`
|
||||||
|
MemoryReturnInterval time.Duration `toml:"memory-return-interval" comment:"daemon will return the freed memory to the OS when it>0"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Costs struct {
|
||||||
|
Cost *int `toml:"cost" comment:"default cost (for wildcarded equalence or matched with regex, or if no value cost set)"`
|
||||||
|
ValuesCost map[string]int `toml:"values-cost" comment:"cost with some value (for equalence without wildcards) (additional tuning, usually not needed)"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ClickHouse struct {
|
||||||
|
URL string `toml:"url" comment:"default url, see https://clickhouse.tech/docs/en/interfaces/http. Can be overwritten with query-params"`
|
||||||
|
|
||||||
|
RenderMaxQueries int `toml:"render-max-queries" comment:"Max queries to render queiries"`
|
||||||
|
RenderConcurrentQueries int `toml:"render-concurrent-queries" comment:"Concurrent queries to render queiries"`
|
||||||
|
TaggedCosts map[string]*Costs `toml:"tagged-costs,commented"`
|
||||||
|
TreeTable string `toml:"tree-table,commented"`
|
||||||
|
ReverseTreeTable string `toml:"reverse-tree-table,commented"`
|
||||||
|
DateTreeTable string `toml:"date-tree-table,commented"`
|
||||||
|
DateTreeTableVersion int `toml:"date-tree-table-version,commented"`
|
||||||
|
TreeTimeout time.Duration `toml:"tree-timeout,commented"`
|
||||||
|
TagTable string `toml:"tag-table,commented"`
|
||||||
|
ExtraPrefix string `toml:"extra-prefix" comment:"add extra prefix (directory in graphite) for all metrics, w/o trailing dot"`
|
||||||
|
ConnectTimeout time.Duration `toml:"connect-timeout" comment:"TCP connection timeout"`
|
||||||
|
DataTableLegacy string `toml:"data-table,commented"`
|
||||||
|
RollupConfLegacy string `toml:"rollup-conf,commented"`
|
||||||
|
MaxDataPoints int `toml:"max-data-points" comment:"max points per metric when internal-aggregation=true"`
|
||||||
|
InternalAggregation bool `toml:"internal-aggregation" comment:"ClickHouse-side aggregation, see doc/aggregation.md"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Tags struct {
|
||||||
|
Rules string `toml:"rules"`
|
||||||
|
Date string `toml:"date"`
|
||||||
|
ExtraWhere string `toml:"extra-where"`
|
||||||
|
InputFile string `toml:"input-file"`
|
||||||
|
OutputFile string `toml:"output-file"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Config struct {
|
||||||
|
Common Common `toml:"common"`
|
||||||
|
ClickHouse ClickHouse `toml:"clickhouse"`
|
||||||
|
Tags Tags `toml:"tags,commented"`
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg := &Config{
|
||||||
|
Common: Common{
|
||||||
|
Listen: ":9090",
|
||||||
|
PprofListen: "",
|
||||||
|
MaxMetricsPerTarget: 15000, // This is arbitrary value to protect CH from overload
|
||||||
|
MemoryReturnInterval: 0,
|
||||||
|
},
|
||||||
|
ClickHouse: ClickHouse{
|
||||||
|
URL: "http://localhost:8123?cancel_http_readonly_queries_on_client_close=1",
|
||||||
|
ExtraPrefix: "",
|
||||||
|
ConnectTimeout: time.Second,
|
||||||
|
DataTableLegacy: "",
|
||||||
|
RollupConfLegacy: "auto",
|
||||||
|
MaxDataPoints: 1048576,
|
||||||
|
InternalAggregation: true,
|
||||||
|
},
|
||||||
|
Tags: Tags{},
|
||||||
|
}
|
||||||
|
|
||||||
|
out, err := toml.Marshal(cfg)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
err = toml.Unmarshal(out, &cfg)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(string(out))
|
||||||
|
|
||||||
|
// Output:
|
||||||
|
// [common]
|
||||||
|
// # general listener
|
||||||
|
// listen = ':9090'
|
||||||
|
// # listener to serve /debug/pprof requests. '-pprof' argument overrides it
|
||||||
|
// pprof-listen = ''
|
||||||
|
// # limit numbers of queried metrics per target in /render requests, 0 or negative = unlimited
|
||||||
|
// max-metrics-per-target = 15000
|
||||||
|
// # daemon will return the freed memory to the OS when it>0
|
||||||
|
// memory-return-interval = 0
|
||||||
|
//
|
||||||
|
// [clickhouse]
|
||||||
|
// # default url, see https://clickhouse.tech/docs/en/interfaces/http. Can be overwritten with query-params
|
||||||
|
// url = 'http://localhost:8123?cancel_http_readonly_queries_on_client_close=1'
|
||||||
|
// # Max queries to render queiries
|
||||||
|
// render-max-queries = 0
|
||||||
|
// # Concurrent queries to render queiries
|
||||||
|
// render-concurrent-queries = 0
|
||||||
|
// # tree-table = ''
|
||||||
|
// # reverse-tree-table = ''
|
||||||
|
// # date-tree-table = ''
|
||||||
|
// # date-tree-table-version = 0
|
||||||
|
// # tree-timeout = 0
|
||||||
|
// # tag-table = ''
|
||||||
|
// # add extra prefix (directory in graphite) for all metrics, w/o trailing dot
|
||||||
|
// extra-prefix = ''
|
||||||
|
// # TCP connection timeout
|
||||||
|
// connect-timeout = 1000000000
|
||||||
|
// # data-table = ''
|
||||||
|
// # rollup-conf = 'auto'
|
||||||
|
// # max points per metric when internal-aggregation=true
|
||||||
|
// max-data-points = 1048576
|
||||||
|
// # ClickHouse-side aggregation, see doc/aggregation.md
|
||||||
|
// internal-aggregation = true
|
||||||
|
//
|
||||||
|
// # [tags]
|
||||||
|
// # rules = ''
|
||||||
|
// # date = ''
|
||||||
|
// # extra-where = ''
|
||||||
|
// # input-file = ''
|
||||||
|
// # output-file = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReadmeComments(t *testing.T) {
|
||||||
|
type TLS struct {
|
||||||
|
Cipher string `toml:"cipher"`
|
||||||
|
Version string `toml:"version"`
|
||||||
|
}
|
||||||
|
type Config struct {
|
||||||
|
Host string `toml:"host" comment:"Host IP to connect to."`
|
||||||
|
Port int `toml:"port" comment:"Port of the remote server."`
|
||||||
|
Tls TLS `toml:"TLS,commented" comment:"Encryption parameters (optional)"`
|
||||||
|
}
|
||||||
|
example := Config{
|
||||||
|
Host: "127.0.0.1",
|
||||||
|
Port: 4242,
|
||||||
|
Tls: TLS{
|
||||||
|
Cipher: "AEAD-AES128-GCM-SHA256",
|
||||||
|
Version: "TLS 1.3",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
out, err := toml.Marshal(example)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
expected := `# Host IP to connect to.
|
||||||
|
host = '127.0.0.1'
|
||||||
|
# Port of the remote server.
|
||||||
|
port = 4242
|
||||||
|
|
||||||
|
# Encryption parameters (optional)
|
||||||
|
# [TLS]
|
||||||
|
# cipher = 'AEAD-AES128-GCM-SHA256'
|
||||||
|
# version = 'TLS 1.3'
|
||||||
|
`
|
||||||
|
require.Equal(t, expected, string(out))
|
||||||
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
//go:build go1.18 || go1.19 || go1.20
|
//go:build go1.18 || go1.19 || go1.20 || go1.21
|
||||||
// +build go1.18 go1.19 go1.20
|
// +build go1.18 go1.19 go1.20 go1.21
|
||||||
|
|
||||||
package ossfuzz
|
package ossfuzz
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
//go:generate go run github.com/toml-lang/toml-test/cmd/toml-test@master -copy ./tests
|
||||||
//go:generate go run ./cmd/tomltestgen/main.go -o toml_testgen_test.go
|
//go:generate go run ./cmd/tomltestgen/main.go -o toml_testgen_test.go
|
||||||
|
|
||||||
// This is a support file for toml_testgen_test.go
|
// This is a support file for toml_testgen_test.go
|
||||||
|
|||||||
+1364
-351
File diff suppressed because it is too large
Load Diff
+11
-7
@@ -149,12 +149,16 @@ type errorContext struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *decoder) typeMismatchError(toml string, target reflect.Type) error {
|
func (d *decoder) typeMismatchError(toml string, target reflect.Type) error {
|
||||||
|
return fmt.Errorf("toml: %s", d.typeMismatchString(toml, target))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *decoder) typeMismatchString(toml string, target reflect.Type) string {
|
||||||
if d.errorContext != nil && d.errorContext.Struct != nil {
|
if d.errorContext != nil && d.errorContext.Struct != nil {
|
||||||
ctx := d.errorContext
|
ctx := d.errorContext
|
||||||
f := ctx.Struct.FieldByIndex(ctx.Field)
|
f := ctx.Struct.FieldByIndex(ctx.Field)
|
||||||
return fmt.Errorf("toml: cannot decode TOML %s into struct field %s.%s of type %s", toml, ctx.Struct, f.Name, f.Type)
|
return fmt.Sprintf("cannot decode TOML %s into struct field %s.%s of type %s", toml, ctx.Struct, f.Name, f.Type)
|
||||||
}
|
}
|
||||||
return fmt.Errorf("toml: cannot decode TOML %s into a Go value of type %s", toml, target)
|
return fmt.Sprintf("cannot decode TOML %s into a Go value of type %s", toml, target)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *decoder) expr() *unstable.Node {
|
func (d *decoder) expr() *unstable.Node {
|
||||||
@@ -963,7 +967,7 @@ func (d *decoder) unmarshalInteger(value *unstable.Node, v reflect.Value) error
|
|||||||
case reflect.Interface:
|
case reflect.Interface:
|
||||||
r = reflect.ValueOf(i)
|
r = reflect.ValueOf(i)
|
||||||
default:
|
default:
|
||||||
return d.typeMismatchError("integer", v.Type())
|
return unstable.NewParserError(d.p.Raw(value.Raw), d.typeMismatchString("integer", v.Type()))
|
||||||
}
|
}
|
||||||
|
|
||||||
if !r.Type().AssignableTo(v.Type()) {
|
if !r.Type().AssignableTo(v.Type()) {
|
||||||
@@ -982,7 +986,7 @@ func (d *decoder) unmarshalString(value *unstable.Node, v reflect.Value) error {
|
|||||||
case reflect.Interface:
|
case reflect.Interface:
|
||||||
v.Set(reflect.ValueOf(string(value.Data)))
|
v.Set(reflect.ValueOf(string(value.Data)))
|
||||||
default:
|
default:
|
||||||
return unstable.NewParserError(d.p.Raw(value.Raw), "cannot store TOML string into a Go %s", v.Kind())
|
return unstable.NewParserError(d.p.Raw(value.Raw), d.typeMismatchString("string", v.Type()))
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -1093,9 +1097,9 @@ func (d *decoder) handleKeyValuePart(key unstable.Iterator, value *unstable.Node
|
|||||||
|
|
||||||
f := fieldByIndex(v, path)
|
f := fieldByIndex(v, path)
|
||||||
|
|
||||||
if !f.CanSet() {
|
if !f.CanAddr() {
|
||||||
// If the field is not settable, need to take a slower path and make a copy of
|
// If the field is not addressable, need to take a slower path and
|
||||||
// the struct itself to a new location.
|
// make a copy of the struct itself to a new location.
|
||||||
nvp := reflect.New(v.Type())
|
nvp := reflect.New(v.Type())
|
||||||
nvp.Elem().Set(v)
|
nvp.Elem().Set(v)
|
||||||
v = nvp.Elem()
|
v = nvp.Elem()
|
||||||
|
|||||||
@@ -240,6 +240,11 @@ func TestUnmarshal_Floats(t *testing.T) {
|
|||||||
input: `0E0`,
|
input: `0E0`,
|
||||||
expected: 0.0,
|
expected: 0.0,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
desc: "float zero without decimals",
|
||||||
|
input: `0`,
|
||||||
|
expected: 0.0,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
desc: "float fractional with exponent",
|
desc: "float fractional with exponent",
|
||||||
input: `6.626e-34`,
|
input: `6.626e-34`,
|
||||||
@@ -2043,6 +2048,68 @@ func TestUnmarshalErrors(t *testing.T) {
|
|||||||
require.Equal(t, "toml: cannot decode TOML integer into struct field toml_test.mystruct.Bar of type string", err.Error())
|
require.Equal(t, "toml: cannot decode TOML integer into struct field toml_test.mystruct.Bar of type string", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestUnmarshalStringInvalidStructField(t *testing.T) {
|
||||||
|
type Server struct {
|
||||||
|
Path string
|
||||||
|
Port int
|
||||||
|
}
|
||||||
|
|
||||||
|
type Cfg struct {
|
||||||
|
Server Server
|
||||||
|
}
|
||||||
|
|
||||||
|
var cfg Cfg
|
||||||
|
|
||||||
|
data := `[server]
|
||||||
|
path = "/my/path"
|
||||||
|
port = "bad"
|
||||||
|
`
|
||||||
|
|
||||||
|
file := strings.NewReader(data)
|
||||||
|
err := toml.NewDecoder(file).Decode(&cfg)
|
||||||
|
require.Error(t, err)
|
||||||
|
|
||||||
|
x := err.(*toml.DecodeError)
|
||||||
|
require.Equal(t, "toml: cannot decode TOML string into struct field toml_test.Server.Port of type int", x.Error())
|
||||||
|
expected := `1| [server]
|
||||||
|
2| path = "/my/path"
|
||||||
|
3| port = "bad"
|
||||||
|
| ~~~~~ cannot decode TOML string into struct field toml_test.Server.Port of type int`
|
||||||
|
|
||||||
|
require.Equal(t, expected, x.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUnmarshalIntegerInvalidStructField(t *testing.T) {
|
||||||
|
type Server struct {
|
||||||
|
Path string
|
||||||
|
Port int
|
||||||
|
}
|
||||||
|
|
||||||
|
type Cfg struct {
|
||||||
|
Server Server
|
||||||
|
}
|
||||||
|
|
||||||
|
var cfg Cfg
|
||||||
|
|
||||||
|
data := `[server]
|
||||||
|
path = 100
|
||||||
|
port = 50
|
||||||
|
`
|
||||||
|
|
||||||
|
file := strings.NewReader(data)
|
||||||
|
err := toml.NewDecoder(file).Decode(&cfg)
|
||||||
|
require.Error(t, err)
|
||||||
|
|
||||||
|
x := err.(*toml.DecodeError)
|
||||||
|
require.Equal(t, "toml: cannot decode TOML integer into struct field toml_test.Server.Path of type string", x.Error())
|
||||||
|
expected := `1| [server]
|
||||||
|
2| path = 100
|
||||||
|
| ~~~ cannot decode TOML integer into struct field toml_test.Server.Path of type string
|
||||||
|
3| port = 50`
|
||||||
|
|
||||||
|
require.Equal(t, expected, x.String())
|
||||||
|
}
|
||||||
|
|
||||||
func TestUnmarshalInvalidTarget(t *testing.T) {
|
func TestUnmarshalInvalidTarget(t *testing.T) {
|
||||||
x := "foo"
|
x := "foo"
|
||||||
err := toml.Unmarshal([]byte{}, x)
|
err := toml.Unmarshal([]byte{}, x)
|
||||||
@@ -2734,6 +2801,28 @@ res = [
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIssue915(t *testing.T) {
|
||||||
|
type blah struct {
|
||||||
|
A string `toml:"a"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type config struct {
|
||||||
|
Fizz string `toml:"fizz"`
|
||||||
|
blah `toml:"blah"`
|
||||||
|
}
|
||||||
|
|
||||||
|
b := []byte(`
|
||||||
|
fizz = "abc"
|
||||||
|
blah.a = "def"`)
|
||||||
|
var cfg config
|
||||||
|
err := toml.Unmarshal(b, &cfg)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
require.Equal(t, "abc", cfg.Fizz)
|
||||||
|
require.Equal(t, "def", cfg.blah.A)
|
||||||
|
require.Equal(t, "def", cfg.A)
|
||||||
|
}
|
||||||
|
|
||||||
func TestUnmarshalDecodeErrors(t *testing.T) {
|
func TestUnmarshalDecodeErrors(t *testing.T) {
|
||||||
examples := []struct {
|
examples := []struct {
|
||||||
desc string
|
desc string
|
||||||
|
|||||||
@@ -1013,6 +1013,7 @@ func (p *Parser) parseIntOrFloatOrDateTime(b []byte) (reference, []byte, error)
|
|||||||
return p.builder.Push(Node{
|
return p.builder.Push(Node{
|
||||||
Kind: Float,
|
Kind: Float,
|
||||||
Data: b[:3],
|
Data: b[:3],
|
||||||
|
Raw: p.Range(b[:3]),
|
||||||
}), b[3:], nil
|
}), b[3:], nil
|
||||||
case 'n':
|
case 'n':
|
||||||
if !scanFollowsNan(b) {
|
if !scanFollowsNan(b) {
|
||||||
@@ -1022,6 +1023,7 @@ func (p *Parser) parseIntOrFloatOrDateTime(b []byte) (reference, []byte, error)
|
|||||||
return p.builder.Push(Node{
|
return p.builder.Push(Node{
|
||||||
Kind: Float,
|
Kind: Float,
|
||||||
Data: b[:3],
|
Data: b[:3],
|
||||||
|
Raw: p.Range(b[:3]),
|
||||||
}), b[3:], nil
|
}), b[3:], nil
|
||||||
case '+', '-':
|
case '+', '-':
|
||||||
return p.scanIntOrFloat(b)
|
return p.scanIntOrFloat(b)
|
||||||
@@ -1146,6 +1148,7 @@ func (p *Parser) scanIntOrFloat(b []byte) (reference, []byte, error) {
|
|||||||
return p.builder.Push(Node{
|
return p.builder.Push(Node{
|
||||||
Kind: Integer,
|
Kind: Integer,
|
||||||
Data: b[:i],
|
Data: b[:i],
|
||||||
|
Raw: p.Range(b[:i]),
|
||||||
}), b[i:], nil
|
}), b[i:], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1169,6 +1172,7 @@ func (p *Parser) scanIntOrFloat(b []byte) (reference, []byte, error) {
|
|||||||
return p.builder.Push(Node{
|
return p.builder.Push(Node{
|
||||||
Kind: Float,
|
Kind: Float,
|
||||||
Data: b[:i+3],
|
Data: b[:i+3],
|
||||||
|
Raw: p.Range(b[:i+3]),
|
||||||
}), b[i+3:], nil
|
}), b[i+3:], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1180,6 +1184,7 @@ func (p *Parser) scanIntOrFloat(b []byte) (reference, []byte, error) {
|
|||||||
return p.builder.Push(Node{
|
return p.builder.Push(Node{
|
||||||
Kind: Float,
|
Kind: Float,
|
||||||
Data: b[:i+3],
|
Data: b[:i+3],
|
||||||
|
Raw: p.Range(b[:i+3]),
|
||||||
}), b[i+3:], nil
|
}), b[i+3:], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1202,6 +1207,7 @@ func (p *Parser) scanIntOrFloat(b []byte) (reference, []byte, error) {
|
|||||||
return p.builder.Push(Node{
|
return p.builder.Push(Node{
|
||||||
Kind: kind,
|
Kind: kind,
|
||||||
Data: b[:i],
|
Data: b[:i],
|
||||||
|
Raw: p.Range(b[:i]),
|
||||||
}), b[i:], nil
|
}), b[i:], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -569,9 +569,9 @@ key5 = [ # Next to start of inline array.
|
|||||||
// ---
|
// ---
|
||||||
// 1:1->1:1 (0->0) | KeyValue []
|
// 1:1->1:1 (0->0) | KeyValue []
|
||||||
// 1:1->1:1 (0->0) | Array []
|
// 1:1->1:1 (0->0) | Array []
|
||||||
// 1:1->1:1 (0->0) | Integer [1]
|
// 19:11->19:12 (396->397) | Integer [1]
|
||||||
// 1:1->1:1 (0->0) | Integer [2]
|
// 19:14->19:15 (399->400) | Integer [2]
|
||||||
// 1:1->1:1 (0->0) | Integer [3]
|
// 19:17->19:18 (402->403) | Integer [3]
|
||||||
// 19:1->19:6 (386->391) | Key [array]
|
// 19:1->19:6 (386->391) | Key [array]
|
||||||
// 19:21->19:46 (406->431) | Comment [# Next to one-line array.]
|
// 19:21->19:46 (406->431) | Comment [# Next to one-line array.]
|
||||||
// ---
|
// ---
|
||||||
@@ -583,12 +583,12 @@ key5 = [ # Next to start of inline array.
|
|||||||
// 1:1->1:1 (0->0) | Array []
|
// 1:1->1:1 (0->0) | Array []
|
||||||
// 23:10->23:42 (483->515) | Comment [# Next to start of inline array.]
|
// 23:10->23:42 (483->515) | Comment [# Next to start of inline array.]
|
||||||
// 24:3->24:38 (518->553) | Comment [# Second line before array content.]
|
// 24:3->24:38 (518->553) | Comment [# Second line before array content.]
|
||||||
// 1:1->1:1 (0->0) | Integer [1]
|
// 25:3->25:4 (556->557) | Integer [1]
|
||||||
// 25:6->25:30 (559->583) | Comment [# Next to first element.]
|
// 25:6->25:30 (559->583) | Comment [# Next to first element.]
|
||||||
// 26:3->26:25 (586->608) | Comment [# After first element.]
|
// 26:3->26:25 (586->608) | Comment [# After first element.]
|
||||||
// 27:3->27:27 (611->635) | Comment [# Before second element.]
|
// 27:3->27:27 (611->635) | Comment [# Before second element.]
|
||||||
// 1:1->1:1 (0->0) | Integer [2]
|
// 28:3->28:4 (638->639) | Integer [2]
|
||||||
// 1:1->1:1 (0->0) | Integer [3]
|
// 29:3->29:4 (643->644) | Integer [3]
|
||||||
// 29:6->29:28 (646->668) | Comment [# Next to last element]
|
// 29:6->29:28 (646->668) | Comment [# Next to last element]
|
||||||
// 30:3->30:24 (671->692) | Comment [# After last element.]
|
// 30:3->30:24 (671->692) | Comment [# After last element.]
|
||||||
// 23:1->23:5 (474->478) | Key [key5]
|
// 23:1->23:5 (474->478) | Key [key5]
|
||||||
|
|||||||
Reference in New Issue
Block a user