Skip to content

Commit 96fcef2

Browse files
committed
Check BURNTSUSHI_TOML_110 in the parser
Checking it on import means applications won't be to set it with SetEnv in the application itself. Fixes #394
1 parent 743df59 commit 96fcef2

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

decode_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import (
1818
)
1919

2020
func WithTomlNext(f func()) {
21-
tomlNext = true
22-
defer func() { tomlNext = false }()
21+
os.Setenv("BURNTSUSHI_TOML_110", "")
22+
defer func() { os.Unsetenv("BURNTSUSHI_TOML_110") }()
2323
f()
2424
}
2525

parse.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ import (
1111
"github.com/BurntSushi/toml/internal"
1212
)
1313

14-
var tomlNext = func() bool {
15-
_, ok := os.LookupEnv("BURNTSUSHI_TOML_110")
16-
return ok
17-
}()
14+
var tomlNext bool
1815

1916
type parser struct {
2017
lx *lexer
@@ -35,6 +32,9 @@ type keyInfo struct {
3532
}
3633

3734
func parse(data string) (p *parser, err error) {
35+
_, ok := os.LookupEnv("BURNTSUSHI_TOML_110")
36+
tomlNext = ok
37+
3838
defer func() {
3939
if r := recover(); r != nil {
4040
if pErr, ok := r.(ParseError); ok {

0 commit comments

Comments
 (0)