go/template is a tool for jumpstarting production-ready Golang projects quickly.

go/template

SIT CI Semgrep

go/template provides a blueprint for production-ready Go project layouts.

go/template logo

Credit to Renée French for the Go Gopher logo
Credit to Go Authors for the official Go logo

Batteries included

  • Makefile for most common tasks
  • optimized Dockerfile
  • golangci-lint default configuration
  • pre-push git hook to ensure no linting issues
  • gRPC support
  • folder structure based on github.com/golang-standards/project-layout
  • enforced default packages
    • go.uber.org/zap for logging
    • go.uber.org/automaxprocs to be safe in container environments (see this article for more information)

Usage

Install

go install github.com/schwarzit/go-template/cmd/gt@latest

Initialize your repo from the template

asciicast

Use the template to generate your repo:

gt new

Initialize the project:

cd <your project>
make all

Options

To get an overview of all options that can be set for the template you can take a look at the options definition file, run the CLI or check out the testing example values file.

Maintainers

Name Email
@brumhard [email protected]
@linuxluigi [email protected]
@danielzwink [email protected]

Contribution

If you want to contribute to go/template please have a look at our contribution guidelines.

Comments
  • feat: add goreleaser for gt cli

    feat: add goreleaser for gt cli

    Signed-off-by: Engin Diri [email protected]

    fixes #45

    As discussed in https://github.com/SchwarzIT/go-template/discussions/43 the PR for gt itself.

  • golangci is broken from the makefile

    golangci is broken from the makefile

    Since yesterday the golangci installation from the Makefile is broken.

    $ curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b bin v1.42.1
    > golangci/golangci-lint info checking GitHub for tag 'v1.42.1'
    > golangci/golangci-lint info found version: 1.42.1 for v1.42.1/linux/amd64
    > golangci/golangci-lint info installed bin/golangci-lint
    > golangci/golangci-lint err this script is deprecated, please do not use it anymore. check https://github.com/goreleaser/godownloader/issues/207
    > go mod download
    > bin/golangci-lint run
    > level=error msg="Running error: context loading failed: no go files to analyze"
    

    There a several other ways to install golangci → https://golangci-lint.run/usage/install/ Which version do we want to use?

  • Dotfiles and directories that only contain dotfiles are not included in the resulting directory

    Dotfiles and directories that only contain dotfiles are not included in the resulting directory

    Due to golang/go#43854 the go:embed directive does not include dotfiles and empty directories (or dirs that only contain dotfiles such as .gitkeep). Because of this the created project directory when running gt new does not contain the all those files.

  • Set ZAP loglevel via environment var

    Set ZAP loglevel via environment var

    Is your feature request related to a problem? Please describe.

    It's useful for 12factor apps.

    Describe the solution you'd like

    Set Zap logging level through an environment var. Example for debug: LOG_LEVEL=debug

    Describe alternatives you've considered

    ...

    Search

    • [X] I did search for other open and closed issues before opening this.

    Code of Conduct

    • [X] I agree to follow this project's Code of Conduct

    Additional context

    No response

  • `grpc.base=false` does not delete grpc files if `opensource.license=9`

    `grpc.base=false` does not delete grpc files if `opensource.license=9`

    When running gt new and using the defaults and setting grpc.base to false the files are deleted properly. When doing the same but setting opensource.license to 9 (no license) the files are still present after generating.

  • feat(template): use projectSlug as default for appName

    feat(template): use projectSlug as default for appName

    Working with the template, I encountered the following:

    linting the repository that just was created, the linter errors due to not handling the error from the logger.Sync() call.

    Error return value of `logger.Sync` is not checked (errcheck)
            defer logger.Sync()
                             ^
    

    In addition I think it is more convenient to start with a cmd/{{.projectName}} instead of cmd/awesomecli if nothing else is specified.

  • Add license in Template

    Add license in Template

    Add LICENSE & CODEOWNERS files in template.

    But I'm not sure what to do, if there should no OpenSource license will be selected. Add in post hook to delete the LICENSE file or let it be empty?

  • Remove go matrix from CI

    Remove go matrix from CI

    Is your feature request related to a problem? Please describe.

    Testing multiple go versions is not required for the tests. It creates manual effort at times since required checks from old PRs are outdated after go version updates.

    Describe the solution you'd like

    Just test one go version.

    Describe alternatives you've considered

    Search

    • [X] I did search for other open and closed issues before opening this.

    Code of Conduct

    • [X] I agree to follow this project's Code of Conduct

    Additional context

    No response

  • refactor: replace fatih/color with muesli/termenv

    refactor: replace fatih/color with muesli/termenv

    This is a PR to replace the package used for coloring console output. This is needed in an effort to tackle #166 since fatih/color does not support to force colored output. With termenv you can set an env var to force the colors even if the output tty is not a terminal.

  • feat: add flake.nix file to consume gt via nix

    feat: add flake.nix file to consume gt via nix

    This PR adds a flake.nix file which is used to install go-template within the nix ecosystem. In the future this could also be used to provide dev environments for developers.

  •  feat(template): replace openapiv2 generator with gnostic

    feat(template): replace openapiv2 generator with gnostic

    This PR replaces the current openapiv2 generator for the oas with openapi from gnostic. The annotations for v3 were imported in the template proto file, instead of the v2 ones.

  • Replace Makefile with earthly

    Replace Makefile with earthly

    Is your feature request related to a problem? Please describe.

    Makefiles are fast hard to read & to maintain. It would be nice to have a more elgant alternative like earthly.

    Describe the solution you'd like

    Replace current Makefile with an Earthly file. Earthly could also be split up into multiple files & folders. So this could also help to make go-template fit for more options, since not everything needs to be going into one file. Also with earthly, supporting multiple CI provider would be much easier.

    Describe alternatives you've considered

    Keep the Makefile 😁

    Search

    • [X] I did search for other open and closed issues before opening this.

    Code of Conduct

    • [X] I agree to follow this project's Code of Conduct

    Additional context

    No response

