An extensible Go library for handling program configuration using flags.
Alternatives To Flagga
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
a month ago13June 19, 20228otherPHP
Constantly updated lists of world countries and their associated alpha-2, alpha-3 and numeric country codes as defined by the ISO 3166 standard, available in CSV, JSON , PHP, SQL and XML formats, in multiple languages and with national flags included; also available are the ISO 3166-2 codes of provinces/ states associated with the countries
12 months ago33January 07, 2020mitSwift
🚩 Allows developers to configure feature flags, run multiple A/B tests or phase feature roll out using a JSON configuration file.
Config4641821 hours ago59October 16, 20227mitGo
📝 Go configuration manage(load,get,set,export). support JSON, YAML, TOML, Properties, INI, HCL, ENV and Flags. Multi file load, data override merge, parse ENV var. Go应用配置加载管理,支持多种格式,多文件加载,远程文件加载,支持数据合并,解析环境变量名
Aconfig43616a month ago65October 15, 202211mitGo
Simple, useful and opinionated config loader.
9 days ago1October 25, 2018mitGo
A feature flags client library for Go
Country Flag Emoji Json3912 years ago4September 11, 2021cc-by-sa-4.0JavaScript
Country flag emojis in JSON format.
Paerser39164 months ago7March 16, 20222apache-2.0Go
5 years ago1July 23, 2018mitGo
An extensible Go library for handling program configuration using flags.
13 months ago5January 04, 2022unlicenseGo
Configuration loader in Go
Json Typedef Infer22
a year ago4mitRust
A CLI tool that generates JSON Typedef schemas from example data
Alternatives To Flagga
Select To Compare

Alternative Project Comparisons

flagga GoDoc Build Status codecov Go Report Card License: MIT

flagga is an extensible Go library for handling program configuration using (but not limited to) command line arguments, environment variables and JSON.

This idea and API come from Peter Bourgon's Go for Industrial Programming talk at Gophercon Iceland 2018.

It should work as a drop-in replacement for the standard library flag package. The only difference is the fact that NewFlagSet and Init accept a second string for the description.


  • Be able to configure a program with different sources that have different priorities.
  • Be extensible so anyone can extend the API to provide different sources to get their configuration from (yaml, toml, database?, ...).
  • Be a drop-in replacement for the Go standard flag package with extra features.
  • Have no third-party dependencies.


go get github.com/erizocosmico/flagga

Or use your preferred dependency manager such as dep or vgo.


var fs flagga.FlagSet

db := fs.String("db", defaultDBURI, "database connection string", flagga.Env("DBURI"))
users := fs.StringList("users", nil, "list of allowed users", flagga.JSON("users"))

err := fs.Parse(os.Args[1:], flagga.JSONVia("config.json"), flagga.EnvPrefix("MYAPP_"))
if err != nil {
    // handle err

fmt.Println(*db) // Outputs: "[email protected]:1234/foo"
fmt.Println(strings.Join(*users, ", ")) // Outputs: "jane, joe, alice"

To get the previous results we can invoke the program in the following ways:

echo '{"users":["jane", "joe", "alice"]}' > config.json
./myprogram [email protected]:1234/foo -users=jane -users=joe -users=alice
[email protected]:1234/foo ./myprogram

Priority of sources

CLI flags always have priority over environment variables or JSON keys. If a flag is provided using the command line flags, no other sources will be checked for that variable.

The rest of the priorities depend of the order in which the sources are passed to the Parse method. For example, fs.Parse(os.Args, flagga.EnvPrefix("FOO_"), flagga.JSONVia("cfg")) gives more priority to environment variables than to the JSON configuration.

Available Extractors

  • Env: from environment variable sources.
  • JSON: from JSON sources.

YAML and TOML extractors are available in the flaggax repository.

Available Sources

  • EnvPrefix: provides all environment variables matching the given prefix.
  • JSONVia: provides the content of the JSON in the given file.

YAML and TOML sources are available in the flaggax repository.

Custom Sources and Extractors

You can implement your own Sources and Extractors in case your configuration is in a different format. Check out the Source and Extractor interfaces in the package documentation.




Popular Flags Projects
Popular Json Projects
Popular Text Processing Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Environment Variables