Go, also known as Golang, is an open-source programming language developed by Google. Golang is popular for its high performance, simple syntax, and strong support for building network-based applications, distributed systems, and microservices. In this article, we will cover the steps to set up a Golang development environment on Ubuntu, including mkcert + Caddy for local HTTPS reverse proxy with the domain myapp.local, Git integration for version control, and Visual Studio Code as the main editor.
1. Install Golang
Install Golang from the Ubuntu repository:
sudo apt install golang -yCheck the version:
go versionIf you want the latest version, download it from go.dev/dl, then extract it to /usr/local/go:
wget https://go.dev/dl/go1.25.0.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.25.0.linux-amd64.tar.gzAdd Go to your environment path:
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc
source ~/.bashrc2. Creating a Golang Program
Create a project directory:
mkdir -p ~/go/myapp
cd ~/go/myappCreate a main.go file:
package main
import (
"fmt"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Success! Golang application with local HTTPS is running")
}
func main() {
http.HandleFunc("/", handler)
fmt.Println("Server is running at http://localhost:8080")
fmt.Println("If Caddy is configured, access via https://myapp.local")
// Run server
err := http.ListenAndServe(":8080", nil)
if err != nil {
fmt.Println("Error while running server:", err)
}
}Run the application:
go run main.go3. Install Caddy
Install Caddy for reverse proxy:
sudo mkdir -p /usr/share/keyrings
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' \
| sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/caddy-stable-archive-keyring.gpg] \
https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main" \
| sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy -yInstall mkcert for local SSL:
sudo apt install libnss3-tools mkcert -yGenerate local certificates:
mkcert -install
mkcert myapp.local
sudo mv *.pem /etc/caddy
sudo chown caddy:caddy /etc/caddy/*.pemThe files myapp.local.pem and myapp.local-key.pem will be created.
4. Configure Local Domain
Edit /etc/hosts:
sudo nano /etc/hostsAdd:
127.0.0.1 myapp.localConfigure Caddyfile:
sudo nano /etc/caddy/CaddyfileInsert the configuration:
myapp.local {
reverse_proxy localhost:8080
tls /etc/caddy/myapp.local.pem /etc/caddy/myapp.local-key.pem
}Restart Caddy:
sudo systemctl restart caddyNow open https://myapp.local in your browser.
5. Install Git
Install Git for project version control:
sudo apt install git -y
git --versionConfigure identity:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"Initialize the repository in your project:
cd ~/go/myapp
git init
git add .
git commit -m "Initial Golang project setup"6. Install Visual Studio Code
Install VS Code:
wget 'https://code.visualstudio.com/sha/download?build=stable&os=linux-deb-x64' -O code.deb
sudo dpkg -i code.deb
sudo apt install -fTo improve productivity, install the following extensions (Ctrl+Shift+X → search → Install):
code --install-extension golang.go
code --install-extension eamodio.gitlensOr open Visual Studio Code and install:
- Go (by Go Team at Google)
- GitLens (for better Git integration)
Open the project in Visual Studio Code:
code ~/go/myappWith these steps, you now have a complete Golang development environment on Ubuntu:
- Go installed and able to run applications,
- mkcert + Caddy for local HTTPS with the domain
myapp.local, - Git for version control,
- Visual Studio Code for development with Go support.
This setup gives you a development workflow similar to production while remaining safe and local.




