Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/fmt: inconsistent formatting of math when a function is part of an expression #7880

Closed
gopherbot opened this issue Apr 27, 2014 · 1 comment

Comments

@gopherbot
Copy link

by magwebpub:

There seems to be an edge case with math operator spacing in gofmt. Normally gofmt
adds/preserves spaces around expressions like "a := (b + (1 / (2 * c * c))) *
100" but when a function is added like the spacing is lost. So given an input like
"a := math.Abs(b + (1 / (2 * c * c))) * 100" gofmt will produce "a :=
math.Abs(b+(1/(2*c*c))) * 100".


Seeing this against the following builds/versions and the play.golang.org site:
  go version go1.2.1 darwin/amd64
  go version go1.2.1 linux/amd64


Here's a simple example: http://play.golang.org/p/BwLsi2-iU_
A more complex one: http://play.golang.org/p/w5jx0py1Xc

In both cases, the combination of a function call with another expression leads to the
loss of formatting in the function call's argument.
@ianlancetaylor
Copy link
Contributor

Comment 1:

This is the way that gofmt is designed to work.  See the long comment above the
binaryExpr method in pkg/go/print/nodes.go.

Status changed to WorkingAsIntended.

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants