mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-17 21:01:26 +02:00
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
This commit is contained in:
@@ -30,20 +30,20 @@ func TestRemarshal(t *testing.T) {
|
||||
ns := New(newDeps(v))
|
||||
c := qt.New(t)
|
||||
|
||||
tomlExample := `title = "Test Metadata"
|
||||
tomlExample := `title = 'Test Metadata'
|
||||
|
||||
[[resources]]
|
||||
src = "**image-4.png"
|
||||
title = "The Fourth Image!"
|
||||
src = '**image-4.png'
|
||||
title = 'The Fourth Image!'
|
||||
[resources.params]
|
||||
byline = "picasso"
|
||||
byline = 'picasso'
|
||||
|
||||
[[resources]]
|
||||
name = "my-cool-image-:counter"
|
||||
src = "**.png"
|
||||
title = "TOML: The Image #:counter"
|
||||
name = 'my-cool-image-:counter'
|
||||
src = '**.png'
|
||||
title = 'TOML: The Image #:counter'
|
||||
[resources.params]
|
||||
byline = "bep"
|
||||
byline = 'bep'
|
||||
`
|
||||
|
||||
yamlExample := `resources:
|
||||
@@ -129,11 +129,9 @@ a = "b"
|
||||
|
||||
`
|
||||
|
||||
expected := `
|
||||
Hugo = "Rules"
|
||||
|
||||
expected := `Hugo = 'Rules'
|
||||
[m]
|
||||
a = "b"
|
||||
a = 'b'
|
||||
`
|
||||
|
||||
for _, format := range []string{"json", "yaml", "toml"} {
|
||||
@@ -149,7 +147,7 @@ Hugo = "Rules"
|
||||
|
||||
diff := htesting.DiffStrings(expected, converted)
|
||||
if len(diff) > 0 {
|
||||
t.Fatalf("[%s] Expected \n%v\ngot\n%v\ndiff:\n%v\n", fromTo, expected, converted, diff)
|
||||
t.Fatalf("[%s] Expected \n%v\ngot\n>>%v\ndiff:\n%v\n", fromTo, expected, converted, diff)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -182,5 +180,5 @@ func TestTestRemarshalMapInput(t *testing.T) {
|
||||
|
||||
output, err := ns.Remarshal("toml", input)
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(output, qt.Equals, "hello = \"world\"\n")
|
||||
c.Assert(output, qt.Equals, "hello = 'world'\n")
|
||||
}
|
||||
|
Reference in New Issue
Block a user