gocredo

A Golang package for creating random (and valid) credentials.
Right now, only PostgreSQL user accounts are supported.
And "gocredo" rhymes with "Freddo".
The "Credentials" struct
The package exposes the following functions which return instances of the Credentials struct:
The Credentials struct exposes the following members:
Username is the randomly-generated username.
Password is the randomly-generated password.
The Credentials struct exposes the following functions:
ToJSON() (string, error) returns the username and password as a JSON string.
MakeForPostgreSQL
MakeForPostgreSQL creates a set of credentials suitable for a PostgreSQL database.
package main
import (
"fmt"
"github.com/cariad/gocredo"
)
func main() {
credentials, _ := gocredo.MakeForPostgreSQL()
fmt.Println(credentials.Username)
// xcdumcpwjfderkyjreixpjfypwlqpkuunktzjshvqpocbqwtxxlxoofdiliprtd
fmt.Println(credentials.Password)
// SH7Z71RKiXImpk4SEDoWqn1YzLNjkfMMglXIasOCKvyNENjXAXgpAInfnDBCBe7
credentialsJSON, _ := credentials.ToJSON()
fmt.Println(credentialsJSON)
// {"username":"xcdumcpwjfderkyjreixpjfypwlqpkuunktzjshvqpocbqwtxxlxoofdiliprtd","password":"SH7Z71RKiXImpk4SEDoWqn1YzLNjkfMMglXIasOCKvyNENjXAXgpAInfnDBCBe7"}
}
Security
This package uses https://github.com/cariad/gorando
to generate random values, and you should read that package's security notes.
Also, this package intentionally does not log any values.
Acknowledgements
This project uses the following packages:
This project is published under the MIT Licence.
You don't owe me anything in return, but as an indie freelance coder there are two things I'd appreciate:
- Credit. If your app or documentation has a credits page, please consider mentioning the projects you use.
- Cash. If you want and are able to support future development, please consider becoming a patron or buying me a coffee. Thank you!