Matt Cudmore <
cudmo...@gmail.com> writes:
> I went looking to see if someone had already asked about this.
>
> it also shows up in this example:
>
> fmt.Println("a"+"b", "c", 1+2)
> fmt.Println([]interface{}{"a" + "b", "c", 1 + 2}...)
>
> in the second line, gofmt puts spaces between everything.
>
> not a big issue though, the inconsistency simply catches the eye and
> doesn't immediately make sense.
It's somewhat inconsistent, but only in that function calls and value
literals have different rules.
On Wednesday, 16 January 2013 00:01:15 UTC-4, RMacy wrote:
> When I run gofmt, it puts a space before and after the plus in Println,
> but not on other functions like ListenAndServe.
>
> fmt.Println("Listening for incoming requests on: " +
> os.Getenv("PORT"))
> err := http.ListenAndServe(":"+os.Getenv("PORT"), nil)
>
> Is that intended-- I can file a bug if not.
>
> _Ryan
>
gofmt uses operator spacing (or the lack thereof) to signify operator
precedence.
This also applies to using operators in function calls with only one
argument and more than one argument.
Also see
http://play.golang.org/p/PCyV62nKhH