Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
sflags
✓ github.com/octago/sflags
Parses command-line flags from a struct definition.
package main
import (
"flag"
"fmt"
"github.com/octago/sflags"
)
type Config struct {
Name string `flag:"name" default:"world"`
}
func main() {
cfg := &Config{}
fs := flag.NewFlagSet("example", flag.ExitOnError)
sflags.ParseStruct(fs, cfg)
fs.Parse([]string{"-name", "Go"})
fmt.Println("Hello", cfg.Name)
}
Debug
Known issues
No known issues recorded.
Upgrade
Version history
0.4.1latest on pkg.go.dev
Audit
Dependencies
No dependency data recorded yet.