
Security News
Meet Socket at Black Hat Europe and BSides London 2025
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.
goconfig uses a struct as input and populates the fields of this struct with parameters from command line, environment variables and configuration file.
go get github.com/gosidekick/goconfig
package main
import "github.com/gosidekick/goconfig"
/*
step 1: Declare your configuration struct,
it may or may not contain substructures.
*/
type mongoDB struct {
Host string `cfgDefault:"example.com" cfgRequired:"true"`
Port int `cfgDefault:"999"`
}
type configTest struct {
Domain string
DebugMode bool `json:"db" cfg:"db" cfgDefault:"false"`
MongoDB mongoDB
IgnoreMe string `cfg:"-"`
}
func main() {
// step 2: Instantiate your structure.
config := configTest{}
// step 3: Pass the instance pointer to the parser
err := goconfig.Parse(&config)
if err != nil {
println(err)
return
}
/*
The parser populated your struct with the data
it took from environment variables and command
line and now you can use it.
*/
println("config.Domain......:", config.Domain)
println("config.DebugMode...:", config.DebugMode)
println("config.MongoDB.Host:", config.MongoDB.Host)
println("config.MongoDB.Port:", config.MongoDB.Port)
}
With the example above try environment variables like $DOMAIN or $MONGODB_HOST and run the example again to see what happens.
You can also try using parameters on the command line, try -h to see the help.
git checkout -b fantastic-feature.git commit -m 'Implementation of new fantastic feature'git push origin fantastic-feature.FAQs
Unknown package
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.