~havi/go-template

Template Repository for quickly bootstraping Go projects
chore: move to sourcehut
test(golangci-lint): fixed 'local-prefixes'
feat(cli/mitchellh): sample cli using `github.com/mitchellh/cli` library

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~havi/go-template
read/write
git@git.sr.ht:~havi/go-template

You can also use your local clone with git send-email.

#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