Documentation moved
We introduced Quickstarts as a new place for examples of how to use your favourite language and framework on Gitpod. Remember though, even if you can't find your use case as a quickstart, Gitpod very likely still supports your programming language as it's simply a Ubuntu-based operating system in the cloud. Visit the quickstarts
Go in Gitpod
Gitpod supports Go right out of the box, but there are still ways to optimize your Go experience within Gitpod.
Example Repositories
Here are a few Go example projects that are already automated with Gitpod:
Repository | Description | Try It |
---|---|---|
prometheus | The Prometheus monitoring system and time series database | |
go-swagger | A simple yet powerful representation of your RESTful API | |
go-gin-app | Gin example running in Gitpod | |
gosh-terminal | A terminal implemented in Go where you can do anything |
Workspace Configuration
VSCode Extensions
Name | Description |
---|---|
Go Test Explorer | Provides Test Explorer for Go which allows you to run your tests at the click of a button! |
To install Go Test Explorer for your repository, add the following to your .gitpod.yml
vscode:
extensions:
- premparihar.gotestexplorer@0.1.10:jvUM8akrQ67vQxfjaxCgCg==
Start-up tasks
Here is how to have your dependencies automatically fetched before you open your Gitpod workspace!
tasks:
- init: go get -v -t -d ./...
A full example of a .gitpod.yml file might look like this
image: gitpod/workspace-full
tasks:
- init: go get -v -t -d ./...
vscode:
extensions:
- premparihar.gotestexplorer@0.1.10:jvUM8akrQ67vQxfjaxCgCg==
Using the dep
dependency manager in Gitpod
If your project uses the dep
dependency manager then you need to add a .gitpod.Dockerfile to your project. A basic example that extends the default workspace image might be something like:
FROM gitpod/workspace-full
USER gitpod
RUN brew install dep
Also, don’t forget to reference the above Dockerfile in your .gitpod.yml
configuration file, like so:
image:
file: .gitpod.Dockerfile
tasks:
- init: dep ensure
vscode:
extensions:
- premparihar.gotestexplorer@0.1.10:jvUM8akrQ67vQxfjaxCgCg==
Debugging
Here is a quick clip on how to automatically configure debugging for Go!
So, basically in this video we:
- First, open the Go file that we want to debug
- Then, go to the debug menu and select “Add Configuration…”
- Next, in the dropdown choose “Go launch file”
- Finally, start debugging your Go program!
You can also create the Go debug configuration file manually
To start debugging your Go application in Gitpod, please create a new directory called .theia/
, and inside add a file called launch.json
, finally, add the following to it:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
"version": "0.2.0",
"configurations": [
{
"name": "Launch file",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${file}"
}
]
}
Then, simply open the Go file you want to debug, open the Debug panel (in the left vertical toolbar, click the icon with the crossed-out-spider), and click the green “Run” button.
To see a basic repository with Go debugging enabled, please check out gitpod-io/Gitpod-Go-Debug:
Further Reading
- VSCode/Go Documentation The stuff here also applies to Gitpod!
- VSCode/Go debugging VSCode’s Documentation on Go debugging
On this page