Skip to content

Modernize codebase for Go 1.26#2144

Open
skrashevich wants to merge 3 commits intoAlexxIT:masterfrom
skrashevich:go-1.26
Open

Modernize codebase for Go 1.26#2144
skrashevich wants to merge 3 commits intoAlexxIT:masterfrom
skrashevich:go-1.26

Conversation

@skrashevich
Copy link
Collaborator

@skrashevich skrashevich commented Mar 10, 2026

Summary

  • Fix all go vet errors for Go 1.26 (method signatures, unkeyed structs, unreachable code, non-constant format strings, broken tests)
  • Apply go fix -any changes (interface{}any)
  • Modernize 33 C-style for loops to for range syntax (Go 1.22+)
  • Skip nil sources in stream config to avoid noisy error logs

Changes

  • ReadByte()/WriteByte() renamed to ReadUint8()/WriteUint8() in bits.Reader, bits.Writer, mqtt.Message — Go 1.26 vet enforces io.ByteReader/io.ByteWriter signature match
  • interface{}any across 7 files (automated via go fix)
  • for i := 0; i < N; i++for i := range N in 22 files
  • Broken tests fixed: SetupEndpointsSetupEndpointsRequest, Client()NewConn(), removed test for deleted StripUserinfo
  • Nil stream sources silently skipped instead of logging errors

Binary size

  Branch                        Size   Size (MB)
  ---------------------------------------------------
  master                    18791890    17.92 MB
  go-1.26                   18791890    17.92 MB

  Difference:           no change

- replace traditional for loop with range-based for loop for clarity

refactor(ffmpeg): simplify cut function loop
- utilize range-based for loop instead of traditional for loop

refactor(ring): update API response mapping type
- change map type from `interface{}` to `any` for better type safety

refactor(stream): handle nil source in NewStream
- add nil check for source elements before processing

refactor(webrtc): unify payload handling in GetToken
- change map type from `interface{}` to `any` for consistency

refactor(ascii): optimize nested loops in Write function
- replace traditional for loops with range-based for loops for readability

refactor(bits): enhance readability in Reader methods
- replace traditional for loops with range-based for loops in Read functions

refactor(h264): modernize loop structures in DecodeConfig
- switch to range-based for loops for cleaner code

refactor(h265): streamline profile_tier_level loops
- utilize range-based for loops instead of traditional for loops

chore(core): remove commented-out test function for clarity

refactor(core): simplify RandString function loop
- change traditional for loop to range-based for loop

refactor(flvt): optimize timestamp handling in TestTimeToRTP
- switch to range-based for loop for iterating frames

refactor(nest): improve error handling in ExchangeSDP
- format error message with printf-style formatting for clarity

refactor(tapo): enhance securityEncode function
- change traditional for loop to range-based for loop for readability

fix(tcp): correct masking in websocket Write method
- replace traditional for loop with range-based for loop

refactor(tutk): modernize encoding loops in crypto functions
- utilize range-based for loops for better readability

refactor(tuya): unify data types in MQTT message struct
- change map type from `interface{}` to `any` for consistency

refactor(webrtc): standardize codec registration
- change map type from `interface{}` to `any` for type safety

refactor(yaml): simplify Unmarshal function signature
- update parameter type from `interface{}` to `any` for better clarity
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