diff options
author | Bjørn Erik Pedersen <[email protected]> | 2021-07-27 19:07:10 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2021-07-28 11:51:13 +0200 |
commit | a3701e09313695d4a0f6fb0eb7844c1a4befc07a (patch) | |
tree | 443c85a8b6cbf841155efad4aa99ead8c2824720 /parser | |
parent | 40b6016cf3f7aac541b042d32e3a162411fd9cd0 (diff) | |
download | hugo-a3701e09313695d4a0f6fb0eb7844c1a4befc07a.tar.gz hugo-a3701e09313695d4a0f6fb0eb7844c1a4befc07a.zip |
Switch to go-toml v2
We have been using `go-toml` for language files only. This commit makes it the only TOML library.
It's spec compliant and very fast.
A benchark building a site with 200 pages with TOML front matter:
```bash
name old time/op new time/op delta
SiteNew/Regular_TOML_front_matter-16 48.5ms ± 1% 47.1ms ± 1% -2.85% (p=0.029 n=4+4)
name old alloc/op new alloc/op delta
SiteNew/Regular_TOML_front_matter-16 16.9MB ± 0% 16.7MB ± 0% -1.56% (p=0.029 n=4+4)
name old allocs/op new allocs/op delta
SiteNew/Regular_TOML_front_matter-16 302k ± 0% 296k ± 0% -2.20% (p=0.029 n=4+4)
```
Note that the front matter unmarshaling is only a small part of building a site, so the above is very good.
Fixes #8801
Diffstat (limited to 'parser')
-rw-r--r-- | parser/frontmatter.go | 2 | ||||
-rw-r--r-- | parser/frontmatter_test.go | 4 | ||||
-rw-r--r-- | parser/metadecoders/decoder.go | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/parser/frontmatter.go b/parser/frontmatter.go index 4965d3fe8..e7492745e 100644 --- a/parser/frontmatter.go +++ b/parser/frontmatter.go @@ -20,7 +20,7 @@ import ( "github.com/gohugoio/hugo/parser/metadecoders" - "github.com/BurntSushi/toml" + toml "github.com/pelletier/go-toml/v2" yaml "gopkg.in/yaml.v2" ) diff --git a/parser/frontmatter_test.go b/parser/frontmatter_test.go index 9d9b7c3b8..dfbc695d8 100644 --- a/parser/frontmatter_test.go +++ b/parser/frontmatter_test.go @@ -31,9 +31,9 @@ func TestInterfaceToConfig(t *testing.T) { // TOML {map[string]interface{}{}, metadecoders.TOML, nil, false}, { - map[string]interface{}{"title": "test 1"}, + map[string]interface{}{"title": "test' 1"}, metadecoders.TOML, - []byte("title = \"test 1\"\n"), + []byte("title = \"test' 1\"\n"), false, }, diff --git a/parser/metadecoders/decoder.go b/parser/metadecoders/decoder.go index 131d6f39b..168c130ed 100644 --- a/parser/metadecoders/decoder.go +++ b/parser/metadecoders/decoder.go @@ -24,7 +24,7 @@ import ( "github.com/gohugoio/hugo/common/herrors" "github.com/niklasfasching/go-org/org" - "github.com/BurntSushi/toml" + toml "github.com/pelletier/go-toml/v2" "github.com/pkg/errors" "github.com/spf13/afero" "github.com/spf13/cast" |