go-template

module
v0.0.0-...-94a580d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2022 License: MIT

README

go-template

Open in Gitpod

overview

The purpose of this template repository is to help with quickly bootstrapping a Golang project. It has the following features :

  • Sane Spacevim configuration
  • Virtualized Development Environment
    • Sane VSCode-remote-containers configuration and Alpine Backed Docker container with support for AMD64 and AARCH64 CPUs.
    • Vagrantfile Debian 10 based development environment configured to work with Virtualbox, Hyper-V, Libvirt and Google-Cloud providers.
    • Custom Gitpod Image that enables one to use the Gitpod as a backend for vsc-rs-url
  • Common revive and [golang-ci][golang-ci-url] Linter configuration
  • Makefile with targets for Semantic Versioning
  • Justfile targets for bootstrapping base dependencies, Semantic Versioning and development environment-related tasks.
  • pre-commit: configuration and some common hooks
  • Common dev tools, managed in tools.go
  • Github actions workflows for building docker images

setup

The virtualized environments have all the needed tools pre-provisioned. If you are using this repo to bootstrap projects out of the virtualized environments, you need to have the following installed.

  • OS: Linux
  • Go Toolchain >= 1.16.3
  • Rust Toolchain for building convco and just
  • Ripgrep
  • Python for installing `pre-commit.
  • Spacevim
  • NodeJs and Yarn for installing Spacevim Language Servers and some pre-commit hooks

I won't cover NodeJS, Python, Go-Toolchain, and Pre-commit setup in this document. I would explain how to install rust-based dependencies. ake sure to install Ripgrep through your favorite package manager

Rust ToolChain
  • install the stable toolchain and configure ~/.bashrc
curl \
  --proto '=https' \
  --tlsv1.2 -sSf \
  https://sh.rustup.rs \
  | sh -s -- \
    -y \
    --no-modify-path \
    --default-toolchain stable \
    --profile default  ;
if ! grep -q "cargo" ~/.bashrc; then
  echo '[ -r $HOME/.cargo/env ] && . $HOME/.cargo/env' >> ~/.bashrc ;
  source ~/.bashrc ;
fi
rustup default stable
Convco
  • make sure cmake is installed.
  • run cargo install convco
Just
  • run cargo install just
Bootstrap Repository Go Tools
  • ensure just is installed
  • run just bootstrap

docker images

all images come with a build script that would prefer to build the image with buildx command.

In case the buildx plugin is not available, then the script would fall back on the basic build command

prerequisites
  • update IMAGE_NAME variable in build scripts
build scripts
  • login to your container registry of choice
  • Docker image used with VScode remote-containers extension
bash contrib/docker/devcontainer/alpine/build.sh
  • Gitpod Docker Image
bash .gp/build.sh
Github Actions
  • add DOCKER_PASSWORD and DOCKER_USERNAME to your repository's secrets

Spacevim

  • I would encourage use neovim >= 0.5. Since the release is not available in most package managers, either install it from the Snap store's edge channel or build it from the source.
  • Spacevim needs Python and Nodejs
  • Spacevim has some font package dependencies. for instance, on Debian-based distributions, install xfonts-utils and fonts-symbola .
  • Install Spacevim
curl -sLf https://spacevim.org/install.sh | bash
  • install extra dependencies. Make sure yarn is installed before running the following command
just spacevim-dependencies
# or
just sd

git

  • the following target ensures pre-commit hooks are installed and it would run pre-commit hooks.
just pre-commit
# or
just pc
  • use the following target for commits. this target would run pre-commit target as a dependency.
just target
# or
just c
  • use the following target submitting a patch-release and generate release changelog.
just patch-release
# or
just pr
  • use the following target submitting a minor-release and generate release changelog.
just minor-release
# or
just mir
  • use the following target submitting a major-release and generate release changelog.
just major-release
# or
just mar

Directories

Path Synopsis
build
cmd
mitchellh/commands
Package command holds cli entrypoint functions
Package command holds cli entrypoint functions
mitchellh/commands/keygen
Package keygen creates a subcommand that can help with generating random strings.
Package keygen creates a subcommand that can help with generating random strings.
mitchellh/commands/version
Package version returns Reproducible and immutable build version information https://blog.macrium.com/reproducible-and-immutable-builds-can-improve-trust-in-the-software-supply-chain-after-the-17b9117c6e7b
Package version returns Reproducible and immutable build version information https://blog.macrium.com/reproducible-and-immutable-builds-can-improve-trust-in-the-software-supply-chain-after-the-17b9117c6e7b
internal
cli/data
Package data enables commands to painlessly read values from file or stdin
Package data enables commands to painlessly read values from file or stdin
cli/decoder
Package decoder has a collection of mapstructure hooks to help with decoding an interface into golang struct
Package decoder has a collection of mapstructure hooks to help with decoding an interface into golang struct
cli/flagset
Package flagset contains of core shared functions that every cli command needs for parsing flags
Package flagset contains of core shared functions that every cli command needs for parsing flags
logger
Package logger this package combines various logger libraries from `hashicorp` and adds some extra features, safety checks and optimizations.
Package logger this package combines various logger libraries from `hashicorp` and adds some extra features, safety checks and optimizations.
primitives
Package primitives is collection of utility functions to ease working with primitive types in go ─── ACKNOWLEDGEMENTS ─────────────────────────────────────────────────────────── github.com/hoempf/creader github.com/danilopolani/gosc github.com/mina86/unsafeConvert github.com/fmstephe/unsafeutil github.com/alecthomas/unsafeslice ────────────────────────────────────────────────────────────────────────────────
Package primitives is collection of utility functions to ease working with primitive types in go ─── ACKNOWLEDGEMENTS ─────────────────────────────────────────────────────────── github.com/hoempf/creader github.com/danilopolani/gosc github.com/mina86/unsafeConvert github.com/fmstephe/unsafeutil github.com/alecthomas/unsafeslice ────────────────────────────────────────────────────────────────────────────────
testutils
package testutils holds a collection of utility functions to help with testing go packages ─── ACKNOWLEDGEMENTS ───────────────────────────────────────────────────────────
package testutils holds a collection of utility functions to help with testing go packages ─── ACKNOWLEDGEMENTS ───────────────────────────────────────────────────────────

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL