Flagstruct
A simple way to register and parse flag into struct
Install / Use
/learn @ngdinhtoan/FlagstructREADME
FlagStruct
A simple way to register and parse flag into struct
Install
go get -u github.com/ngdinhtoan/flagstruct
Tag syntax
`flag:"name" default:"value" usage:"description"`
Tag default and usage can be omit.
Example
package main
import (
"fmt"
"github.com/ngdinhtoan/flagstruct"
)
type dbConfig struct {
Hostname string `flag:"hostname" default:"localhost" usage:"Hostname"`
Port uint64 `flag:"port" default:"3306"`
DbName string `flag:"db_name" usage:"Database name"`
}
func main() {
conf := dbConfig{}
flagstruct.Parse(&conf)
fmt.Println("Hostname:", conf.Hostname)
fmt.Println("Port:", conf.Port)
fmt.Println("DB Name:", conf.DbName)
}
Run with some options:
go run main.go -hostname=127.0.0.1 -db_name=test_db
Output:
Hostname: 127.0.0.1
Port: 3306
DB Name: test_db
Related Skills
node-connect
352.9kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
xurl
352.9kA CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
frontend-design
111.5kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
352.9kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
