/go-template

Go template for new projects

Primary LanguageGo

Go template

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:

Getting started

To create a new project based on one of the templates:

  1. Install gonew (if it is not already installed):
go install golang.org/x/tools/cmd/gonew@latest
  1. 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>

Example

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).