keyconfig

package module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2022 License: MIT Imports: 4 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

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.

Documentation

Overview

Package keyconfig implements a simple keychain wrapper for storing and retrieving configs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteConfig

func DeleteConfig(configID string) error

DeleteConfig deletes the config from keychain. Note: The configID is used as the key for the config.

func GetConfig

func GetConfig(configID string, config interface{}) error

GetConfig gets the config from keychain and decodes it into an interface. Note: The configID is used as the key for the config.

func SetConfig

func SetConfig(configID string, config interface{}) error

SetConfig sets the config to keychain from an interface. Note: The configID is used as the key for the config.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址