Skip to content

Apply go fix modernization across codebase#169

Merged
linyows merged 2 commits intomainfrom
modernize
Mar 4, 2026
Merged

Apply go fix modernization across codebase#169
linyows merged 2 commits intomainfrom
modernize

Conversation

@linyows
Copy link
Owner

@linyows linyows commented Mar 4, 2026

Summary

  • Apply go fix modernization across the entire codebase
  • Replace interface{} with any, reflect.Ptr with reflect.Pointer, reflect.TypeOf with reflect.TypeFor
  • Adopt standard library APIs: maps.Copy, slices.Contains, strings.SplitSeq, strings.CutPrefix, fmt.Appendf
  • Use integer range syntax (for i := range n)
  • 38 files changed, 174 insertions, 223 deletions (net reduction in code)

Test plan

  • go build ./... passes
  • go vet ./... passes
  • go test ./... all tests pass

🤖 Generated with Claude Code

Modernize Go code using go fix: interface{} to any, reflect.Ptr to
reflect.Pointer, reflect.TypeOf to reflect.TypeFor, integer range syntax,
maps.Copy, slices.Contains, strings.SplitSeq, strings.CutPrefix, and
fmt.Appendf.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@linyows linyows requested a review from Copilot March 4, 2026 07:24
@linyows linyows self-assigned this Mar 4, 2026
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes the Go codebase using go fix-style updates and newer standard library APIs (e.g., maps, slices, strings sequence helpers), while also aligning types toward any and newer reflection helpers.

Changes:

  • Replace interface{} with any across production and test code.
  • Adopt newer stdlib helpers (maps.Copy, slices.Contains/ContainsFunc, strings.CutPrefix, strings.SplitSeq, fmt.Appendf) and integer-range loops (for i := range n).
  • Update reflection-related code to use newer reflect constants/helpers (e.g., reflect.Pointer, reflect.TypeFor).

Reviewed changes

Copilot reviewed 38 out of 38 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
workflow_test.go Uses integer-range loops in concurrency/parallelism tests.
step_test.go Switches to strings.SplitSeq iteration for line checking.
ssh/client_test.go Uses maps.Copy for test input map cloning.
ssh/client.go Uses strings.CutPrefix and maps.Copy for request preparation/copying.
shell/client.go Uses slices.Contains and strings.CutPrefix for validation and env extraction.
repeat_test.go Updates tests to any (including pointer cases).
repeat.go Updates YAML marshal/unmarshal signatures/return types to any.
probe.go Uses strings.SplitSeq for multi-path parsing.
printer_test.go Updates varargs/types to any and SplitSeq-based iteration.
printer.go Updates public printer APIs to ...any and uses SplitSeq for echo formatting.
outputs.go Uses maps.Copy for copying output maps.
mapping.go Uses maps.Copy, reflect.TypeFor, and reflect.Pointer in mapping utilities.
mail/mock_server.go Uses strings.SplitSeq for CRLF command splitting.
mail/bulk.go Replaces string concatenation loop with strings.Builder.
imap/client.go Uses maps.Copy, strings.SplitSeq, and strings.CutPrefix in parsing/fetch logic.
http/client_test.go Updates test header maps to map[string]any.
http/client.go Uses maps.Copy and updates header map type assertions to map[string]any.
grpc/client.go Uses maps.Copy for request map cloning.
funcs.go Updates helper signature to any.
expr_test.go Uses integer-range loops in edge-case tests.
expr.go Uses slices.Contains, fmt.Appendf for byte formatting in templating.
error.go Updates error context type and context setter to any.
embedded/client.go Uses maps.Copy to avoid mutating caller request maps.
db/client_test.go Updates params/rows types in tests to any.
db/client.go Updates DB request/response types and callback signatures to any.
dag_ascii.go Uses slices.Contains for membership checks in DAG rendering.
dag/cycles.go Uses slices.ContainsFunc for DFS-driven cycle detection.
cmd/probe/main.go Uses slices.Contains and index-range loop modernization in CLI parsing.
browser/client_test.go Updates debug callback varargs to ...any.
browser/client.go Updates debug callback varargs to ...any.
ascii-dag/layout.go Uses integer-range loop in level calculation.
ascii-dag/dag.go Uses slices.Contains to prevent duplicate edges.
actions_test.go Uses maps.Copy for copying action params into results.
actions/ssh/main.go Updates log map type to map[string]any.
actions/hello/main.go Uses maps.Copy for response map construction.
actions/db/main.go Updates callback signature to []any.
actions/browser/main.go Updates callback varargs to ...any.
actions.go Uses reflect.Pointer when detecting pointer values for protobuf conversion.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

