Re: [dev] golang dwm status

From: Silvan Jegen <s.jegen_AT_gmail.com>
Date: Thu, 13 Mar 2014 22:01:30 +0100

On Thu, Mar 13, 2014 at 04:33:16PM -0400, Charlie Andrews wrote:
> On Thu, Mar 13, 2014 at 09:21:09PM +0100, Markus Teich wrote:
> >
> > If you like, please explain the benefits of the first 2 points a bit more
> > detailed (see my other mail for my reasoning)
>
> In both cases, I believe it's much more readable and maintainable to
> have a section for imports and a section for vars (global-ish variabls).
> Readability is subjective I guess, but maintainability is not, and it is
> much easier this way to add imports and vars with fewer key strokes
> later. If I wanted to log a random part all I would have to do is pop in
> "log" into the list and go on my merry way. This is a very small
> workflow optimization, but who knows what a few seconds saved here could
> do.

I agree.


> > Ok, I will try to find a readable way for the slice-literal then. Thanks.
>
> I find this very readable:
>
> newSlice := []string{
> "string1",
> "string2",
> "string3", // yes you need the comma here
> }
>
> but again, readability is subjective, so it's up to you.

I see it the same way. These are probably personal preferences for the
most part. While we are talking about personal preferences...

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
                ...

In any case, your code looks like idiomatic Go to me.
Received on Thu Mar 13 2014 - 22:01:30 CET

This archive was generated by hypermail 2.3.0 : Thu Mar 13 2014 - 22:12:08 CET