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
Conversation
…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>
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
✨ Code Quality
Problem
new(builtinLibs.String())andnew(proxy.String())are invalid Go. The built-innew()requires a type argument (e.g.,new(string)), not a value expression.builtinLibs.String()evaluates to astringvalue at runtime, sonew(...)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 importsgo.bug.st/fwhich providesf.ToPtr()for exactly this purpose.Severity:
criticalFile:
commands/service_settings.goSolution
Replace the
new(value)calls with the idiomatic pointer-helper from the already-importedfpackage:Changes
commands/service_settings.go(modified)Please check if the PR fulfills these requirements
See how to contribute
before creating one)
our contributing guidelines
UPGRADING.mdhas been updated with a migration guide (for breaking changes)configuration.schema.jsonupdated 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:
If you have questions or feedback about this PR, please comment below.
We appreciate your time reviewing this contribution!
Closes #3228