Code formatting issue

Go noob here.

Currently I am using it to write some simple scripts. My 3rd party lib has lots of functions of the form:

resp, err := func(a)

So I created a little Must function son now I can do resp, err := func(a); Must(err) in one line.
However everytime I format the code (I use IntelliJ) it breaks it up to 2 lines.
I couldn’t google the answer to how to change formatting rules.

Anyone knows the answer?

1 Like

Unlike other languages, Go have a very strictly formatting rules to make your programs readable. If you look over many Go programs on the internet you will notice that all look like was written by the same person because one of the main principle in Go language design was the readability of the code. I don’t know how IntelliJ works but if it use the Go formatting rules (or tools) I guess it won’t allow multiple instructions on the same line.

References:
https://golang.org/cmd/gofmt/
https://golang.org/doc/effective_go#formatting

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.