How to Build a Remote Go Development Environment with VS Code
This guide walks through configuring a remote Linux machine for Go development using VS Code’s Remote‑SSH extension, covering SSH key setup, host configuration, Go installation, VS Code extensions, and additional system tweaks to create a fast, resource‑rich development environment.
Background
A Make syntax incompatibility on macOS prevented successful compilation of a Go program. To avoid this, a remote Linux development environment accessed via VS Code was set up using an old university notebook reinstalled with Ubuntu.
Comparison of Local vs Remote Environments
Local
Fast program start and environment loading.
Not limited by network or geographic constraints.
Bound to the local machine; some software runs poorly on macOS.
Limited memory and CPU resources.
Remote
Access to larger memory, CPU, and disk resources.
Isolates development from the Mac by using Linux.
Usable only within a private home network.
Initialization can be slower due to network latency.
Basic Setup
Remote Linux machine (Ubuntu or CentOS) with SSH port 22 open.
VS Code installed on the local workstation.
Remote Environment Configuration
Install the Remote - SSH extension in VS Code via the Extensions marketplace.
Generate an SSH key pair:
# Generate key pair
$ ssh-keygen -f id_rsa_goland_developer_comCopy the public key to the remote machine and append it to ~/.ssh/authorized_keys:
# Upload public key
$ cat id_rsa_goland_developer_com.pub > ~/.ssh/authorized_keysAdd a host entry in the VS Code Remote‑SSH configuration file:
Host GoDev
User {user}
HostName {ip}
IdentityFile ~/.ssh/id_rsa_goland_developer_com GoDevis an arbitrary label. {user} is a non‑root user created with useradd. {ip} is the remote machine’s IP address. IdentityFile points to the private key for password‑less login.
Use VS Code to connect to the remote host and select the desired workspace directory.
Go Environment Installation
Download the Go binary package:
$ wget -c https://dl.google.com/go/go1.19.linux-amd64.tar.gzExtract and install to /usr/local and add the binary directory to PATH:
$ sudo tar -C /usr/local -xzf go1.19.linux-amd64.tar.gz
$ sudo vim /etc/profile # add: export PATH=$PATH:/usr/local/go/bin
$ source /etc/profileConfigure Go environment variables:
$ go env -w GO111MODULE=on
$ go env -w GOPROXY=https://goproxy.cnVS Code Go Extension Configuration
Within the remote VS Code session, install the official Go extension.
Install additional Go‑related extensions as needed.
Press Ctrl+Shift+P and run “Go: Install/Update Tools” to install all required tools. The latest version lists seven tools; earlier versions listed ten‑plus because utilities such as golint and goimports have been integrated into staticcheck.
Install the Code Runner extension (search keyword “code”) to enable Ctrl+Alt+N for quick code execution.
Additional System Settings
To allow the notebook (used as the remote host) to keep the lid closed without suspending, edit /etc/systemd/logind.conf and set:
# Edit /etc/systemd/logind.conf
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
# Restart the service
$ sudo service systemd-logind restartFuture Plans
The current notebook is limited by memory, disk size, CPU performance, and lacks a GPU. The setup is intended to evolve toward a low‑power home server, with reference links:
https://www.reddit.com/r/homelab/comments/rlouof/trying_to_build_a_small_low_power_server/
https://kit.co/TechnoTim/efficient-low-power-powerful-virtualization-server
https://www.proxmox.com/en/
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Infra Learning Club
Infra Learning Club shares study notes, cutting-edge technology, and career discussions.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
