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
  • Loading branch information
arp242 committed Jun 6, 2023
1 parent 743df59 commit 96fcef2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions decode_test.go
Expand Up @@ -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()
}

Expand Down
8 changes: 4 additions & 4 deletions parse.go
Expand Up @@ -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
Expand All @@ -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 {
Expand Down

0 comments on commit 96fcef2

Please sign in to comment.