spf13 / viper

Go configuration with fangs
MIT License
26.29k stars 2.01k forks source link

viper go.mod has dependency issues from 1.17.0 #1772

Closed andy12593 closed 1 month ago

andy12593 commented 4 months ago

Preflight Checklist

Viper Version

1.17.0

Go Version

1.18

Config Source

Files

Format

TOML

Repl.it link

No response

Code reproducing the issue

No response

Expected Behavior

go run main.go success without error

Actual Behavior

go run main.go error:
The reason is that github.com/spf13/viper@v1.17.0 only requires go 1.18, but the dependency github.com/sagikazarmark/slog-shim v0.1.0 requires go 1.20

# golang.org/x/exp/slog
/home/oppo/go/pkg/mod/golang.org/x/exp@v0.0.0-20230905200255-921286631fa9/slog/level.go:159:13: undefined: atomic.Int64
/home/oppo/go/pkg/mod/golang.org/x/exp@v0.0.0-20230905200255-921286631fa9/slog/attr.go:20:19: undefined: StringValue
/home/oppo/go/pkg/mod/golang.org/x/exp@v0.0.0-20230905200255-921286631fa9/slog/attr.go:68:19: undefined: GroupValue
/home/oppo/go/pkg/mod/golang.org/x/exp@v0.0.0-20230905200255-921286631fa9/slog/handler.go:446:15: undefined: StringValue
/home/oppo/go/pkg/mod/golang.org/x/exp@v0.0.0-20230905200255-921286631fa9/slog/json_handler.go:109:20: v.str undefined (type Value has no field or method str)
/home/oppo/go/pkg/mod/golang.org/x/exp@v0.0.0-20230905200255-921286631fa9/slog/record.go:192:9: undefined: GroupValue
/home/oppo/go/pkg/mod/golang.org/x/exp@v0.0.0-20230905200255-921286631fa9/slog/text_handler.go:99:20: v.str undefined (type Value has no field or method str)
/home/oppo/go/pkg/mod/golang.org/x/exp@v0.0.0-20230905200255-921286631fa9/slog/value.go:87:7: undefined: stringptr
/home/oppo/go/pkg/mod/golang.org/x/exp@v0.0.0-20230905200255-921286631fa9/slog/value.go:91:7: undefined: groupptr
/home/oppo/go/pkg/mod/golang.org/x/exp@v0.0.0-20230905200255-921286631fa9/slog/value.go:173:10: undefined: StringValue
/home/oppo/go/pkg/mod/golang.org/x/exp@v0.0.0-20230905200255-921286631fa9/slog/value.go:173:10: too many errors
note: module requires Go 1.20

Steps To Reproduce

  1. go get github.com/spf13/viper@v1.17.0
  2. go mod tidy
  3. go run main.go

Additional Information

No response

github-actions[bot] commented 4 months ago

👋 Thanks for reporting!

A maintainer will take a look at your issue shortly. 👀

In the meantime: We are working on Viper v2 and we would love to hear your thoughts about what you like or don't like about Viper, so we can improve or fix those issues.

⏰ If you have a couple minutes, please take some time and share your thoughts: https://forms.gle/R6faU74qPRPAzchZ9

📣 If you've already given us your feedback, you can still help by spreading the news, either by sharing the above link or telling people about this on Twitter:

https://twitter.com/sagikazarmark/status/1306904078967074816

Thank you! ❤️

gotostack commented 4 months ago

This commit introduced the slog: https://github.com/spf13/viper/commit/d16deb4b938f39ad5bd0995ef9b909f4d0c0f4ff

Then the viper from v1.17.0 will require golang 1.20.

Roll back the viper to v1.16.0 works for golang 1.18 for my project.

sagikazarmark commented 4 months ago

As per the Go version support policy we support the last two Go versions. We may have forgotten to update the go.mod file.

andy12593 commented 4 months ago

As per the Go version support policy we support the last two Go versions. We may have forgotten to update the go.mod file.

Yes, the mod file after tag 1.7.0 should be updated from go 1.18 to 1.20. It is recommended to add tag 1.7.1 1.8.3 for this purpose.

sagikazarmark commented 3 months ago

Not sure how that would change anything. If a transitive dependency requires a higher Go version, that's virtually the same as Viper requiring it as well. I doubt Go would behave differently.

sagikazarmark commented 1 month ago

This should be fixed on the latest version.