Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/inozuma/flagger

golang flag structure parsing
https://github.com/inozuma/flagger

Last synced: 24 days ago
JSON representation

golang flag structure parsing

Awesome Lists containing this project

README

        

# flagger
`flagger` is a simple package wrapping `flag` standard package allowing the declaration of flags via a structure.

# Installation

```
go get -u github.com/inozuma/flagger
```

# Usage

## Simple usage

Supposing we have a `Configuration`:

```go
type Configuration struct {
Enable bool `flag:"enable,false,enable something"`
Address string `flag:"addr,:8080,address to something"`
}
```

You can call `flagger.Flag` to declare the flag `enable`:

```go
config := &Configuration{}

if err := flagger.Flag(config); err != nil {
panic(err)
}
```

And like `flag`, parse your flags with `flag.Parse`:

```go
flag.Parse()
```