Skip to content

refactor(modernize): apply safe modernize fixes#861

Merged
mengzhuo merged 3 commits intosipeed:mainfrom
p3ddd:refactor/modernize
Mar 1, 2026
Merged

refactor(modernize): apply safe modernize fixes#861
mengzhuo merged 3 commits intosipeed:mainfrom
p3ddd:refactor/modernize

Conversation

@p3ddd
Copy link
Contributor

@p3ddd p3ddd commented Feb 27, 2026

📝 Description

This PR applies safe, mechanical modernization fixes across the codebase using modernize.
Scope is limited to non-functional refactors (loop/style/stdlib modernizations), with no API or behavior changes intended.

This is a follow-up maintenance cleanup complementary to #435.

Not included in this PR:

  • omitempty -> omitzero behavior-changing alternatives.

Reproducibility:

  • Applied with: modernize -fix -omitzero=false ./...

🗣️ Type of Change

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 📖 Documentation update
  • ⚡ Code refactoring (no functional changes, no api changes)

🤖 AI Code Generation

  • 🤖 Fully AI-generated (100% AI, 0% Human)
  • 🛠️ Mostly AI-generated (AI draft, Human verified/modified)
  • 👨‍💻 Mostly Human-written (Human lead, AI assisted or none)

🔗 Related Issue

N/A

📚 Technical Context (Skip for Docs)

  • Reference URL:
  • Reasoning:
    • After feat(fmt): Run formatters #435 , there were still reproducible modernize suggestions to address.
    • This PR keeps the modernization pass behavior-neutral and easy to review.
    • omitempty -> omitzero is intentionally deferred because it may change JSON serialization semantics.

🧪 Test Environment

  • Hardware: Mac mini M4
  • OS: macOS 26.3 (25D125)
  • Model/Provider: N/A
  • Channels: N/A

📸 Evidence (Optional)

Click to view Logs/Screenshots
➜ make check
all modules verified
ok      github.com/sipeed/picoclaw/cmd/picoclaw 0.744s
ok      github.com/sipeed/picoclaw/cmd/picoclaw/internal        (cached)
ok      github.com/sipeed/picoclaw/cmd/picoclaw/internal/agent  1.247s
ok      github.com/sipeed/picoclaw/cmd/picoclaw/internal/auth   (cached)
ok      github.com/sipeed/picoclaw/cmd/picoclaw/internal/cron   (cached)
ok      github.com/sipeed/picoclaw/cmd/picoclaw/internal/gateway        1.564s
ok      github.com/sipeed/picoclaw/cmd/picoclaw/internal/migrate        (cached)
ok      github.com/sipeed/picoclaw/cmd/picoclaw/internal/onboard        (cached)
ok      github.com/sipeed/picoclaw/cmd/picoclaw/internal/skills 2.033s
ok      github.com/sipeed/picoclaw/cmd/picoclaw/internal/status (cached)
ok      github.com/sipeed/picoclaw/cmd/picoclaw/internal/version        (cached)
ok      github.com/sipeed/picoclaw/pkg/agent    2.734s
ok      github.com/sipeed/picoclaw/pkg/auth     (cached)
?       github.com/sipeed/picoclaw/pkg/bus      [no test files]
ok      github.com/sipeed/picoclaw/pkg/channels 3.014s
ok      github.com/sipeed/picoclaw/pkg/config   3.521s
?       github.com/sipeed/picoclaw/pkg/constants        [no test files]
ok      github.com/sipeed/picoclaw/pkg/cron     (cached)
?       github.com/sipeed/picoclaw/pkg/devices  [no test files]
?       github.com/sipeed/picoclaw/pkg/devices/events   [no test files]
?       github.com/sipeed/picoclaw/pkg/devices/sources  [no test files]
?       github.com/sipeed/picoclaw/pkg/fileutil [no test files]
?       github.com/sipeed/picoclaw/pkg/health   [no test files]
ok      github.com/sipeed/picoclaw/pkg/heartbeat        (cached)
ok      github.com/sipeed/picoclaw/pkg/logger   (cached)
ok      github.com/sipeed/picoclaw/pkg/migrate  (cached)
ok      github.com/sipeed/picoclaw/pkg/providers        15.892s
ok      github.com/sipeed/picoclaw/pkg/providers/anthropic      4.416s
ok      github.com/sipeed/picoclaw/pkg/providers/openai_compat  3.889s
?       github.com/sipeed/picoclaw/pkg/providers/protocoltypes  [no test files]
ok      github.com/sipeed/picoclaw/pkg/routing  5.073s
ok      github.com/sipeed/picoclaw/pkg/session  (cached)
ok      github.com/sipeed/picoclaw/pkg/skills   5.167s
ok      github.com/sipeed/picoclaw/pkg/state    5.096s
ok      github.com/sipeed/picoclaw/pkg/tools    5.914s
ok      github.com/sipeed/picoclaw/pkg/utils    4.562s
?       github.com/sipeed/picoclaw/pkg/voice    [no test files]

