GithubHelp home page GithubHelp logo

go-template's Introduction

Go template

Go template 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.

Scripts

build.sh

Script to build the binary and optionally build a docker image containing said binary.

Note: The script should have the variable bin= at the top modified to match the name of the projects binary, most often the directory name.

Usage

# To build binary.
./scripts/bash/build.sh --version <version>

# To build binary and docker image.
./scripts/bash/build.sh --version <version> --image

release.sh

Script to prepare a release. The script makes sure the current branch is the base branch (often main), pulls from remote, run tests and then finally creates a Git tag with the version number.

Usage

# Set a version (valid semver without the 'v' prefix).
./scripts/bash/release.sh --version <version>

# If there already is existing tagged versions, the following can be used.

# Patch increment (patch number according to semantic versioning).
./scripts/bash/release.sh --patch

# Minor increment (minor number according to semantic versioning).
./scripts/bash/release.sh --minor

# Major increment (minor number according to semantic versioning).
./scripts/bash/release.sh --major

go-install.sh

Script to install dependencies of a Go project when having dependencies in a private repository. When that is not the case, there is no need to make use of this script.

Usage

export PRIVATE_REPO_URL=<url-to-private-repository>
export PRIVATE_REPO_SSH_KEY_BASE64=<base64-of-private-key-to-repository>

./scripts/bash/go-install.sh

Dockerfiles

Two Dockerfiles are provided:

  • Dockerfile - Needs the binary pre-built and located in build/.
  • Dockerfile_build - Builds the binary during the image build.

Note: The Dockerfile(s) needs the following updated:

First step

  • ARG BIN needs to be updated ARG BIN=<binary-name> (if not provided during build).

Second step

  • ARG BIN needs to be updated ARG BIN=<binary-name> (if not provided during build).

  • ARG PORT needs to be updated to ARG PORT=<port-number> (if not provided during build).

  • ENTRYPOINT needs to be updated to ENTRYPOINT [ "/<binary-name>" ].

If ca-certificates is not needed by the project, the following lines can be deleted:

  • RUN apk update && apk add --no-cache ca-certificates && update-ca-certificates from the First step.
  • COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ from the Second step.

Workflows

test.yaml

Workflow to be called by other workflows, runs a job with the most common steps for testing a Go module.

build.yaml

Workflow that includes a call to the test.yaml workflow. A starter workflow that needs to be modified to suit the project.

go-template's People

Contributors

karlgw avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.