Skip to content

A simple password generator written in Go that showcases a scalable and testable project structure built on top of Cobra library.

License

Notifications You must be signed in to change notification settings

Antolius/passgen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Passgen

About

Passgen is a command line app written in Go using the Cobra library. This project showcases a code structure that makes it easy to testing all the business logic of the CLI app.

The app itself is a simple password generator inspired by an XKCD comic:

Password Strength XKCD comic

Motivation

I'm a big fan of the Cobra library. However, I find it hard to test my code that depends on Cobra directly and Cobra Generator scaffolding tool produces a bit ugly code. In this demo project I tried to overcome those issues by organizing my code with a little bit of forethought.

Built with

Getting started

I suggest you to clone the project locally and explore the code yourself. My idea was to keep the domain logic as simple as possible, while still demonstrating how to achieve good test coverage.

Prerequisites

You'll need to have Go installed locally in order to test or build passgen.

Testing

To run tests execute:

$ go test ./...

in the project's root directory.

Installation

To build the app execute:

$  go build ./cmd/passgen/

in the project's root directory. This will generate the executable passgen file that you can run.

Usage

Passgen app is not really intended for widespread usage, but you can still play around with it. Underlying Cobra library provides CLI related features, like a sub-command structure, help flag, file config etc.

The actual sub-command for generating passwords is generate. You can run it with:

$ ./passgen generate
richswordmeadowmanage

Or, for more features, like this:

./passgen generate -csm 24
Agree Melt Light Honey Window!

License

Distributed under the MIT License. See LICENSE.txt for more information.

Authors

About

A simple password generator written in Go that showcases a scalable and testable project structure built on top of Cobra library.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages