Support Go 1.24-1.27 and modernize deprecated APIs - #132
Merged
Conversation
Shift the CI matrix and README support table to Go 1.24-1.26, and clean up code that no longer passes vet/lint on current toolchains: - Replace deprecated `ioutil.ReadAll`/`TempFile` with `io.ReadAll`/`os.CreateTemp` - Replace deprecated `strings.Title` with an explicit first-rune upper - Replace deprecated `rand.Seed` with a local `rand.New` source - Use a typed context key for `api_version` instead of a bare string, fixing the `SA1029` staticcheck violation - Use a raw string literal for the base64 detection regex - Drop the duplicated `omitempty` on `UpdateAssetParams.Tags` - Remove unused test constants and unused assignments Also fix two latent test/code bugs surfaced while cleaning up: - `Upload` discarded the error from `HandleRawResponse` and returned nil - `TestUploader_UploadWithResponsiveBreakpoints` dereferenced a nil response after `t.Error`; use `t.Fatal` - Register `getAutoVideoDetailsTestCases` in the acceptance suite, which was defined but never run Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
v1.11.0 depends on golang.org/x/tools@v0.11.0, which fails to compile on
Go 1.25 and 1.26 ("invalid array length -delta * delta" in
internal/tokeninternal). v1.13.0 pulls x/tools@v0.36.0 and builds cleanly.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`watchMemoryAllocation` computed `read - initialRead` on uint64 without checking that the live heap had actually grown. `runtime.MemStats.Alloc` is the live heap, so once the GC collects it can fall below the baseline taken before the upload; the subtraction then wraps to ~2^64 and trips the allocation limit. Go 1.26's GC timing makes this reproducible, which failed TestUploader_UploadLargeFile with "allocated 18446744073709509944 bytes". Only account for growth, and make `proceed`/`maxAlloc` atomic — they were written by the returned closure and read by the sampling goroutine without synchronization. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Go 1.27.0 is released; build, vet, and gotestsum v1.13.0 all verified clean against it locally. Collapse the README support columns into a "Go 1.24 - 1.27" range rather than adding a sixth column. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Moves the CI matrix and README support table to Go 1.24–1.27, and fixes the things that stood in the way of those versions actually passing.
Two of the fixes were only discoverable in CI, since the test suite needs real credentials against a live test cloud:
gotestsum@v1.11.0does not build on Go 1.25+. It depends ongolang.org/x/tools@v0.11.0, which fails to compile withinvalid array length -delta * deltaininternal/tokeninternal. This aborted the job before a single test ran, so the new matrix rows would have been permanently red regardless of the SDK code. Bumped tov1.13.0(pullsx/tools@v0.36.0).watchMemoryAllocation.read - initialReadwas computed onuint64without checking that the live heap had grown.runtime.MemStats.Allocis the live heap, so a GC cycle during the upload can drop it below the baseline; the subtraction then wraps to ~2^64 and trips the allocation limit. This failedTestUploader_UploadLargeFilewithallocated 18446744073709509944 bytes. The bug is pre-existing — Go 1.26's GC timing just makes it reproducible.Changes
Version support
1.20–1.24→1.24,1.25,1.26,1.27Go 1.13 - 1.19/Go 1.20 - 1.23/Go 1.24 - 1.27gotestsumv1.11.0→v1.13.0Deprecated APIs
ioutil.ReadAll/ioutil.TempFile→io.ReadAll/os.CreateTempstrings.Title→ explicit first-rune upperrand.Seed→ localrand.NewsourceCorrectness
Uploaddiscarded the error fromHandleRawResponseand returnednilapi_versioninstead of a bare string (staticcheckSA1029)watchMemoryAllocation: only count heap growth; makeproceed/maxAllocatomic, as they were written by the returned closure and read by the sampling goroutine unsynchronizedTestUploader_UploadWithResponsiveBreakpointsdereferenced a nil response aftert.Error→t.FatalgetAutoVideoDetailsTestCaseswas defined but never registered in the acceptance suiteomitemptyonUpdateAssetParams.TagsTest plan
CI green on all four versions — 279 tests, 3 skipped, 0 failures on Go 1.24, 1.25, 1.26, and 1.27. The 1.27 job confirms
go version go1.27.0 linux/amd64, so it is not silently falling back to an older toolchain. The 3 skips are the pre-existingdynamic_folders/visual_searchaccount-feature gates.Go 1.27 was additionally verified locally (
build,vet, and agotestsum v1.13.0install) before being added to the matrix.Note
go.modstill declaresgo 1.20, left deliberately unchanged. Dropping the older CI rows doesn't by itself end support for those versions — the directive is what enforces the floor. Raising the minimum is a separate decision with downstream impact.🤖 Generated with Claude Code