GitHub release (latest SemVer) GitHub go.mod Go version GoDoc License
Build Quality Gate Status Coverage Go Report Card

Welcome to go-credentials!

This project is being built out of a need for a library to manage credentials files (similar to AWS credentials), their attributes, sessions, and environment variables.

go-credentials logo

The Credential API is broken down into two pieces, each with their own functionality:

  1. Factory: responsible for setting variables that are global to your application, and;
    • Set alternate keys for username/password (e.g. ACCESS_TOKEN/SECRET_KEY).
    • Set the output type of the credentials (environment, ini, and json supported).
    • Responsible for logging.
  2. Credential: represents a user's credentials.
    • Username/Password defined on model.
    • Can have a profile.
    • Save and Load Credentials (and Profiles).
  3. Profile: represents a profile, containing variables specific to a profile.
    • Username/Password defined on model.
    • Set Attributes (including sections).
    • Get Attributes (including sections).

To get started, is all you need to do is create the following files.


username =
password = !my_test_pass==word


package main

import (

func main() {
	myFact, _ := factory.New("gcea", false) // go-credentials-example-application
	myFact.ModifyLogger("trace", true) // let's see under the hood and make it pretty.
	myCredential, _ := credential.Load(myFact)

	fmt.Printf("Username: %s\n", myCredential.Username)
	fmt.Printf("Password: %s\n\n", myCredential.Password)

	myCredential.SetSectionAttribute("metadata", "last_updated", time.Now().Format("02/01/2006 15:04:05"))
	myCredential = nil

	yourCredential, _ := credential.Load(myFact)

	fmt.Printf("Username: %s\n", yourCredential.Username)
	fmt.Printf("Password: %s\n", yourCredential.Password)

	lastUpdated, _ := yourCredential.GetSectionAttribute("metadata", "last_updated")
	fmt.Printf("Last Updated: %s\n", lastUpdated)
Expand ▾ Collapse ▴


Path Synopsis
credential Package credential provides the base implementation detail for the go-credentials library.
factory Package factory provides an API for managing application-level credential details.
global Package global contains constants, test variables, and some minor utility functions.
profile Package profile contains all of the code for managing multiple credential files.
serializer Package serializer is responsible for de/serializing Credential and Profile objects into different file formats.