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/gofmt: damages the indentation #12257

Closed
ip opened this issue Aug 21, 2015 · 2 comments
Closed

cmd/gofmt: damages the indentation #12257

ip opened this issue Aug 21, 2015 · 2 comments

Comments

@ip
Copy link

@ip ip commented Aug 21, 2015

For example it turns this

const REGEXP_WHOLE =
    // [1] Return value
    `^\s*` + REGEXP_TYPE +
    // 3+1 = [4] Function name
    `(gl\w+)\s*` +
    // [5] Argument list
    `\((` + REGEXP_ARG_LIST + `)\)\s*$`

// ...

returnType  := submatches[1]
funcName    := submatches[4]
argList     := submatches[5]

into

const REGEXP_WHOLE =
// [1] Return value
`^\s*` + REGEXP_TYPE +
    // 3+1 = [4] Function name
    `(gl\w+)\s*` +
    // [5] Argument list
    `\((` + REGEXP_ARG_LIST + `)\)\s*$`

// ...

returnType := submatches[1]
funcName := submatches[4]
argList := submatches[5]

Especially first case is annoying. Is it at least a way to locally disable it with comments like in other similar tools i.e. like that?

// gofmt off
blablabla
// gofmt on
@bradfitz
Copy link
Contributor

@bradfitz bradfitz commented Aug 21, 2015

No, there's no such mechanism.

You'll have to find another way to reformat your code to make both gofmt and yourself happy.

As an aside, NAMES_LIKE_THIS should be NamesLikeThis or namesLikeThis in Go. See https://github.com/golang/go/wiki/CodeReviewComments#mixed-caps

@bradfitz bradfitz closed this Aug 21, 2015
@ip
Copy link
Author

@ip ip commented Aug 21, 2015

@bradfitz Ok, thanks for noticing about constants.

@mikioh mikioh changed the title gofmt damages the indentation cmd/gofmt: damages the indentation Aug 22, 2015
@golang golang locked and limited conversation to collaborators Aug 22, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.