A Golang package for simplifying storing configuration in the OS-provided secret manager.
MIT License
A Golang package for simplifying storing configuration in the OS-provided secret manager.
OS | Secret Manager |
---|---|
MacOS | OSX Keychain |
Linux | Gnome Keyring |
Linux | KWallet |
Windows | Windows Credential Manager |
go get -u github.com/infamousjoeg/go-keyconfig
For a full example of usage, please see example/example.go.
import "github.com/infamousjoeg/go-keyconfig"
func SetConfig (configID string, config interface{}) error
keyconfig.SetConfig
sets a struct type containing config key/values to the secret store of the current OS using the configID
value as the identifier. It first encodes the struct to JSON and then Base64 encodes it for prior to setting in the secret store. Only an error will be returned, if one occurs.
func GetConfig (configID string, config interface{}) error
keyconfig.GetConfig
gets a Base64-encoded key/value config from the current OS secret store using the configID
value as the identifier. It then Base64 decodes to JSON and then will unmarshal the JSON data into the struct provided as the config interface{}
value. Since the struct is provided when the function is called, only an error will be returned otherwise, if one occurs.
func DeleteConfig (configID string) error
keyconfig.DeleteConfig
removes a Base64-encoded key/value config from the current OS secret store using the configID
value as the identifier. Only an error will be returned, if one occurs.
go test -v ./...
Please responsibly disclose any security issues or concerns as outlined in the Security Guidelines.
MIT
Pull Requests are currently being accepted. Please read and follow the guidelines laid out in CONTRIBUTING.md.