Skip to content

Commit

Permalink
fix: adjust splitLines to match go 1.22 behavior (#30)
Browse files Browse the repository at this point in the history
see https://tip.golang.org/doc/go1.22#minor_library_changes

there was a change in bufio.Scanner, which does not "report" anymore
a 'nil' final line

unit test would work pre 1.22, and fail on 1.22 and onwards

fixes #29
  • Loading branch information
LeGEC authored Dec 1, 2024
1 parent 0430c38 commit 490d1d0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion gotenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func Write(env Env, filename string) error {
// If a CR is immediately followed by a LF, it is treated as a CRLF (one single line break).
func splitLines(data []byte, atEOF bool) (advance int, token []byte, err error) {
if atEOF && len(data) == 0 {
return 0, nil, bufio.ErrFinalToken
return 0, []byte{}, bufio.ErrFinalToken
}

idx := bytes.IndexAny(data, "\r\n")
Expand Down

0 comments on commit 490d1d0

Please sign in to comment.