Skip to content

Commit

Permalink
Check BURNTSUSHI_TOML_110 in the parser
Browse files Browse the repository at this point in the history
Checking it on import means applications won't be to set it with SetEnv
in the application itself.

Fixes #394
arp242 committed Jun 6, 2023
1 parent 743df59 commit 96fcef2
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions decode_test.go
Original file line number Diff line number Diff line change
@@ -18,8 +18,8 @@ import (
)

func WithTomlNext(f func()) {
tomlNext = true
defer func() { tomlNext = false }()
os.Setenv("BURNTSUSHI_TOML_110", "")
defer func() { os.Unsetenv("BURNTSUSHI_TOML_110") }()
f()
}

8 changes: 4 additions & 4 deletions parse.go
Original file line number Diff line number Diff line change
@@ -11,10 +11,7 @@ import (
"github.com/BurntSushi/toml/internal"
)

var tomlNext = func() bool {
_, ok := os.LookupEnv("BURNTSUSHI_TOML_110")
return ok
}()
var tomlNext bool

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

func parse(data string) (p *parser, err error) {
_, ok := os.LookupEnv("BURNTSUSHI_TOML_110")
tomlNext = ok

defer func() {
if r := recover(); r != nil {
if pErr, ok := r.(ParseError); ok {

0 comments on commit 96fcef2

Please sign in to comment.