Go templates for new projects
This repository is a template to make use of when creating new projects in Go. It contains scripts, Dockerfile(s) and workflows.
Four templates are provided:
- base - Base project.
- http-server - Basic HTTP server project.
- server - General server project.
- service - General service project.
To create a new project based on one of the templates:
- Install
gonew
(if it is not already installed):
go install golang.org/x/tools/cmd/gonew@latest
- Download the template and create the new project:
# Assuming the project will be hosted in GitHub.
# If not replace github.com/<owner>/<repo> with the correct path.
gonew github.com/RedeployAB/go-template/templates/<name> github.com/<owner>/<repo>
To create a new project based on the http-server template
to a GitHub repository with the user/organization name YourUser
and the project/module name myproject
gonew github.com/RedeployAB/go-template/templates/http-server github.com/YourUser/myproject
This will download the module, it's assets and rewrite the module name and import paths to match the new module name (project).