profile
viewpoint

Ask questionsbreak long lines when it's appropriate to do so

Howdie, love your work, and just stumbled across this which also looks awesome :)

I use prettier with JavaScript, and cargo fmt with Rust, and they both automatically (and consistently) break up long lines

Example func:

func somethingTooLong(ctx context.Context, longArgument string, anotherOne func(time.Duration) bool) (int, error) {
	// foo
}
func somethingTooLong(
	ctx context.Context,
	longArgument string,
	anotherOne func(time.Duration) bool
) (int, error) {
	// foo
}

gofmt doesn't do this, but it also doesn't undo it where I've done this manually, so at least this particular example is gofmt-compatible

mvdan/gofumpt

Answer questions jokeyrhyme

Agreed, something about putting the second condition on the next line right next to the if body irks me a bit

prettier turns this:

if (isThisAReallyLongVariableName === 123 && doReallyLongNamedCheck() === true) {
  return true
}

into this:

if (
  isThisAReallyLongVariableName === 123 &&
  doReallyLongNamedCheck() === true
) {
  return true;
}

which works for me, but only because of the way the parens are used here, which is optional and completely uncommon in Go code

useful!

Related questions

No questions were found.
source:https://uonfu.com/
answerer
Ron Waldon jokeyrhyme @atlassian Gosford, NSW, Australia https://jokeyrhyme.github.io/ gay, male, cisgender, husband, Beagle chew-toy, JavaScript jockey, Apple / Google apologist
Github User Rank List