Announcing go-james 1.6.0

May 28, 2020
golang | opensource | tool | automation | james

go-james v1.6.0

github.com/pieterclaerhout/go-james

James is your butler and helps you to create, build, debug, test and run your Go projects.

When you often create new apps using Go, it quickly becomes annoying when you realize all the steps it takes to configure the basics. You need to manually create the source files, version info requires more steps to be injected into the executable, using Visual Studio Code requires you to manually setup the tasks you want to run…

Using the go-james tool, you can automate and streamline this process. The tool will take care of initializing your project, running your project, debugging it, building it and running the tests.


In version 1.6.0, the followings things are changed/updated/fixed:

  • Added the option to build and publish your app as a Docker image
  • Added the option to create a GitHub action
  • Conditional create commands
  • Added support for installing go-james via Homebrew
  • Smaller bugfixes

You can find a list of fixed issues in the milestone.

Publish a Docker container

When you create a new project with docker files, it will also allow you to specify the repository to which the image should be pushed:

"docker-image": {
    "name": "go-james",
    "repository": "pieterclaerhout/go-james",
    "tag": "version",
    "prune_images_after_build": true
}

Additionally, you can specify a couple of extra settings:

  • tag: either release or version which indicates which of the two values should be used as the tag of the image.

  • prune_images_after_build: executes docker image prune -f after building the image.

GitHub Action

If you add the option --with-github-action, the following sample GitHub action file will be created under .github/workflows/build.yaml. It will test, run staticcheck and build the app storing the resulting assets.

name: Build and Publish

on: [push]

jobs:

  build-test-staticcheck:
    name: Build, Test and Check
    runs-on: ubuntu-latest
    steps:

    - name: Set up Go 1.14
      uses: actions/setup-go@v1
      with:
        go-version: 1.14
      id: go

    - name: Environment Variables
      uses: FranzDiebold/github-env-vars-action@v1.0.0

    - name: Check out code into the Go module directory
      uses: actions/checkout@v2
      with:
        lfs: true

    - name: Restore Cache
      uses: actions/cache@preview
      id: cache
      with:
        path: ~/go/pkg
        key: 1.14-${{ runner.os }}-${{ hashFiles('**/go.sum') }}

    - name: Get go-james
      run: |
        go get -u github.com/pieterclaerhout/go-james/cmd/go-james

    - name: Get dependencies
      run: |
        go get -v -t -d ./...

    - name: Build
      run: |
        export PATH=${PATH}:`go env GOPATH`/bin
        go-james build

    - name: Test
      run: |
        export PATH=${PATH}:`go env GOPATH`/bin
        go-james test

    - name: Staticcheck
      run: |
        export PATH=${PATH}:`go env GOPATH`/bin
        go-james staticcheck

    - name: Package
      run: |
        export PATH=${PATH}:`go env GOPATH`/bin
        go-james package

    - uses: actions/upload-artifact@v2
      name: Publish
      with:
        name: ${{ env.GITHUB_REPOSITORY_NAME }}-${{ env.GITHUB_SHA_SHORT }}-${{ env.GITHUB_REF_NAME }}.zip
        path: build/*.*

Conditional create commands

The option --create-git-repo has been renamed to --with-git which is easier to remember and less confusing. Two additional ones were added (both false by default):

  • --with-docker: creates the .dockerignore and Dockerfile files

  • --with-github-action: creates a sample .github/workflows/build.yaml file

Install via homebrew

To make the install easier, you can now install via homebrew:

First, install the correct tap.

$ brew tap pieterclaerhout/go-james
==> Tapping pieterclaerhout/go-james
Cloning into '/usr/local/Homebrew/Library/Taps/pieterclaerhout/homebrew-go-james'...
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 0), reused 4 (delta 0), pack-reused 0
Receiving objects: 100% (4/4), done.
Tapped 1 formula (27 files, 26.5KB).

Then, install (or update):

$ brew install go-james
==> Installing go-james from pieterclaerhout/go-james
==> Downloading https://github.com/pieterclaerhout/go-james/releases/download/v1.6.0/go-james_darwin_amd64.tar.gz
######################################################################## 100.0%
🍺  /usr/local/Cellar/go-james/1.6.0: 4 files, 11.5MB, built in 3 seconds

Download

You can download version 1.6.0 from here.