a := newApp(servers)
https://github.com/facebookgo/grace/blob/master/gracehttp/ht...
EDIT: read my comment below where I elaborate
a := newApp(servers)
https://github.com/facebookgo/grace/blob/master/gracehttp/ht...
EDIT: read my comment below where I elaborate
If you are going to be creating these complex structures why not using a factory function for it? If there were many creations of this type it could severely increase the bulk of the code....
Are you saying you dislike single-character variable names, and that you see them frequently in Go?
In the context of reading someone else's source code, the variable name "a" is inadequate, and I've seen it in many Golang codebases. It's like intentionally obtuse code.
Maybe I haven't read enough Go code in the wild, but it really feels like the C days. Yes, it's GC'd, and that makes a difference. Yet I can't help but wonder how much easier it is to read code from the Python or Ruby communities. I'd even go as far to say that it's easier to read code from the Javascript community.
Your "complaint" of go actually have nothing to do with Go itself...
In my opinion, a is an great variable name. Especially when it is used after calling a function like newApp(...). I may have picked a different name for newApp but it was still clear to me what it did.
Personally I think single character variable names are over used in Go as well, but at least they're generally restricted to the smallest of functions (eg struct methods), or instances where a longer name wouldn't be more descriptive (eg inside for loops (for i := 0), or b[], byte arrays.).
However in this specific example, I think "a := NewApp(server)" is both readable and overly terse. So I do find myself agreeing with the OP in their example.
I have two metrics for variable names. First, is it clear what the variable is? You say yes. Second, is it not obnoxious to type? Clearly not.
So, at least by my metrics, it's a great variable name.
I've looked at a lot of other people's Go code and I have had no issue with 1 character variable names, but maybe that is just me. The methods/functions is generally small enough that it is obvious to me what is happening.