Skip to content

infamousjoeg/go-keyconfig

Repository files navigation

go-keyconfig

Go Reference CodeQL keyconfig CI

A Golang package for simplifying storing configuration in the OS-provided secret manager.

Operating System Support

OS Secret Manager
MacOS OSX Keychain
Linux Gnome Keyring
Linux KWallet
Windows Windows Credential Manager

Installation

go get -u github.com/infamousjoeg/go-keyconfig

Usage

Example

For a full example of usage, please see example/example.go.

import "github.com/infamousjoeg/go-keyconfig"

func SetConfig

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

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

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.

Screenshots

MacOS

MacOS Image 1

MacOS Image 2

Linux

Linux Image 1

Linux Image 2

Windows

Windows Image 1

Testing

go test -v ./...

Security

Please responsibly disclose any security issues or concerns as outlined in the Security Guidelines.

License

MIT

Maintainer

@infamousjoeg

Buy me a coffee

Contributions

Pull Requests are currently being accepted. Please read and follow the guidelines laid out in CONTRIBUTING.md.

About

A Golang package for simplifying storing configuration in the OS-provided secret manager.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks