Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also 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: v1.3.2
Choose a base ref
...
head repository: BurntSushi/toml
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.4.0
Choose a head ref

Commits on Jun 8, 2023

  1. Run Go 1.16 in CI

    The only reason I retained backwards-compatibility is because Debian 11
    is still on Go 1.15, but Debian 12 should be released this week with Go
    1.19 so we can fairly safely drop it.
    arp242 committed Jun 8, 2023
    Copy the full SHA
    cfb3ca9 View commit details

Commits on Sep 23, 2023

  1. Update toml-test

    Because toml-test now requires Go 1.18, also update the version here to
    Go 1.18. Latest Debian has Go 1.19, and Go 1.18 is EOL now. People can
    still continue to use older versions for older Go versions.
    arp242 committed Sep 23, 2023
    Copy the full SHA
    99c5690 View commit details
  2. interface{} → any

    arp242 committed Sep 23, 2023
    Copy the full SHA
    c63ff8a View commit details
  3. Small staticcheck fixes

    arp242 committed Sep 23, 2023
    Copy the full SHA
    01fb725 View commit details
  4. Actually use errParseDate

    arp242 committed Sep 23, 2023
    Copy the full SHA
    61d6a9c View commit details

Commits on Sep 30, 2023

  1. Small performance boost by allocating arrays if we can

    In the case of valueArray() we don't actually know the array length, but
    allocating an empty array and an array with a cap of 2 is identical in
    terms of performance, and it saves a few allocation for the common case
    of len>=2.
    arp242 committed Sep 30, 2023
    Copy the full SHA
    41f8cc8 View commit details
  2. Copy signbit for -nan

    Is this useful? Doubtful. But doesn't hurt either, and it is useful for
    toml-test.
    
    Also write the signbit back, and don't write explicit +inf – just inf is
    enough.
    arp242 committed Sep 30, 2023
    Copy the full SHA
    d17285a View commit details

Commits on Oct 1, 2023

  1. Add -time flag to tomlv

    arp242 committed Oct 1, 2023
    Copy the full SHA
    fb576ca View commit details
  2. Update toml-test

    arp242 committed Oct 1, 2023
    Copy the full SHA
    9775128 View commit details
  3. Require 2-digit hour

    Fixes #320
    arp242 committed Oct 1, 2023
    Copy the full SHA
    59c762d View commit details
  4. Clarify error on out of safe range floats

    Fixes #396
    arp242 committed Oct 1, 2023
    Copy the full SHA
    663cca6 View commit details
  5. Wrap UnmarshalTOML()/UnmarshalText return values in ParseError

    This adds position information.
    
    Fixes #398
    arp242 committed Oct 1, 2023
    Copy the full SHA
    b6fe702 View commit details
  6. Correct error position with tab indentation

    Previously the ^^^s would be misplaced, e.g.:
    
          2 |               k1 = "asd"
          3 |               k2 = "ok"
          4 |               k3 = "invalid"
                      ^^^^^^^
    arp242 committed Oct 1, 2023
    Copy the full SHA
    1905bd7 View commit details
  7. Remove unused code

    This is never called, as the value here is never a pointer.
    arp242 committed Oct 1, 2023
    Copy the full SHA
    b41de93 View commit details
  8. Mark Primitive, MetaData.PrimitiveDecode() as deprecated

    It's not really needed: if you're not sure of the structure you can use
    any with type switches, and if you want some custom (un)marshal logic you
    can use the (Un)Marshal interface.
    
    Did some basic performance tests: Primitive isn't really faster. It's
    also not really more convenient. And it does complicate things quite a
    bit.
    arp242 committed Oct 1, 2023
    Copy the full SHA
    4f8abaa View commit details

Commits on Oct 10, 2023

  1. Write "inf" instead of "Inf" in JSON tests

    Doesn't really matter for the toml-test test runner, but we use
    toml-test-decoder for generating tests, and "Inf" with capital was
    causing issues for some: toml-lang/toml-test#143
    arp242 committed Oct 10, 2023
    Copy the full SHA
    c0a26cb View commit details
  2. Few performance improvements

    replaceEscapes() got called for every string, and key.String() gets
    called a lot in the parser, so small improvements add up. Also figured
    that calling replaceEscapes() for every string isn't really needed.
    
    It's about 20 to 30% faster (depending on the TOML file).
    arp242 committed Oct 10, 2023
    Copy the full SHA
    6fb5266 View commit details

Commits on Dec 3, 2023

  1. Fix utf8.RuneError test

    arp242/uni@5f9eb0d
    
    This is actually not really an issue here, because U+FFFD isn't valid in
    TOML, but it doesn't hurt to properly check.
    arp242 committed Dec 3, 2023
    Copy the full SHA
    c320c2d View commit details

Commits on Dec 7, 2023

  1. Update toml-test

    arp242 committed Dec 7, 2023
    Copy the full SHA
    45e7e49 View commit details
  2. Fix inline tables with dotted keys inside inline arrays (#400)

    For example this:
    
    	arr = [
    		{a.b.c = 1},
    	]
    
    Would lose the a.b context, and it would just be map["c" = 1].
    arp242 authored Dec 7, 2023
    Copy the full SHA
    4223137 View commit details

Commits on Jan 2, 2024

  1. Update toml-test

    This adds a failing test case for #403.
    arp242 committed Jan 2, 2024
    Copy the full SHA
    c299e75 View commit details

Commits on Jan 3, 2024

  1. Fix panic when trying to set subkey for a value that's not a table

    Would panic for inline tables; regression added in 4223137.
    
    Fixes #403
    arp242 committed Jan 3, 2024
    Copy the full SHA
    0e879cb View commit details

Commits on May 2, 2024

  1. Add Marshal Function (#405)

    Added the Marshal function which returns the TOML representation of the Go value as bytes along with any error that may occur while marshaling.
    samawise authored May 2, 2024
    Copy the full SHA
    77ce858 View commit details

Commits on May 6, 2024

  1. fuzz: move fuzz_targets from oss-fuzz (#406)

    - Moves fuzz_targets from oss-fuzz. This makes it easy
      to maintain the fuzzers and minimizes breakages that
      can arise as source code changes over time.
    
    - Adds cifuzz action workflow which is a service provided
      by oss-fuzz where this project already runs, this helps
      in catching shallow bugs,regression or build breakage by
      running fuzzers on PR for ~5 minutes.
    manunio authored May 6, 2024
    Copy the full SHA
    3203540 View commit details

Commits on May 10, 2024

  1. Add -json flag to tomlv

    arp242 committed May 10, 2024
    Copy the full SHA
    9a80667 View commit details

Commits on May 23, 2024

  1. Update toml-test

    arp242 committed May 23, 2024
    Copy the full SHA
    f8f7e48 View commit details
  2. Copy the full SHA
    1e2c053 View commit details
Showing 325 changed files with 2,964 additions and 2,917 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/cifuzz.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: CIFuzz
on: [pull_request]
jobs:
Fuzzing:
runs-on: ubuntu-latest
steps:
- name: Build Fuzzers
id: build
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with:
oss-fuzz-project-name: 'burntsushi-toml'
dry-run: false
language: go
- name: Run Fuzzers
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
with:
oss-fuzz-project-name: 'burntsushi-toml'
fuzz-seconds: 300
dry-run: false
language: go
- name: Upload Crash
uses: actions/upload-artifact@v4
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts
path: ./out/artifacts
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
"test": {
"strategy": {
"matrix": {
"go-version": ["1.13.x", "1.20.x"],
"go-version": ["1.18.x", "1.22.x"],
"os": ["ubuntu-latest", "macos-latest", "windows-latest"]
}
},
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ See the [releases page](https://github.com/BurntSushi/toml/releases) for a
changelog; this information is also in the git tag annotations (e.g. `git show
v0.4.0`).

This library requires Go 1.13 or newer; add it to your go.mod with:
This library requires Go 1.18 or newer; add it to your go.mod with:

% go get github.com/BurntSushi/toml@latest

2 changes: 1 addition & 1 deletion _example/example.toml
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ times = [
# Durations.
duration = ["4m49s", "8m03s", "1231h15m55s"]

# Table with inline tables.
# Array with inline tables.
distros = [
{name = "Arch Linux", packages = "pacman"},
{name = "Void Linux", packages = "xbps"},
18 changes: 7 additions & 11 deletions bench_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
//go:build go1.16
// +build go1.16

package toml_test

import (
"bytes"
"io/fs"
"io/ioutil"
"os"
"path/filepath"
"sort"
@@ -48,30 +44,30 @@ func BenchmarkDecode(b *testing.B) {
b.ResetTimer()
for n := 0; n < b.N; n++ {
for _, f := range tt.toml {
var val map[string]interface{}
var val map[string]any
toml.Decode(f, &val)
}
}
})
}

b.Run("large-doc", func(b *testing.B) {
d, err := os.ReadFile("testdata/ja-JP.toml")
d, err := os.ReadFile("testdata/Cargo.toml")
if err != nil {
b.Fatal(err)
}
doc := string(d)

b.ResetTimer()
for n := 0; n < b.N; n++ {
var val map[string]interface{}
var val map[string]any
toml.Decode(doc, &val)
}
})
}

func BenchmarkEncode(b *testing.B) {
files := make(map[string][]map[string]interface{})
files := make(map[string][]map[string]any)
fs.WalkDir(tomltest.EmbeddedTests(), ".", func(path string, d fs.DirEntry, err error) error {
if strings.HasPrefix(path, "valid/") && strings.HasSuffix(path, ".toml") {
d, _ := fs.ReadFile(tomltest.EmbeddedTests(), path)
@@ -88,7 +84,7 @@ func BenchmarkEncode(b *testing.B) {
return nil
}

var dec map[string]interface{}
var dec map[string]any
_, err := toml.Decode(string(d), &dec)
if err != nil {
b.Fatalf("decode %q: %s", path, err)
@@ -108,7 +104,7 @@ func BenchmarkEncode(b *testing.B) {

type test struct {
group string
data []map[string]interface{}
data []map[string]any
}
tests := make([]test, 0, len(files))
for k, v := range files {
@@ -132,7 +128,7 @@ func BenchmarkEncode(b *testing.B) {
}

func BenchmarkExample(b *testing.B) {
d, err := ioutil.ReadFile("_example/example.toml")
d, err := os.ReadFile("_example/example.toml")
if err != nil {
b.Fatal(err)
}
2 changes: 1 addition & 1 deletion cmd/toml-test-decoder/main.go
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ func main() {
flag.Usage()
}

var decoded interface{}
var decoded any
if _, err := toml.NewDecoder(os.Stdin).Decode(&decoded); err != nil {
log.Fatalf("Error decoding TOML: %s", err)
}
2 changes: 1 addition & 1 deletion cmd/toml-test-encoder/main.go
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ func main() {
flag.Usage()
}

var tmp interface{}
var tmp any
if err := json.NewDecoder(os.Stdin).Decode(&tmp); err != nil {
log.Fatalf("Error decoding JSON: %s", err)
}
18 changes: 17 additions & 1 deletion cmd/tomlv/main.go
Original file line number Diff line number Diff line change
@@ -2,24 +2,30 @@
package main

import (
"encoding/json"
"flag"
"fmt"
"log"
"os"
"path"
"strings"
"text/tabwriter"
"time"

"github.com/BurntSushi/toml"
)

var (
flagTypes = false
flagJSON = false
flagTime = false
)

func init() {
log.SetFlags(0)
flag.BoolVar(&flagTypes, "types", flagTypes, "Show the types for every key.")
flag.BoolVar(&flagTime, "time", flagTypes, "Show how long the parsing took.")
flag.BoolVar(&flagJSON, "json", flagTypes, "Output parsed document as JSON.")
flag.Usage = usage
flag.Parse()
}
@@ -35,14 +41,24 @@ func main() {
flag.Usage()
}
for _, f := range flag.Args() {
var tmp interface{}
var tmp any
start := time.Now()
md, err := toml.DecodeFile(f, &tmp)
if err != nil {
log.Fatalf("Error in '%s': %s", f, err)
}
if flagTime {
fmt.Printf("%f\n", time.Now().Sub(start).Seconds())
}
if flagTypes {
printTypes(md)
}
if flagJSON {
enc := json.NewEncoder(os.Stdout)
enc.SetEscapeHTML(false)
enc.SetIndent("", " ")
enc.Encode(tmp)
}
}
}

Loading