Inspectopedia 2026.1 Help

Replace new-like function call with 'new()'

Syntax update: replace new-like helper functions with new()

Reports calls to "new-like" helper functions that can be replaced with Go 1.26's new(expr) syntax.

A new-like function is a helper that takes a value and returns a pointer to a copy of that value. These functions are commonly used to create pointers to primitive values in struct initializations. Popular examples include proto.Int64, proto.String, proto.Bool, and similar functions from the Protocol Buffers library (google.golang.org/protobuf/proto).

Example:

msg := &pb.Person{ Name: proto.String("Alice"), Age: proto.Int64(30), }

Here, proto.String and proto.Int64 are new-like functions that create pointers to string and int64 values.

To simplify, use the Replace with 'new()' quick-fix. After the quick-fix is applied:

msg := &pb.Person{ Name: new("Alice"), Age: new(int64(30)), }

Locating this inspection

By ID

Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

GoReplaceNewLikeFunctionCall
Via Settings dialog

Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.

Settings or Preferences | Editor | Inspections | Go | Syntax updates

Inspection ID: GoReplaceNewLikeFunctionCall

Suppressing Inspection

You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:

//noinspection GoReplaceNewLikeFunctionCall

More detailed instructions as well as other ways and options that you have can be found in the product documentation:

Inspection Details

By default bundled with:

GoLand 2026.1, Qodana for Go 2026.1,

Last modified: 31 March 2026