Skip to content

cmd/gofmt: remove plus operator before variable #30299

@kevinburke

Description

@kevinburke

In the following program:

package main

import "fmt"

func main() {
	a := 3
	b := 7
	a = +b
	a += +b
	fmt.Println("a", a, "b", b)
}

I believe the +b is extraneous and does not modify command operation, in both cases. Could go fmt simplify this by removing the plus operator? Similarly we remove things like braces and semicolons when they are unnecessary and do not affect program operation.

Running go tip.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureRequestIssues asking for a new feature that does not need a proposal.NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions