Besides the stand library “flag”, there are many Go libraries for parsing command line arguments. Excluding inactive ones, there are still many (see below). Which of them is the best for parsing command-line arguments?
cobra is not to parse command line but for build CLI programs.
Usually I follow the selection in this way:
- I need something simple →
flag is not enough →
- if I need environment variable management →
spf13/viper (it manages also configuration files)
Thank you so much, Massimo!
May I ask another question please? Generally speaking, how can a GoLANG beginner quickly identify a few good libraries for his need? Taking command line parsing libraries for example, I immediately learned from online resource that “flag” is a standard library for this purpose. However, there are many voices online saying that it is very limited (which I can confirm after trying it for a while). I searched for alternative packages on pkg.go.dev but I don’t think the returned results were very helpful. There was no way for me to sort search results according to how active/popular each library is. The good library spf13/viper doesn’t show up in the first 2 pages.
What is a good way for a GoLANG beginner to quickly adopt good practices in the GoLANG community?
now sure is the best way but I usually start from searching by category on awesome-go.com.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.