Seed project for starting a dockerized, golang project. Features include:
- Command parsing with https://github.com/spf13/cobra
- Logging setup with https://github.com/inconshreveable/log15
- Configuration management with https://github.com/spf13/viper
- Dependency management and vendoring with https://github.com/Masterminds/glide
Feel free to fork this repo to start your own project. The rest of the README below assumes you are using this as a template and will fill in extra details.
If you want to duplicate without forking see: https://help.github.com/articles/duplicating-a-repository
For all projects, it will be MacOS, Windows, and Linux or N/A
Briefly describe inputs and expected outputs if needed
Memory / CPU if applicable
-
commands
- add commands to execute/start your code in this package. You should not have to modifymain.go
. Read more about the library being used here: https://github.com/spf13/cobra. -
config
- package for managing configuration. Currently setup for dev, qa, prod environments. Defaults to dev. To set the environment, make sure an environment variableENV
is set on your target system.
Configuration put inconfig-common.yml
is accessible in all environments. To get a value from configuration do something like this after importingconfig
package:myConfigurationValue := config.Viper.GetString("myConfigurationKey")
See https://github.com/spf13/viper for more usage information.
-
logger
- package to use for logging. Import this package and setup your own logger or use the root logger. e.g.// Root logger logger.Log.Info("This is using the root logger") // Child logger myPackageLogger := logger.Log.New("package", "myPackage", "someContextKey", "someContextValue") myPackageLogger.Info("This uses myPackageLogger which is a child of the root logger and shares root logger configuration.")
See https://github.com/inconshreveable/log15 for more usage information.
Install chcolatey if you have not already done so (https://chocolatey.org/)
choco install golang
https://golang.org/doc/install
- Install an IDE. Recommend Visual Studio Code
- Create a directory for your go projects, ex:
c:\source\go
Install go
extension in visual studio code.
- Open extensions window (cmd + shift + x)
- Type
go
- Install the one with author of lukehoban.
Assuming your workspace folder is c:\source\go
, setup environment variable GOPATH = c:\source\go
Create bin, pkg, src sub-folders in $GOPATH
.
Create $GOPATH\src\github.com\<your github username/organization>
folder.
In the $GOPATH\src\github.com\<your github username/organization>
folder, clone the repo. When finished you should have the folder: $GOPATH\src\github.com\<your github username/organization>\golang-seed
We use https://github.com/Masterminds/glide to manage package dependencies.
- Install glide and add it to your path. See https://github.com/Masterminds/glide#install
- Inside
golang-seed
directory runglide install --strip-vendor
. This downloads all package dependencies to avendor/
folder. - If you need to add more dependencies to the project at any point run
glide get <package name>
, which will add the package to theglide.yaml
. If you want to update dependencies to the latest version runglide up
, this will update theglide.lock
file with the latest dependencies.
Golang has testing built in.
To run tests for a single package run:
go test ./<package name>
To run all tests run:
// Run all tests but skip vendor directory
go test $(glide novendor)
TODO fill in your deployment pipeline info here
- From root directory of project run
go install
- To see what commands you can run:
golang-seed
- Generate mocks using counterfeiter
go get github.com/maxbrunsfeld/counterfeiter
From project folder or inside package folder
go generate
Read this article and follow the steps they outline: http://scottchacon.com/2011/08/31/github-flow.html
All PRs should be signed off by a member of the team before merging.
- List
- Your
- Team
- Members
February 2016