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

feat: upgrade to go 1.21 #317

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

feat: upgrade to go 1.21 #317

wants to merge 5 commits into from

Conversation

crandles
Copy link

@crandles crandles commented Sep 15, 2024

Update all packages to 1.21, and update tests to cover 1.21 -> 1.23.

I was going to start with 1.23 -- I can update if preferred. At least with 1.21, you can build the later toolchains, so you can start to update individual packages as needed.

Additional changes:

  • go mod tidy of all packages
  • go work sync

There are many packages in the repository -- I'm not sure what your build tool of choice is, but here are some non-fancy makefile targets I've been using:

update-deps:
	GO_ARGS="mod tidy" $(MAKE) go
	GO_ARGS="work sync" $(MAKE) go
	GO_ARGS="test -v" $(MAKE) go
	GO_ARGS="build -v" $(MAKE) go

GO_ARGS ?= -h
go:
	find . -type d -not -path '*/.*' -exec sh -c 'cd {} && go $(GO_ARGS)' \;

@rhnvrm
Copy link
Collaborator

rhnvrm commented Sep 17, 2024

I was just trying to verify if this would break older go versions, and wrote this bash script and it seems to work. But I'm not a 100% sure. Wanted to understand if this is going to be a breaking change for those using v1.18-v1.20.

docker run --rm golang:1.18 bash -c "
    go version &&
    mkdir test &&
    cd test &&
    go mod init foo &&
    echo 'require github.com/knadh/koanf/v2 latest' >> go.mod &&
    echo 'replace github.com/knadh/koanf/v2 => github.com/crandles/koanf/v2 go-v1.21' >> go.mod &&
    cat <<EOL > main.go
package main

import (
    \"github.com/knadh/koanf/v2\"
    \"fmt\"
)

func main() {
    // Create a new koanf instance.
    k := koanf.New(\".\")
    k.Print()
    fmt.Println(\"done\")
}
EOL
    cat go.mod && go mod tidy && cat go.mod &&
    go run main.go
"

@crandles
Copy link
Author

Perhaps worth adding back into the CI, then? I think things will break if you start depending on capabilities that don't exist yet in the older versions.

Starting in 1.21, there's more flexibility.

@rhnvrm
Copy link
Collaborator

rhnvrm commented Sep 17, 2024

Yeah, it might be better to keep v1.18 -> v1.21 in the matrix. Having a similar discussion in #313.

Let me think of other ways to test if anything is breaking in the meanwhile.

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 this pull request may close these issues.

2 participants