☑️ Checklist

  • My code/docs follow the style of this project.
  • I have performed a self-review of my own changes.
  • I have updated the documentation accordingly.

Copy link
Collaborator

@mengzhuo mengzhuo left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@yinwm
Copy link
Collaborator

yinwm commented Feb 27, 2026

@p3ddd please fix linter failed

@p3ddd p3ddd requested a review from mengzhuo February 27, 2026 13:36
Copy link

@nikolasdehor nikolasdehor left a comment

Choose a reason for hiding this comment

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

Clean mechanical modernization pass. All changes are behavior-preserving:

  • for range N replacing for i := 0; i < N; i++** (Go 1.22+) -- correct when the loop variable was unused
  • slices.Contains/slices.Sort/slices.ContainsFunc replacing manual search loops -- correct, more readable
  • strings.Cut/strings.CutPrefix/strings.CutSuffix replacing strings.HasPrefix + strings.TrimPrefix patterns -- correct, avoids the double-scan
  • maps.Copy replacing manual map iteration -- correct
  • strings.Builder replacing string concatenation -- correct, avoids quadratic allocation in parseResponse, listJobs, and NormalizeAgentID test
  • max() builtin replacing manual min/max patterns -- correct (Go 1.21+)
  • wg.Go() replacing wg.Add(1) + go func() -- correct (sync.WaitGroup.Go is Go 1.25+, and picoclaw uses Go 1.25)

The omitzero exclusion is sensible since it changes JSON serialization semantics.

All tests passing per the evidence. LGTM.

@p3ddd
Copy link
Contributor Author

p3ddd commented Feb 28, 2026

@nikolasdehor I’ve resolved the merge conflicts. Could you please approve/run the workflows for this fork PR when convenient? Thank you very much.

@p3ddd
Copy link
Contributor Author

p3ddd commented Feb 28, 2026

@yinwm CI is now green and conflicts are resolved. This PR is ready to merge when you have time. Thanks!

@mengzhuo mengzhuo merged commit f7136b6 into sipeed:main Mar 1, 2026
2 checks passed
@xiaket
Copy link
Collaborator

xiaket commented Mar 1, 2026

should we add a step in CI to check this automatically?

@Orgmar
Copy link
Contributor

Orgmar commented Mar 2, 2026

@p3ddd Clean modernize pass. Keeping the codebase up to date with newer Go patterns and stdlib improvements without changing behavior is valuable maintenance work that often gets overlooked.

We're building a PicoClaw Dev Group on Discord for contributors to connect and collaborate. If you'd like to join, send an email to support@sipeed.com with the subject [Join PicoClaw Dev Group] p3ddd and we'll send you the invite link.

hyperwd pushed a commit to hyperwd/picoclaw that referenced this pull request Mar 5, 2026
refactor(modernize): apply safe modernize fixes
Pluckypan pushed a commit to Pluckypan/picoclaw that referenced this pull request Mar 6, 2026
refactor(modernize): apply safe modernize fixes
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.

6 participants