What is the best flag package ?

1,205 views
Skip to first unread message

daru...@gmail.com

unread,
Apr 22, 2014, 8:29:10 PM4/22/14
to golan...@googlegroups.com
Friends,
        I am a newbie to GO and it is going to be my go to language.
I would like to know if there is a better package than inbuilt flag package http://golang.org/pkg/flag/

I see people using several modified packages, please let me know which has the most number of features ?

There is one package Docker is using, looks like it has more features.

Do I need to go ahead and use the inbuilt one or any better package existing ? 

I am so used to python argparse and would like to start using something like that in GO.
Please direct me in the right direction.


Darup 

Shawn Milochik

unread,
Apr 22, 2014, 9:08:48 PM4/22/14
to golan...@googlegroups.com
First, check this out:


I'm also a Python developer, and lots of things are easier in Python than Go. Go isn't Python. It's Go. 

The right direction: Learn to use what Go offers first. If you actually use it and understand it and can articulate exactly how it's insufficient for your needs, then you will probably get real, constructive help. 

If you have specific functionality you can't figure out with the flag package, explain your problem. If you just don't like that the syntax is different than argparse, then you probably just need to get some more hands-on time with Go.

daru...@gmail.com

unread,
Apr 22, 2014, 11:40:02 PM4/22/14
to golan...@googlegroups.com, Sh...@milochik.com
I appreciate the answer, that was really appropriate, I agree
Cheers :)

Hai Thanh Nguyen

unread,
Apr 23, 2014, 1:25:01 AM4/23/14
to golan...@googlegroups.com, daru...@gmail.com
This is a good one that I use https://github.com/jessevdk/go-flags

Justin Israel

unread,
Apr 23, 2014, 5:20:45 AM4/23/14
to Hai Thanh Nguyen, golang-nuts, daru...@gmail.com
+1 for that go-flags recommendation. I love it. 

For anyone else that has used it, do you know how to include a much longer long description string in a nice way? I only seem to know how to just do it right there in the tag. But I would prefer to define it in a nicely formatted multi-line string, and then set it. 


--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jesse van den Kieboom

unread,
Apr 23, 2014, 10:46:10 AM4/23/14
to golan...@googlegroups.com, Hai Thanh Nguyen, daru...@gmail.com
You can, although you need to do a bit of work. See http://play.golang.org/p/MJi0itaz00 for an example. I'm not against adding some convenience API for this use case in go-flags, as long as it doesn't clutter the API, but I've not needed it myself yet.

Kyle Lemons

unread,
Apr 23, 2014, 1:35:22 PM4/23/14
to daru...@gmail.com, golang-nuts
On Tue, Apr 22, 2014 at 5:29 PM, <daru...@gmail.com> wrote:
Friends,
        I am a newbie to GO and it is going to be my go to language.
I would like to know if there is a better package than inbuilt flag package http://golang.org/pkg/flag/

I see people using several modified packages, please let me know which has the most number of features ?

There is one package Docker is using, looks like it has more features.

Do I need to go ahead and use the inbuilt one or any better package existing ? 

While I recognize the perceived deficiencies in the stdlib "flag" package, I think that when you're getting started with Go you should make use of it as much as possible; it's the common denominator, and it is actually perfectly full-featured and has some good reasons for the features it doesn't include.  Once you know the language and its idioms well, you can make a more informed decision about when/where to use another package, and you'll know how to evaluate them better.
 
I am so used to python argparse and would like to start using something like that in GO.
Please direct me in the right direction.


Darup 

--

daru...@gmail.com

unread,
Apr 23, 2014, 2:02:18 PM4/23/14
to golan...@googlegroups.com, daru...@gmail.com
Thanks for the wisdom.

Justin Israel

unread,
Apr 24, 2014, 5:13:41 AM4/24/14
to Jesse van den Kieboom, daru...@gmail.com, golang-nuts, Hai Thanh Nguyen


On Apr 24, 2014 2:46 AM, "Jesse van den Kieboom" <jess...@gmail.com> wrote:
>
> You can, although you need to do a bit of work. See http://play.golang.org/p/MJi0itaz00 for an example. I'm not against adding some convenience API for this use case in go-flags, as long as it doesn't clutter the API, but I've not needed it myself yet.
>
>

Ah awesome. So it is possible. I actually needed it right away since I was porting an existing tool from another language to Go. And it had a very descriptive description for certain flags. Would be really great if it were directly supported in the library to make it easy. I don't think it is all that uncommon to have much longer descriptions for certain flags.

C Banning

unread,
Apr 24, 2014, 10:55:48 AM4/24/14
to golan...@googlegroups.com, Hai Thanh Nguyen, daru...@gmail.com
Why not something like this: http://play.golang.org/p/23PedCe95r?

Justin Israel

unread,
Apr 25, 2014, 9:14:29 PM4/25/14
to C Banning, daru...@gmail.com, golang-nuts, Hai Thanh Nguyen

On Apr 25, 2014 2:55 AM, "C Banning" <clba...@gmail.com> wrote:
>
> Why not something like this: http://play.golang.org/p/23PedCe95r?
>
>

Thanks but I was specifically asking about doing long descriptions using go-flags and not the stdlib flags.

Reply all
Reply to author
Forward
0 new messages