For CLI it’s true to the Go mantra. If the flags library is “good enough” why not just use it and avoid being fancy?
Besides, isn’t it feasible someone might confuse long and short options? “Is -d and —delete the same, or is -d —debug??” KISS even if it’s annoying.
As for loops, I know that they’re generally more common in Go. Another example is finding if an element exists in a slice. Most of the implementations is this stuff is just a loop under the hood in the end.
From a Java background it was strange to me because I’m used to dealing with classes and there’s always a method for this or that...
> For CLI it’s true to the Go mantra. If the flags library is “good enough” why not just use it and avoid being fancy?
Users of a command line utility ultimately don’t care what language it’s written in; having a familiar interface is a much more important goal. Since the vast majority of Linux utilities these days use GNU-style rather than Unix-style long options, it stands to reason that the latter is a better choice for users. (There are also technical advantages I won’t get into.) I know Rob Pike probably isn’t a fan given his background, but why not give developers the choice to build what they want to build, instead of shoehorning them into something they dislike? What’s the point of being opinionated here? (Edit: Sorry, didn’t mean to imply that the standard library ought to have it; however, I do find it strange that in the ten years of golang the community didn’t bother to come up with a reasonably good library for it.)
Btw, flags is very primitive and can hardly handle anything complex, even if you accept the Unix-style.
Sorry for the bother but I'm a big lost due to the lingo and the interwebs are unclear: by unix-style long options do you mean single-dash long options (e.g. `-long` being a single option), and therefore flags not allowing concatenating short options (e.g. `-r -x` can't be written `-rx`)?
> by unix-style long options do you mean single-dash long options (e.g. `-long` being a single option)
Yes.
> and therefore flags not allowing concatenating short options (e.g. `-r -x` can't be written `-rx`)?
Depending on the implementation concatenation of short options may be allowed; it certainly could be ambiguous. I'm not sure about flags (the golang package) though.
Besides, isn’t it feasible someone might confuse long and short options? “Is -d and —delete the same, or is -d —debug??” KISS even if it’s annoying.
As for loops, I know that they’re generally more common in Go. Another example is finding if an element exists in a slice. Most of the implementations is this stuff is just a loop under the hood in the end.
From a Java background it was strange to me because I’m used to dealing with classes and there’s always a method for this or that...