Summary
This issue proposes formally dropping support for Go 1.21.x and stating that go 1.22.x
is the minimum required version — which is already the case based on the go.mod file on the master branch.
Current State of go.mod (on master)
module github.com/go-python/gopy
go 1.22.0
require (
github.com/gonuts/commander v0.1.0
github.com/gonuts/flag v0.1.0
github.com/pkg/errors v0.9.1
golang.org/x/tools v0.29.0
)
require (
golang.org/x/mod v0.22.0 // indirect
golang.org/x/sync v0.10.0 // indirect
)
The go directive in go.mod already declares go 1.22.0 as the minimum. This means Go 1.21.x
users are already technically excluded — Go's toolchain management (introduced in Go 1.21) will
attempt to auto-upgrade or refuse to build depending on the user's GOTOOLCHAIN setting.
What Would Be Required to Support Go 1.21.x
To re-enable Go 1.21.x support, the following changes to go.mod would be necessary:
- Lower the
go directive from go 1.22.0 to go 1.21
- Downgrade
golang.org/x/tools from v0.29.0 to v0.19.0 (the last version compatible with Go 1.21)
- Remove
golang.org/x/sync as a dependency (it gets dropped by go mod tidy under Go 1.21 constraints)
- Downgrade
golang.org/x/mod from v0.22.0 to v0.16.0
The resulting go.mod would look like:
module github.com/go-python/gopy
go 1.21
require (
github.com/gonuts/commander v0.1.0
github.com/gonuts/flag v0.1.0
github.com/pkg/errors v0.9.1
golang.org/x/tools v0.19.0
)
require golang.org/x/mod v0.16.0 // indirect
These are meaningful dependency regressions — particularly golang.org/x/tools, which provides
core functionality for gopy's code analysis and generation pipeline.
Test Results by Go Version
Today (2026 April 16), I tested various go versions locally, using the code found in this PR: #386
All tests were run locally using the same Python .venv (pybindgen installed) across Go versions on
Apple Silicon (darwin/arm64). Results as of this writing:
| Go Version |
Tests Run |
Pass |
Fail |
Skip |
Notes |
| 1.21.x |
36 |
35 |
0 |
1 |
Required temporary go.mod downgrade to run at all |
| 1.22.x |
36 |
35 |
0 |
1 |
Passes fully |
| 1.23.x |
36 |
34 |
0 |
2 |
TestBindCgoPackage skipped (issue #370) |
| 1.25.x |
36 |
35 |
0 |
1 |
Passes fully |
The single consistent skip (TestPythonConfig in the bind package) is unrelated to Go version.
Note: Go 1.24 is also affected by the TestBindCgoPackage CGO issue (#370) and is skipped
for that test. Go 1.25 passes without any CGO-related skips.
Question: What Is the Benefit of Supporting Multiple Go Versions?
The question
Given that go.mod already requires Go 1.22.0, is there any meaningful benefit to maintaining backward compatibility with Go 1.21.x — or with older versions in general?
Arguments for supporting multiple Go versions
-
Wider user base: Some users or organizations pin Go versions for stability reasons (e.g., corporate environments, reproducible builds, embedded toolchains). Supporting older versions lowers the barrier to adoption.
-
Ecosystem consistency: Libraries and tools that support a range of Go versions are easier to integrate into projects that haven't yet migrated to the latest release.
-
CI coverage: Running tests against multiple versions can surface regressions introduced by changes in the Go runtime or standard library — catching bugs before they affect users on newer versions.
Arguments against (reasons to drop Go 1.21.x now)
-
Already effectively dropped: The go 1.22.0 directive in go.mod already prevents Go 1.21 users from building without workarounds (GOTOOLCHAIN=local, manual go.mod edits). The
deprecation is a formality at this point.
-
Dependency cost: Maintaining Go 1.21 compatibility requires pinning golang.org/x/tools at v0.19.0 , a release which is already quite old. New features, bug fixes, and security patches ingolang.org/x/tools (used heavily by gopy for type analysis and code generation) would be unavailable.
-
Go's own support policy: The Go team officially supports only the two most recent major releases. As of this writing, that is Go 1.24 and Go 1.25. Go 1.21 is out of official support. See: https://go.dev/doc/devel/release#policy
-
Toolchain complexity: Go 1.21 introduced GOTOOLCHAIN management, making it possible for go.mod to declare a minimum version. Using this feature correctly is easiest when the declared minimum matches reality — i.e., we declare go 1.22.0 and mean it.
-
Test matrix simplicity: Fewer supported versions means a simpler CI matrix and fewer version-specific skip conditions to maintain in main_test.go.
Recommendation
Formally declare Go 1.22.0 as the minimum supported version. This matches the current go.mod, requires no code changes, and aligns with Go's own support policy. The CI matrix can then focus on Go 1.22, 1.23 (with the known CGO skip), and the two latest releases.
Related
Summary
This issue proposes formally dropping support for Go 1.21.x and stating that
go 1.22.xis the minimum required version — which is already the case based on the
go.modfile on themasterbranch.Current State of
go.mod(onmaster)The
godirective ingo.modalready declaresgo 1.22.0as the minimum. This means Go 1.21.xusers are already technically excluded — Go's toolchain management (introduced in Go 1.21) will
attempt to auto-upgrade or refuse to build depending on the user's
GOTOOLCHAINsetting.What Would Be Required to Support Go 1.21.x
To re-enable Go 1.21.x support, the following changes to
go.modwould be necessary:godirective fromgo 1.22.0togo 1.21golang.org/x/toolsfromv0.29.0tov0.19.0(the last version compatible with Go 1.21)golang.org/x/syncas a dependency (it gets dropped bygo mod tidyunder Go 1.21 constraints)golang.org/x/modfromv0.22.0tov0.16.0The resulting
go.modwould look like:These are meaningful dependency regressions — particularly
golang.org/x/tools, which providescore functionality for gopy's code analysis and generation pipeline.
Test Results by Go Version
Today (2026 April 16), I tested various go versions locally, using the code found in this PR: #386
All tests were run locally using the same Python
.venv(pybindgen installed) across Go versions onApple Silicon (darwin/arm64). Results as of this writing:
go.moddowngrade to run at allTestBindCgoPackageskipped (issue #370)The single consistent skip (
TestPythonConfigin thebindpackage) is unrelated to Go version.Question: What Is the Benefit of Supporting Multiple Go Versions?
The question
Given that
go.modalready requires Go 1.22.0, is there any meaningful benefit to maintaining backward compatibility with Go 1.21.x — or with older versions in general?Arguments for supporting multiple Go versions
Wider user base: Some users or organizations pin Go versions for stability reasons (e.g., corporate environments, reproducible builds, embedded toolchains). Supporting older versions lowers the barrier to adoption.
Ecosystem consistency: Libraries and tools that support a range of Go versions are easier to integrate into projects that haven't yet migrated to the latest release.
CI coverage: Running tests against multiple versions can surface regressions introduced by changes in the Go runtime or standard library — catching bugs before they affect users on newer versions.
Arguments against (reasons to drop Go 1.21.x now)
Already effectively dropped: The
go 1.22.0directive ingo.modalready prevents Go 1.21 users from building without workarounds (GOTOOLCHAIN=local, manualgo.modedits). Thedeprecation is a formality at this point.
Dependency cost: Maintaining Go 1.21 compatibility requires pinning
golang.org/x/toolsatv0.19.0, a release which is already quite old. New features, bug fixes, and security patches ingolang.org/x/tools(used heavily by gopy for type analysis and code generation) would be unavailable.Go's own support policy: The Go team officially supports only the two most recent major releases. As of this writing, that is Go 1.24 and Go 1.25. Go 1.21 is out of official support. See: https://go.dev/doc/devel/release#policy
Toolchain complexity: Go 1.21 introduced
GOTOOLCHAINmanagement, making it possible forgo.modto declare a minimum version. Using this feature correctly is easiest when the declared minimum matches reality — i.e., we declarego 1.22.0and mean it.Test matrix simplicity: Fewer supported versions means a simpler CI matrix and fewer version-specific skip conditions to maintain in
main_test.go.Recommendation
Formally declare Go 1.22.0 as the minimum supported version. This matches the current
go.mod, requires no code changes, and aligns with Go's own support policy. The CI matrix can then focus on Go 1.22, 1.23 (with the known CGO skip), and the two latest releases.Related
TestBindCgoPackagefails on Go 1.23 and 1.24 due to a CGO issuego 1.22.0directive was already present onmasterbefore this issue was filed