- Configure Your Project
- .gitpod.yml
- Docker Configuration
- Start Tasks
- VS Code Extensions
- Exposing Ports
- Prebuilt Workspaces
- Environment Variables
- Workspace Location
- Editor Configuration
- Gitpod Self-Hosted
- Install on Google Cloud Platform
- Install on Amazon Web Services
- Install on self-managed Kubernetes
- Configure OAuth
- Configure a Domain
- Configure HTTPS Certificates
- Configure a Database
- Configure a Docker Registry
- Configure Storage
- Configure Nodes
- Configure Workspaces
Docs
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 |
---|---|---|
go-swagger/go-swagger | A simple yet powerful representation of your RESTful API | |
gitpod-io/go-gin-app | Gin example running in Gitpod | |
gosh-terminal/gosh | A terminal implemented in Go where you can do anything | |
gitpod-io/self-hosted | Self-Host your Gitpod |
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
Still Have Questions?
Please reach out. We’re happy to answer them.