Skip to content

Support Go 1.24-1.27 and modernize deprecated APIs - #132

Merged
const-cloudinary merged 4 commits into
mainfrom
go-version-support-and-lint-cleanup
Aug 25, 2026
Merged

Support Go 1.24-1.27 and modernize deprecated APIs#132
const-cloudinary merged 4 commits into
mainfrom
go-version-support-and-lint-cleanup

Conversation

@const-cloudinary

@const-cloudinary const-cloudinary commented Aug 25, 2026

Copy link
Copy Markdown
Member

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.0 does not build on Go 1.25+. It depends on golang.org/x/tools@v0.11.0, which fails to compile with invalid array length -delta * delta in internal/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 to v1.13.0 (pulls x/tools@v0.36.0).
  • Unsigned underflow in watchMemoryAllocation. read - initialRead was computed on uint64 without checking that the live heap had grown. runtime.MemStats.Alloc is 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 failed TestUploader_UploadLargeFile with allocated 18446744073709509944 bytes. The bug is pre-existing — Go 1.26's GC timing just makes it reproducible.

Changes

Version support

  • CI matrix: 1.20–1.241.24, 1.25, 1.26, 1.27
  • README support table collapsed to Go 1.13 - 1.19 / Go 1.20 - 1.23 / Go 1.24 - 1.27
  • gotestsum v1.11.0v1.13.0

Deprecated APIs

  • ioutil.ReadAll / ioutil.TempFileio.ReadAll / os.CreateTemp
  • strings.Title → explicit first-rune upper
  • rand.Seed → local rand.New source

Correctness

  • Upload discarded the error from HandleRawResponse and returned nil
  • Typed context key for api_version instead of a bare string (staticcheck SA1029)
  • watchMemoryAllocation: only count heap growth; make proceed/maxAlloc atomic, as they were written by the returned closure and read by the sampling goroutine unsynchronized
  • TestUploader_UploadWithResponsiveBreakpoints dereferenced a nil response after t.Errort.Fatal
  • getAutoVideoDetailsTestCases was defined but never registered in the acceptance suite
  • Dropped duplicated omitempty on UpdateAssetParams.Tags
  • Raw string literal for the base64 detection regex
  • Removed unused test constants and an unused assignment

Test 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-existing dynamic_folders / visual_search account-feature gates.

Go 1.27 was additionally verified locally (build, vet, and a gotestsum v1.13.0 install) before being added to the matrix.

Note

go.mod still declares go 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

const-cloudinary and others added 4 commits August 25, 2026 17:31
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>
@const-cloudinary const-cloudinary changed the title Support Go 1.24-1.26 and modernize deprecated APIs Support Go 1.24-1.27 and modernize deprecated APIs Aug 25, 2026
@const-cloudinary
const-cloudinary merged commit 7207d60 into main Aug 25, 2026
10 checks passed
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.

1 participant