Checkout and Workspace Location

Older Go projects without module support need a specific workspace layout: the source code of your repository and its dependencies must be in the directories


in the $GOPATH. Using the .gitpod.yml file, you can bring about such a workspace layout. Here is how we do that for the example go-gin-app repository:

checkoutLocation: "src/"
workspaceLocation: "."
  - init: >
      cd /workspace/src/ &&
      go get -v ./... &&
      go build -o app
    command: >
      cd /workspace/src/ &&

In more detail:

  • By default, Gitpod clones the repository into the directory /workspace, which becomes the root directory for the workspace. With checkoutLocation and workspaceLocation you can change this behavior (the paths are taken relative to /workspace).
  • Gitpod preconfigures the $GOPATH environment variable to include the directory /workspace/go.
  • With go get -v ./... we retrieve the sources of the dependencies from GitHub.
  • To build the app, we run go build -o app.
  • Lastly, we start the application.

Was this helpful?