mapping.go Outdated
} else if field.Type() == reflect.TypeFor[map[string]string]() {
v, ok := params[mapTag].(map[string]any)
if !ok && validateTag == labelRequired {
return fmt.Errorf("expected map[string]interface{} for field '%s'", mapTag)
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message still says map[string]interface{} even though this function now uses map[string]any elsewhere. Since any is the preferred spelling in this file, consider updating the message for consistency and easier debugging.

Suggested change
return fmt.Errorf("expected map[string]interface{} for field '%s'", mapTag)
return fmt.Errorf("expected map[string]any for field '%s'", mapTag)

Copilot uses AI. Check for mistakes.
Comment on lines +165 to +170
var result strings.Builder
for i := 0; i < n; i += length {
if i+length < len(s) {
result += s[i:i+length] + "\n"
result.WriteString(s[i:i+length] + "\n")
} else {
result += s[i:]
result.WriteString(s[i:])
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strings.Builder is a good change, but result.WriteString(s[i:i+length] + "\n") still allocates a temporary concatenated string each iteration. To keep this allocation-free, write the substring and newline separately (and optionally Grow the builder if you can estimate the final size).

Copilot uses AI. Check for mistakes.
- Update error message from map[string]interface{} to map[string]any in
  mapping.go for consistency
- Avoid temporary string allocation in strings.Builder by splitting
  WriteString and WriteByte calls in mail/bulk.go

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions

This comment has been minimized.

@github-actions
Copy link

github-actions bot commented Mar 4, 2026

Code Metrics Report

main (3f2408c) #169 (69facee) +/-
Coverage 56.0% 55.9% -0.1%
Code to Test Ratio 1:1.0 1:1.0 +0.0
Test Execution Time 1m25s 11s -1m14s
Details
  |                     | main (3f2408c) | #169 (69facee) |  +/-   |
  |---------------------|----------------|----------------|--------|
- | Coverage            |          56.0% |          55.9% |  -0.1% |
  |   Files             |             65 |             65 |      0 |
  |   Lines             |           6579 |           6548 |    -31 |
- |   Covered           |           3685 |           3662 |    -23 |
+ | Code to Test Ratio  |          1:1.0 |          1:1.0 |   +0.0 |
  |   Code              |          12888 |          12848 |    -40 |
- |   Test              |          13269 |          13267 |     -2 |
+ | Test Execution Time |          1m25s |            11s | -1m14s |

Code coverage of files in pull request scope (56.3% → 56.1%)

Files Coverage +/- Status
actions.go 41.3% 0.0% modified
actions/browser/main.go 0.0% 0.0% modified
actions/db/main.go 0.0% 0.0% modified
actions/hello/main.go 0.0% 0.0% modified
actions/ssh/main.go 0.0% 0.0% modified
ascii-dag/dag.go 82.0% -0.2% affected
ascii-dag/dag.go 63.4% 0.0% modified
ascii-dag/layout.go 88.6% 0.0% modified
browser/client.go 47.3% 0.0% modified
cmd/probe/main.go 54.7% -2.3% modified
dag/cycles.go 79.6% -1.2% modified
dag_ascii.go 92.9% -0.1% modified
db/client.go 36.7% 0.0% modified
embedded/client.go 16.0% +0.1% modified
error.go 58.8% 0.0% modified
expr.go 75.8% -0.2% modified
funcs.go 45.6% 0.0% modified
grpc/client.go 31.2% -0.5% modified
http/client.go 81.7% -0.3% modified
imap/client.go 29.7% +0.1% modified
mail/bulk.go 92.1% +0.1% modified
mail/mock_server.go 72.0% 0.0% modified
mapping.go 56.4% -0.4% modified
outputs.go 81.2% +0.9% modified
printer.go 78.0% 0.0% modified
probe.go 72.8% 0.0% modified
repeat.go 94.2% 0.0% modified
shell/client.go 86.2% -0.1% modified
ssh/client.go 19.1% +0.0% modified

Reported by octocov

@linyows
Copy link
Owner Author

linyows commented Mar 4, 2026

/run-e2e

@github-actions
Copy link

github-actions bot commented Mar 4, 2026

❌ E2E test failed. View logs

@github-actions
Copy link

github-actions bot commented Mar 4, 2026

✅ E2E test passed successfully!

@linyows linyows merged commit 7c65ec0 into main Mar 4, 2026
6 checks passed
@linyows linyows deleted the modernize branch March 4, 2026 09:09
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