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

Another example, this time in rustfmt (Rust is like Go in that if conditions do not require parens):

    if isThisAReallyReallyReallyReallyReallyLongVariableName == 123 && doReallyReallyReallyLongNamedCheck() == true {
        return true;
    }

becomes:

    if isThisAReallyReallyReallyReallyReallyLongVariableName == 123
        && doReallyReallyReallyLongNamedCheck() == true
    {
        return true;
    }
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