Re: [dev] golang dwm status

From: Markus Teich <markus.teich_AT_stusta.mhn.de>
Date: Thu, 13 Mar 2014 22:13:25 +0100

Silvan Jegen wrote:
> When scanning the code I saw several cases where you declared and
> initialized variables on the same line like this
>
> var void = 0 // target for unused values
> var dev, rx, tx, rxNow, txNow = "", 0, 0, 0, 0
> var scanner = bufio.NewScanner(file)
>
> if you do not want to bother with type declarations I would just eliminate
> 'var' completely by using the ':=' operator.
>
> void := 0 // target for unused values
> dev, rx, tx, rxNow, txNow := "", 0, 0, 0, 0
> ...

This is also intended. I wanted all variables (apart from the short lived ones
declared in for and if headers) to be easily findable with grep var. Anything
wrong with that?
I struggled a bit between the different kinds of variable declarations and tried
to keep it as consistent as possible with this rule:
In control structure headers, ":=" is allowed, everywhere else use "var".

> In any case, your code looks like idiomatic Go to me.

Thanks, much appreciated.

Regards,
Markus

Received on Thu Mar 13 2014 - 22:13:25 CET

This archive was generated by hypermail 2.3.0 : Thu Mar 13 2014 - 22:24:06 CET