Template project to get started with a simple API skeleton in Go and Docker

A template project to create a Docker image for a Go application. The example application exposes an HTTP endpoint through a REST API packaged as a static binary.

Apr 4, 2022
A Go dependency graph visualization tool
A Go dependency graph visualization tool

godepgraph godepgraph is a program for generating a dependency graph of Go packages. Install go get github.com/kisielk/godepgraph Use For basic usage

Jan 7, 2023
cmd tool for automatic storage and comparison of benchmarks results

prettybenchcmp prettybenchcmp is cmd tool for storage and comparison of benchmarks results. There is a standard tool benchcmp, but I don't think that

Apr 6, 2021
A tool that helps you write code in your favorite IDE: your word processor!
A tool that helps you write code in your favorite IDE: your word processor!

WordIDE Have you ever wondered: How would it feel like to write code in a word processor? Me neither. But after months minutes of planning, I present

Jul 21, 2022
A tool to lint Grafana dashboards

Grafana Dashboard Linter This is a tool to lint Grafana dashboards for common mistakes. To use: $ go install github.com/grafana/dashboard-linter $ das

Dec 27, 2022
Drive performance measurement tool

dperf is a drive performance measurement tool to identify slow drives in your host. It takes multiple file paths as input, and performs I/O parallely on those files. The read and write throughput are printed in sorted order, with the fastest drives shown first.

Nov 23, 2022
A TinySQL deployment tool inspired by TiUP

A TinySQL deployment tool inspired by TiUP

Jan 26, 2022
Simple tool that updates Visual Studio Code workspace(s) to include Go modules in gopath/src, then launches VSCode if only one modified.

Simple tool that updates Visual Studio Code workspace(s) to include Go modules in gopath/src, then launches VSCode if only one modified.

Jan 27, 2022
ide-gen is a tool for development workspace prepare automation by automatic VCS repositories discovery and clone and project generation for supported IDEs.

ide-gen is a tool for development workspace prepare automation by automatic VCS repositories discovery and clone and project generation for supported IDEs.

May 8, 2022
A small tool that allows a process to ask a debugger to attach to it.

Client and server for a process to request attach by gdlv. These two packages allow a program to request that a debugger attach to it. The motivating

Feb 1, 2022
golang feature toggle library - a library to help make golang feature toggling clean and easy

toggle supports env_variable backed toggling. It can also be updated via a pubsub interface (tested w/ redis) 2 engines for toggle backing are include

Mar 29, 2022
go-watcher 是一款实现 Golang 源码热重启的工具

go-watcher 是一款实现 Golang 源码热重启的工具,可替换 go run 命令执行任意 main 入口程序,包括参数

Jan 7, 2022
GRONG is a DNS (Domain Name System) authoritative name server.It is more a research project than a production-ready program.

GRONG (Gross and ROugh Nameserver written in Go) is a DNS (Domain Name System) authoritative name server. It is intended as a research project and is

Oct 17, 2020
Bramble is a production-ready GraphQL federation gateway.
Bramble is a production-ready GraphQL federation gateway.

Bramble is a production-ready GraphQL federation gateway. It is built to be a simple, reliable and scalable way to aggregate GraphQL services together.

Jan 3, 2023
An production-ready microservice using Go and a few lightweight libraries
An production-ready microservice using Go and a few lightweight libraries

Go Micro Example This small sample project was created as a collection of the various things I've learned about best practices building microservices

Dec 26, 2022
Create production ready microservices mono repo pattern wired with Neo4j. Microservices for other languages and front end repos to be added as well in future.
Create production ready microservices mono repo pattern wired with Neo4j. Microservices for other languages and front end repos to be added as well in future.

Create Microservices MonoRepo in GO/Python Create a new production-ready project with backend (Golang), (Python) by running one CLI command. Focus on

Oct 26, 2022
✨ Create a new production-ready project with backend, frontend and deploy automation by running one CLI command!
✨ Create a new production-ready project with backend, frontend and deploy automation by running one CLI command!

✨ Create a new production-ready project with backend, frontend and deploy automation by running one CLI command!

Dec 31, 2022
sample-go-test-app-vaibhav is a simple example of a production ready RPC service in Go

sample-go-test-app-vaibhav sample-go-test-app-vaibhav is a simple example of a production ready RPC service in Go. Instead of attempting to abstract a

Dec 2, 2021
Production Ready GO - Development Workspace

dev_ProdGO Production Ready GO - Development Workspace Install and Check Version MacOS $brew install go/golang $go version $mkdir -p $HOME/go/{bin,sr

Jan 6, 2022
Template Repository for quickly bootstraping Go projects

go-template go-template overview setup Rust ToolChain Convco Just Bootstrap Repository Go Tools docker images prerequisites build scripts Github Actio

Feb 6, 2022