Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests fail with Go 1.22 #29

Open
QuLogic opened this issue Sep 22, 2024 · 1 comment · May be fixed by #30
Open

Tests fail with Go 1.22 #29

QuLogic opened this issue Sep 22, 2024 · 1 comment · May be fixed by #30

Comments

@QuLogic
Copy link

QuLogic commented Sep 22, 2024

Building with 1.21 passes:

$ podman run --rm -v "$PWD":/usr/src/gotenv:z -w /usr/src/gotenv golang:1.21 go test ./...
go: downloading golang.org/x/text v0.12.0
go: downloading github.com/stretchr/testify v1.7.5
go: downloading github.com/pmezard/go-difflib v1.0.0
go: downloading github.com/davecgh/go-spew v1.1.1
go: downloading gopkg.in/yaml.v3 v3.0.1
ok  	github.com/subosito/gotenv	0.006s

while building with 1.22 fails:

$ podman run --rm -v "$PWD":/usr/src/gotenv:z -w /usr/src/gotenv golang:1.22.0 go test ./...
go: downloading golang.org/x/text v0.12.0
go: downloading github.com/stretchr/testify v1.7.5
go: downloading github.com/davecgh/go-spew v1.1.1
go: downloading gopkg.in/yaml.v3 v3.0.1
go: downloading github.com/pmezard/go-difflib v1.0.0
--- FAIL: TestScanner (0.00s)
    scanner_test.go:75: 
        	Error Trace:	scanner_test.go:75
        	Error:      	Not equal: 
        	            	expected: 4
        	            	actual  : 3
        	Test:       	TestScanner
        	Messages:   	testCase: regular LF split with trailing LF - expected to have the correct line count
    scanner_test.go:75: 
        	Error Trace:	scanner_test.go:75
        	Error:      	Not equal: 
        	            	expected: 4
        	            	actual  : 3
        	Test:       	TestScanner
        	Messages:   	testCase: regular CR split with trailing CR - expected to have the correct line count
    scanner_test.go:75: 
        	Error Trace:	scanner_test.go:75
        	Error:      	Not equal: 
        	            	expected: 4
        	            	actual  : 3
        	Test:       	TestScanner
        	Messages:   	testCase: regular CRLF split with trailing CRLF - expected to have the correct line count
FAIL
FAIL	github.com/subosito/gotenv	0.006s
FAIL
@LeGEC
Copy link
Contributor

LeGEC commented Oct 26, 2024

indeed, there was a change in the standard library 🤯

link: https://tip.golang.org/doc/go1.22#minor_library_changes

bufio
When a SplitFunc returns ErrFinalToken with a nil token, Scanner will now stop immediately. Previously, it would report a final empty token before stopping, which was usually not desired. Callers that do want to report a final empty token can do so by returning []byte{} rather than nil.

LeGEC added a commit to LeGEC/gotenv that referenced this issue Oct 26, 2024
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 subosito#29
@LeGEC LeGEC linked a pull request Oct 26, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants