Whenever I need to setup new Golang project I find myself copy/pasting from previous one. To save some time for myself
I've created this project
cli app.
This cli app has one command setup
which takes 3 arguments:
destDir
specifies where new project should be createdtemplateRepo
is git repository which hosts project templateconfigFile
has all variable values that should be applied on template
Once you run it:
project setup --destDir=$GOPATH/src/github.com/nildev/my-new-app --configFile=./newapp.config.json --templateRepo="[email protected]:nildev/prj-tpl-cli-app.git"
project
will clone templateRepo
in destDir
will remove .git
dir and will start iterating over the files and directories
searching for {{.Variable}}'s and replacing them with values from configFile
.
Make sure git
is installed and required private keys are added to ssh agent. To add private key:
# If your private key is located at ~/.ssh/id_rsa
ssh-add ~/.ssh/id_rsa
Download binary from here or go get
:
go get github.com/nildev/project
Using Golang template syntax prepare your project template, for example take a look at this one. Or use one of already prepared templates.
Then create project.json
file locally with values for each variable that is defined in config file. Every project template
in root directory will contain project.sample.json
with all available variables.
For example like this one:
{
"GitRepoFullPath": "https://github.com/your_org/your_project_name",
"DocsGitRepoFullPath": "https://github.com/your_org/docs",
"OrgPath":"github.com/your_org",
"BinaryName" : "your_project_binary_name",
"ProjectName" : "your_project_name",
"BinaryDescription" : "Some description of your app",
"Org": "your_org"
}
- replace $PATH_TO_NEW_PROJECT with path to directory where newly generated project should be created
- replace $PATH_TO_CONFIG_JSON with path to json file you have created locally
- replace $PATH_TO_TEMPLATE_REPO to project template git repository for example
[email protected]:nildev/prj-tpl-cli-app.git
Run:
project setup --destDir=$GOPATH/src/github.com/nildev/newapp --configFile=./newapp.config.json --templateRepo="[email protected]:nildev/prj-tpl-cli-app.git"
If template is in private repository make sure that required ssh key is added to ssh agent.
Here is a list of available templates. If you have created one please do a pull request with link to that repository:
- https://github.com/nildev/prj-tpl-cli-app (
[email protected]:nildev/prj-tpl-cli-app.git
)
- Get repo
go get github.com/nildev/project
- Restore deps
godep restore
- Run
build
./build
See the releases tab for more information on each release.
See CONTRIBUTING for details on submitting patches and contacting developers via IRC and mailing lists.
project is released under the Apache 2.0 license. See the LICENSE file for details.
Specific components of project use code derivative from software distributed under other licenses; in those cases the appropriate licenses are stipulated alongside the code.