Skip to content

Quality: Invalid use of Go's new builtin — will not compile or produces wrong pointer#3229

Open
kumburovicbranko682-boop wants to merge 1 commit into
arduino:masterfrom
kumburovicbranko682-boop:contribai/improve/quality/invalid-use-of-go-s-new-builtin-will-not
Open

Quality: Invalid use of Go's new builtin — will not compile or produces wrong pointer#3229
kumburovicbranko682-boop wants to merge 1 commit into
arduino:masterfrom
kumburovicbranko682-boop:contribai/improve/quality/invalid-use-of-go-s-new-builtin-will-not

Conversation

@kumburovicbranko682-boop

Copy link
Copy Markdown

✨ Code Quality

Problem

new(builtinLibs.String()) and new(proxy.String()) are invalid Go. The built-in new() requires a type argument (e.g., new(string)), not a value expression. builtinLibs.String() evaluates to a string value at runtime, so new(...) cannot accept it. This is either a compilation error preventing the package from building, or—if shadowed by some local declaration—it would allocate a zero-valued string instead of the intended value. The project imports go.bug.st/f which provides f.ToPtr() for exactly this purpose.

Severity: critical
File: commands/service_settings.go

Solution

Replace the new(value) calls with the idiomatic pointer-helper from the already-imported f package:

Changes

  • commands/service_settings.go (modified)

Please check if the PR fulfills these requirements

See how to contribute

  • The PR has no duplicates (please search among the Pull Requests
    before creating one)
  • The PR follows
    our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • UPGRADING.md has been updated with a migration guide (for breaking changes)
  • configuration.schema.json updated if new parameters are added.

What kind of change does this PR introduce?

What is the current behavior?

What is the new behavior?

Does this PR introduce a breaking change, and is titled accordingly?

Other information


🤖 About this PR

This pull request was generated by ContribAI, an AI agent
that helps improve open source projects. The change was:

  1. Discovered by automated code analysis
  2. Generated by AI with context-aware code generation
  3. Self-reviewed by AI quality checks

If you have questions or feedback about this PR, please comment below.
We appreciate your time reviewing this contribution!

Closes #3228

…duces wrong pointer

`new(builtinLibs.String())` and `new(proxy.String())` are invalid Go. The built-in `new()` requires a type argument (e.g., `new(string)`), not a value expression. `builtinLibs.String()` evaluates to a `string` value at runtime, so `new(...)` cannot accept it. This is either a compilation error preventing the package from building, or—if shadowed by some local declaration—it would allocate a zero-valued string instead of the intended value. The project imports `go.bug.st/f` which provides `f.ToPtr()` for exactly this purpose.


Affected files: service_settings.go

Signed-off-by: kumburovicbranko682-boop <295886834+kumburovicbranko682-boop@users.noreply.github.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

3 participants