@fredlackey/devutils 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/package.json +1 -1
- package/src/commands/install.js +374 -36
- package/src/installs/adobe-creative-cloud.js +527 -25
- package/src/installs/adobe-creative-cloud.md +605 -0
- package/src/installs/appcleaner.js +303 -26
- package/src/installs/appcleaner.md +699 -0
- package/src/installs/apt-transport-https.js +390 -0
- package/src/installs/apt-transport-https.md +678 -0
- package/src/installs/atomicparsley.js +624 -26
- package/src/installs/atomicparsley.md +795 -0
- package/src/installs/aws-cli.js +779 -26
- package/src/installs/aws-cli.md +727 -0
- package/src/installs/balena-etcher.js +688 -26
- package/src/installs/balena-etcher.md +761 -0
- package/src/installs/bambu-studio.js +912 -26
- package/src/installs/bambu-studio.md +780 -0
- package/src/installs/bash-completion.js +554 -23
- package/src/installs/bash-completion.md +833 -0
- package/src/installs/bash.js +399 -26
- package/src/installs/bash.md +993 -0
- package/src/installs/beyond-compare.js +585 -26
- package/src/installs/beyond-compare.md +813 -0
- package/src/installs/build-essential.js +511 -26
- package/src/installs/build-essential.md +977 -0
- package/src/installs/ca-certificates.js +618 -0
- package/src/installs/ca-certificates.md +937 -0
- package/src/installs/caffeine.js +490 -26
- package/src/installs/caffeine.md +839 -0
- package/src/installs/camtasia.js +577 -25
- package/src/installs/camtasia.md +762 -0
- package/src/installs/chatgpt.js +458 -26
- package/src/installs/chatgpt.md +814 -0
- package/src/installs/chocolatey.js +447 -0
- package/src/installs/chocolatey.md +661 -0
- package/src/installs/chrome-canary.js +472 -26
- package/src/installs/chrome-canary.md +641 -0
- package/src/installs/chromium.js +645 -26
- package/src/installs/chromium.md +838 -0
- package/src/installs/claude-code.js +558 -26
- package/src/installs/claude-code.md +1173 -0
- package/src/installs/curl.js +361 -26
- package/src/installs/curl.md +714 -0
- package/src/installs/cursor.js +561 -26
- package/src/installs/cursor.md +970 -0
- package/src/installs/dbschema.js +674 -26
- package/src/installs/dbschema.md +925 -0
- package/src/installs/dependencies.md +435 -0
- package/src/installs/development-tools.js +600 -0
- package/src/installs/development-tools.md +977 -0
- package/src/installs/docker.js +1010 -25
- package/src/installs/docker.md +1109 -0
- package/src/installs/drawio.js +1001 -26
- package/src/installs/drawio.md +795 -0
- package/src/installs/elmedia-player.js +328 -25
- package/src/installs/elmedia-player.md +556 -0
- package/src/installs/ffmpeg.js +870 -25
- package/src/installs/ffmpeg.md +852 -0
- package/src/installs/file.js +464 -0
- package/src/installs/file.md +987 -0
- package/src/installs/gemini-cli.js +793 -26
- package/src/installs/gemini-cli.md +1153 -0
- package/src/installs/git.js +382 -26
- package/src/installs/git.md +907 -0
- package/src/installs/gitego.js +931 -26
- package/src/installs/gitego.md +1172 -0
- package/src/installs/go.js +913 -26
- package/src/installs/go.md +958 -0
- package/src/installs/google-chrome.js +801 -25
- package/src/installs/google-chrome.md +862 -0
- package/src/installs/gpg.js +412 -73
- package/src/installs/gpg.md +1056 -0
- package/src/installs/homebrew.js +1015 -26
- package/src/installs/homebrew.md +988 -0
- package/src/installs/imageoptim.js +950 -26
- package/src/installs/imageoptim.md +1119 -0
- package/src/installs/installers.json +2297 -0
- package/src/installs/jq.js +382 -26
- package/src/installs/jq.md +809 -0
- package/src/installs/keyboard-maestro.js +701 -26
- package/src/installs/keyboard-maestro.md +825 -0
- package/src/installs/latex.js +771 -26
- package/src/installs/latex.md +1095 -0
- package/src/installs/lftp.js +338 -26
- package/src/installs/lftp.md +907 -0
- package/src/installs/lsb-release.js +346 -0
- package/src/installs/lsb-release.md +814 -0
- package/src/installs/messenger.js +829 -26
- package/src/installs/messenger.md +900 -0
- package/src/installs/microsoft-office.js +550 -26
- package/src/installs/microsoft-office.md +760 -0
- package/src/installs/microsoft-teams.js +782 -25
- package/src/installs/microsoft-teams.md +886 -0
- package/src/installs/node.js +886 -26
- package/src/installs/node.md +1153 -0
- package/src/installs/nordpass.js +698 -26
- package/src/installs/nordpass.md +921 -0
- package/src/installs/nvm.js +977 -26
- package/src/installs/nvm.md +1057 -0
- package/src/installs/openssh.js +734 -64
- package/src/installs/openssh.md +1056 -0
- package/src/installs/pandoc.js +644 -26
- package/src/installs/pandoc.md +1036 -0
- package/src/installs/pinentry.js +492 -26
- package/src/installs/pinentry.md +1142 -0
- package/src/installs/pngyu.js +851 -26
- package/src/installs/pngyu.md +896 -0
- package/src/installs/postman.js +781 -26
- package/src/installs/postman.md +940 -0
- package/src/installs/procps.js +425 -0
- package/src/installs/procps.md +851 -0
- package/src/installs/safari-tech-preview.js +355 -25
- package/src/installs/safari-tech-preview.md +533 -0
- package/src/installs/sfnt2woff.js +640 -26
- package/src/installs/sfnt2woff.md +795 -0
- package/src/installs/shellcheck.js +463 -26
- package/src/installs/shellcheck.md +1005 -0
- package/src/installs/slack.js +722 -25
- package/src/installs/slack.md +865 -0
- package/src/installs/snagit.js +566 -25
- package/src/installs/snagit.md +844 -0
- package/src/installs/software-properties-common.js +372 -0
- package/src/installs/software-properties-common.md +805 -0
- package/src/installs/spotify.js +858 -25
- package/src/installs/spotify.md +901 -0
- package/src/installs/studio-3t.js +803 -26
- package/src/installs/studio-3t.md +918 -0
- package/src/installs/sublime-text.js +780 -25
- package/src/installs/sublime-text.md +914 -0
- package/src/installs/superwhisper.js +687 -25
- package/src/installs/superwhisper.md +630 -0
- package/src/installs/tailscale.js +727 -26
- package/src/installs/tailscale.md +1100 -0
- package/src/installs/tar.js +389 -0
- package/src/installs/tar.md +946 -0
- package/src/installs/termius.js +780 -26
- package/src/installs/termius.md +844 -0
- package/src/installs/terraform.js +761 -26
- package/src/installs/terraform.md +899 -0
- package/src/installs/tidal.js +752 -25
- package/src/installs/tidal.md +864 -0
- package/src/installs/tmux.js +328 -26
- package/src/installs/tmux.md +1030 -0
- package/src/installs/tree.js +393 -26
- package/src/installs/tree.md +833 -0
- package/src/installs/unzip.js +460 -0
- package/src/installs/unzip.md +879 -0
- package/src/installs/vim.js +403 -26
- package/src/installs/vim.md +1040 -0
- package/src/installs/vlc.js +803 -26
- package/src/installs/vlc.md +927 -0
- package/src/installs/vscode.js +825 -26
- package/src/installs/vscode.md +1002 -0
- package/src/installs/wget.js +415 -0
- package/src/installs/wget.md +791 -0
- package/src/installs/whatsapp.js +710 -25
- package/src/installs/whatsapp.md +854 -0
- package/src/installs/winpty.js +352 -0
- package/src/installs/winpty.md +620 -0
- package/src/installs/woff2.js +535 -26
- package/src/installs/woff2.md +977 -0
- package/src/installs/wsl.js +572 -0
- package/src/installs/wsl.md +699 -0
- package/src/installs/xcode-clt.js +520 -0
- package/src/installs/xcode-clt.md +351 -0
- package/src/installs/xcode.js +542 -26
- package/src/installs/xcode.md +573 -0
- package/src/installs/yarn.js +806 -26
- package/src/installs/yarn.md +1074 -0
- package/src/installs/yq.js +636 -26
- package/src/installs/yq.md +944 -0
- package/src/installs/yt-dlp.js +683 -26
- package/src/installs/yt-dlp.md +946 -0
- package/src/installs/yum-utils.js +297 -0
- package/src/installs/yum-utils.md +648 -0
- package/src/installs/zoom.js +740 -25
- package/src/installs/zoom.md +884 -0
- package/src/scripts/README.md +567 -45
- package/src/scripts/STATUS.md +208 -0
- package/src/scripts/afk.js +395 -7
- package/src/scripts/backup-all.js +731 -9
- package/src/scripts/backup-source.js +711 -8
- package/src/scripts/brewd.js +373 -7
- package/src/scripts/brewi.js +505 -9
- package/src/scripts/brewr.js +512 -9
- package/src/scripts/brews.js +462 -9
- package/src/scripts/brewu.js +488 -7
- package/src/scripts/c.js +185 -7
- package/src/scripts/ccurl.js +325 -8
- package/src/scripts/certbot-crontab-init.js +488 -8
- package/src/scripts/certbot-init.js +641 -9
- package/src/scripts/ch.js +339 -7
- package/src/scripts/claude-danger.js +253 -8
- package/src/scripts/clean-dev.js +419 -8
- package/src/scripts/clear-dns-cache.js +525 -7
- package/src/scripts/clone.js +417 -7
- package/src/scripts/code-all.js +420 -7
- package/src/scripts/count-files.js +195 -8
- package/src/scripts/count-folders.js +195 -8
- package/src/scripts/count.js +248 -8
- package/src/scripts/d.js +203 -7
- package/src/scripts/datauri.js +373 -8
- package/src/scripts/delete-files.js +363 -7
- package/src/scripts/docker-clean.js +410 -8
- package/src/scripts/dp.js +426 -7
- package/src/scripts/e.js +375 -9
- package/src/scripts/empty-trash.js +497 -7
- package/src/scripts/evm.js +428 -9
- package/src/scripts/fetch-github-repos.js +441 -10
- package/src/scripts/get-channel.js +329 -8
- package/src/scripts/get-course.js +384 -11
- package/src/scripts/get-dependencies.js +290 -9
- package/src/scripts/get-folder.js +783 -10
- package/src/scripts/get-tunes.js +411 -10
- package/src/scripts/get-video.js +352 -9
- package/src/scripts/git-backup.js +561 -9
- package/src/scripts/git-clone.js +477 -9
- package/src/scripts/git-pup.js +303 -7
- package/src/scripts/git-push.js +380 -8
- package/src/scripts/h.js +607 -9
- package/src/scripts/hide-desktop-icons.js +483 -7
- package/src/scripts/hide-hidden-files.js +522 -7
- package/src/scripts/install-dependencies-from.js +440 -9
- package/src/scripts/ips.js +647 -10
- package/src/scripts/iso.js +354 -8
- package/src/scripts/killni.js +561 -7
- package/src/scripts/ll.js +451 -8
- package/src/scripts/local-ip.js +310 -8
- package/src/scripts/m.js +508 -8
- package/src/scripts/map.js +293 -8
- package/src/scripts/mkd.js +287 -7
- package/src/scripts/ncu-update-all.js +441 -8
- package/src/scripts/nginx-init.js +702 -12
- package/src/scripts/npmi.js +366 -7
- package/src/scripts/o.js +495 -8
- package/src/scripts/org-by-date.js +321 -7
- package/src/scripts/p.js +208 -7
- package/src/scripts/packages.js +313 -8
- package/src/scripts/path.js +209 -7
- package/src/scripts/ports.js +582 -8
- package/src/scripts/q.js +290 -8
- package/src/scripts/refresh-files.js +378 -10
- package/src/scripts/remove-smaller-files.js +500 -8
- package/src/scripts/rename-files-with-date.js +517 -9
- package/src/scripts/resize-image.js +523 -9
- package/src/scripts/rm-safe.js +653 -8
- package/src/scripts/s.js +525 -9
- package/src/scripts/set-git-public.js +349 -7
- package/src/scripts/show-desktop-icons.js +459 -7
- package/src/scripts/show-hidden-files.js +456 -7
- package/src/scripts/tpa.js +265 -8
- package/src/scripts/tpo.js +264 -7
- package/src/scripts/u.js +489 -7
- package/src/scripts/vpush.js +422 -8
- package/src/scripts/y.js +267 -7
- package/src/utils/common/os.js +94 -2
- package/src/utils/ubuntu/apt.js +13 -7
- package/src/utils/windows/choco.js +82 -26
- package/src/utils/windows/winget.js +89 -27
|
@@ -0,0 +1,958 @@
|
|
|
1
|
+
# Installing Go
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Go (also known as Golang) is an open-source programming language developed by Google that makes it simple to build secure, scalable systems. Go is statically typed, compiled, and designed for simplicity and reliability. It features built-in concurrency primitives, garbage collection, and a robust standard library, making it ideal for building web servers, cloud services, command-line tools, and distributed systems.
|
|
6
|
+
|
|
7
|
+
Go was created by Robert Griesemer, Rob Pike, and Ken Thompson at Google and publicly announced in 2009. The language emphasizes simplicity, readability, and fast compilation times.
|
|
8
|
+
|
|
9
|
+
## Dependencies
|
|
10
|
+
|
|
11
|
+
### macOS (Homebrew)
|
|
12
|
+
- **Required:**
|
|
13
|
+
- Homebrew - Install via `/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"` or `dev install homebrew`
|
|
14
|
+
- **Optional:** None
|
|
15
|
+
- **Auto-installed:** None (Homebrew handles all package dependencies automatically)
|
|
16
|
+
|
|
17
|
+
### Ubuntu (APT/Snap)
|
|
18
|
+
- **Required:**
|
|
19
|
+
- `wget` - Install via `sudo apt install wget` (installed automatically by this installer)
|
|
20
|
+
- `curl` - Install via `sudo apt install curl` (installed automatically by this installer)
|
|
21
|
+
- `tar` - Install via `sudo apt install tar` (typically pre-installed on Ubuntu)
|
|
22
|
+
- `sudo` access - Required for system-wide installation to `/usr/local/go`
|
|
23
|
+
- **Optional:** None
|
|
24
|
+
- **Auto-installed:** None (downloads official tarball from go.dev)
|
|
25
|
+
|
|
26
|
+
### Raspberry Pi OS (APT/Snap)
|
|
27
|
+
- **Required:**
|
|
28
|
+
- `wget` - Install via `sudo apt install wget` (installed automatically by this installer)
|
|
29
|
+
- `curl` - Install via `sudo apt install curl` (installed automatically by this installer)
|
|
30
|
+
- `tar` - Install via `sudo apt install tar` (typically pre-installed on Raspberry Pi OS)
|
|
31
|
+
- `sudo` access - Required for system-wide installation to `/usr/local/go`
|
|
32
|
+
- `uname` - Pre-installed (used for architecture detection: aarch64, armv7l, armv6l)
|
|
33
|
+
- **Optional:** None
|
|
34
|
+
- **Auto-installed:** None (downloads official ARM tarball from go.dev)
|
|
35
|
+
|
|
36
|
+
### Amazon Linux (DNF/YUM)
|
|
37
|
+
- **Required:**
|
|
38
|
+
- `wget` - Install via `sudo dnf install wget` or `sudo yum install wget` (installed automatically by this installer)
|
|
39
|
+
- `curl` - Install via `sudo dnf install curl` or `sudo yum install curl` (installed automatically by this installer)
|
|
40
|
+
- `tar` - Install via `sudo dnf install tar` or `sudo yum install tar` (installed automatically by this installer)
|
|
41
|
+
- `sudo` access - Required for system-wide installation to `/usr/local/go`
|
|
42
|
+
- Either `dnf` (Amazon Linux 2023) or `yum` (Amazon Linux 2) package manager
|
|
43
|
+
- **Optional:** None
|
|
44
|
+
- **Auto-installed:** None (downloads official tarball from go.dev)
|
|
45
|
+
|
|
46
|
+
### Windows (Chocolatey/winget)
|
|
47
|
+
- **Required:**
|
|
48
|
+
- Chocolatey - Install via PowerShell: `Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))`
|
|
49
|
+
- PowerShell - Pre-installed on Windows 10/11
|
|
50
|
+
- Administrator privileges - Required to run Chocolatey commands
|
|
51
|
+
- **Optional:** None
|
|
52
|
+
- **Auto-installed:** All Go runtime dependencies are handled automatically by the Chocolatey golang package
|
|
53
|
+
|
|
54
|
+
### Git Bash (Manual/Portable)
|
|
55
|
+
- **Required:**
|
|
56
|
+
- Chocolatey on Windows host - Install via PowerShell (see Windows section above)
|
|
57
|
+
- PowerShell - Pre-installed on Windows 10/11
|
|
58
|
+
- Administrator privileges - Required to run Chocolatey commands via PowerShell from Git Bash
|
|
59
|
+
- Git Bash - Install via `choco install git` or download from https://git-scm.com/download/win
|
|
60
|
+
- **Optional:** None
|
|
61
|
+
- **Auto-installed:** All Go runtime dependencies are handled automatically by the Chocolatey golang package on the Windows host
|
|
62
|
+
|
|
63
|
+
## Prerequisites
|
|
64
|
+
|
|
65
|
+
Before installing Go on any platform, ensure:
|
|
66
|
+
|
|
67
|
+
1. **Internet connectivity** - Required to download Go packages
|
|
68
|
+
2. **Administrative privileges** - Required for system-wide installation
|
|
69
|
+
3. **Sufficient disk space** - At least 500 MB free disk space recommended
|
|
70
|
+
4. **Terminal/command prompt access** - Required to run installation commands
|
|
71
|
+
|
|
72
|
+
**Important**: If you have older Go installations, remove them before installing to avoid conflicts between versions.
|
|
73
|
+
|
|
74
|
+
## Platform-Specific Installation
|
|
75
|
+
|
|
76
|
+
### macOS (Homebrew)
|
|
77
|
+
|
|
78
|
+
#### Prerequisites
|
|
79
|
+
|
|
80
|
+
- macOS 12 (Monterey) or later
|
|
81
|
+
- Homebrew package manager installed
|
|
82
|
+
- Apple Silicon (M1/M2/M3/M4) or Intel processor
|
|
83
|
+
|
|
84
|
+
If Homebrew is not installed, install it first:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
#### Installation Steps
|
|
91
|
+
|
|
92
|
+
Run the following command to install Go:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
brew install --quiet go
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
The `--quiet` flag suppresses non-essential output for cleaner automation. Homebrew automatically:
|
|
99
|
+
|
|
100
|
+
- Installs Go to the Homebrew prefix (`/opt/homebrew/Cellar/go/` on Apple Silicon, `/usr/local/Cellar/go/` on Intel)
|
|
101
|
+
- Creates symlinks in the Homebrew bin directory
|
|
102
|
+
- Adds Go to your PATH (if Homebrew is properly configured)
|
|
103
|
+
|
|
104
|
+
**Note**: With modern Go (1.16+), you do not need to set `GOROOT` or `GOPATH` environment variables. Go modules handle dependency management automatically, and `GOPATH` defaults to `~/go`.
|
|
105
|
+
|
|
106
|
+
#### Verification
|
|
107
|
+
|
|
108
|
+
Confirm the installation succeeded:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
go version
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Expected output (version numbers may vary):
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
go version go1.25.5 darwin/arm64
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Test that Go is working correctly by running a simple command:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
go env GOROOT
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
This displays the Go installation directory, confirming the installation is functional.
|
|
127
|
+
|
|
128
|
+
#### Troubleshooting
|
|
129
|
+
|
|
130
|
+
**Problem**: `go: command not found` after installation
|
|
131
|
+
|
|
132
|
+
**Solution**: Homebrew may not be in your PATH. Add Homebrew to your shell configuration:
|
|
133
|
+
|
|
134
|
+
For Apple Silicon (M1/M2/M3/M4):
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
|
|
138
|
+
source ~/.zprofile
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
For Intel Macs:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
echo 'eval "$(/usr/local/bin/brew shellenv)"' >> ~/.zprofile
|
|
145
|
+
source ~/.zprofile
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**Problem**: Old version of Go installed
|
|
149
|
+
|
|
150
|
+
**Solution**: Update Homebrew and upgrade Go:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
brew update && brew upgrade go
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**Problem**: Need to install Go binaries globally (like `gopls`, `dlv`)
|
|
157
|
+
|
|
158
|
+
**Solution**: Ensure `$HOME/go/bin` is in your PATH:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
echo 'export PATH="$PATH:$HOME/go/bin"' >> ~/.zprofile
|
|
162
|
+
source ~/.zprofile
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
### Ubuntu/Debian (APT)
|
|
168
|
+
|
|
169
|
+
#### Prerequisites
|
|
170
|
+
|
|
171
|
+
- Ubuntu 20.04 (Focal) or later, or Debian 11 (Bullseye) or later (64-bit)
|
|
172
|
+
- sudo privileges
|
|
173
|
+
- At least 500 MB free disk space
|
|
174
|
+
|
|
175
|
+
**Important**: The `golang-go` package in Ubuntu/Debian repositories may be outdated. This guide uses the official Go distribution for the latest stable version.
|
|
176
|
+
|
|
177
|
+
First, remove any existing Go installations to avoid conflicts:
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get remove -y golang-go golang 2>/dev/null || true
|
|
181
|
+
sudo rm -rf /usr/local/go 2>/dev/null || true
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
#### Installation Steps
|
|
185
|
+
|
|
186
|
+
**Step 1: Install required utilities**
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get update -y
|
|
190
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y wget curl
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
**Step 2: Download and install Go**
|
|
194
|
+
|
|
195
|
+
Download the latest stable version and extract to `/usr/local`:
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
GO_VERSION=$(curl -sL 'https://go.dev/VERSION?m=text' | head -n1)
|
|
199
|
+
wget -q "https://go.dev/dl/${GO_VERSION}.linux-amd64.tar.gz" -O /tmp/go.tar.gz
|
|
200
|
+
sudo tar -C /usr/local -xzf /tmp/go.tar.gz
|
|
201
|
+
rm /tmp/go.tar.gz
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**Step 3: Configure environment variables**
|
|
205
|
+
|
|
206
|
+
Add Go to your PATH by appending to your shell profile:
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.profile
|
|
210
|
+
echo 'export PATH=$PATH:$HOME/go/bin' >> ~/.profile
|
|
211
|
+
source ~/.profile
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
The first line adds the Go compiler to PATH. The second line adds the directory where `go install` places binaries.
|
|
215
|
+
|
|
216
|
+
#### Verification
|
|
217
|
+
|
|
218
|
+
Confirm the installation succeeded:
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
go version
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Expected output (version numbers may vary):
|
|
225
|
+
|
|
226
|
+
```
|
|
227
|
+
go version go1.25.5 linux/amd64
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Verify the environment is configured correctly:
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
go env GOROOT GOPATH
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
Expected output:
|
|
237
|
+
|
|
238
|
+
```
|
|
239
|
+
/usr/local/go
|
|
240
|
+
/home/<username>/go
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
#### Troubleshooting
|
|
244
|
+
|
|
245
|
+
**Problem**: `go: command not found` after installation
|
|
246
|
+
|
|
247
|
+
**Solution**: The PATH changes require a new shell session. Either log out and log back in, or source your profile:
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
source ~/.profile
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
**Problem**: Permission denied when running `go install`
|
|
254
|
+
|
|
255
|
+
**Solution**: Go installs binaries to `$HOME/go/bin` by default, which should not require elevated privileges. If you encounter permission issues, ensure the directory exists and is owned by your user:
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
mkdir -p ~/go/bin
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
**Problem**: Old version persists after installation
|
|
262
|
+
|
|
263
|
+
**Solution**: An older version may be installed via apt. Remove it:
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get remove -y golang-go golang
|
|
267
|
+
hash -r
|
|
268
|
+
go version
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
**Problem**: `GOROOT` or `GOPATH` errors
|
|
272
|
+
|
|
273
|
+
**Solution**: Modern Go (1.16+) does not require these to be set. If you have them set incorrectly from a previous installation, remove them:
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
unset GOROOT
|
|
277
|
+
unset GOPATH
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
### Raspberry Pi OS (APT)
|
|
283
|
+
|
|
284
|
+
#### Prerequisites
|
|
285
|
+
|
|
286
|
+
- Raspberry Pi OS (64-bit recommended) - Bookworm or Bullseye
|
|
287
|
+
- Raspberry Pi 3B+ or later (64-bit capable hardware)
|
|
288
|
+
- At least 500 MB free disk space
|
|
289
|
+
- sudo privileges
|
|
290
|
+
|
|
291
|
+
**Important**: You must download the correct Go binary for your architecture. Raspberry Pi OS can run in 32-bit (armv6l/armv7l) or 64-bit (arm64/aarch64) mode.
|
|
292
|
+
|
|
293
|
+
First, verify your architecture:
|
|
294
|
+
|
|
295
|
+
```bash
|
|
296
|
+
uname -m
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
- `aarch64` = 64-bit (recommended, use `linux-arm64`)
|
|
300
|
+
- `armv7l` or `armv6l` = 32-bit (use `linux-armv6l`)
|
|
301
|
+
|
|
302
|
+
Remove any existing Go installations:
|
|
303
|
+
|
|
304
|
+
```bash
|
|
305
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get remove -y golang-go golang 2>/dev/null || true
|
|
306
|
+
sudo rm -rf /usr/local/go 2>/dev/null || true
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
#### Installation Steps
|
|
310
|
+
|
|
311
|
+
**Step 1: Install required utilities**
|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get update -y
|
|
315
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y wget curl
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
**Step 2: Download and install Go**
|
|
319
|
+
|
|
320
|
+
The following script automatically detects your architecture and downloads the correct version:
|
|
321
|
+
|
|
322
|
+
```bash
|
|
323
|
+
GO_VERSION=$(curl -sL 'https://go.dev/VERSION?m=text' | head -n1)
|
|
324
|
+
ARCH=$(uname -m)
|
|
325
|
+
if [ "$ARCH" = "aarch64" ]; then
|
|
326
|
+
GO_ARCH="linux-arm64"
|
|
327
|
+
elif [ "$ARCH" = "armv7l" ] || [ "$ARCH" = "armv6l" ]; then
|
|
328
|
+
GO_ARCH="linux-armv6l"
|
|
329
|
+
else
|
|
330
|
+
echo "Unsupported architecture: $ARCH"
|
|
331
|
+
exit 1
|
|
332
|
+
fi
|
|
333
|
+
wget -q "https://go.dev/dl/${GO_VERSION}.${GO_ARCH}.tar.gz" -O /tmp/go.tar.gz
|
|
334
|
+
sudo tar -C /usr/local -xzf /tmp/go.tar.gz
|
|
335
|
+
rm /tmp/go.tar.gz
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
**Step 3: Configure environment variables**
|
|
339
|
+
|
|
340
|
+
Add Go to your PATH:
|
|
341
|
+
|
|
342
|
+
```bash
|
|
343
|
+
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.profile
|
|
344
|
+
echo 'export PATH=$PATH:$HOME/go/bin' >> ~/.profile
|
|
345
|
+
source ~/.profile
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
#### Verification
|
|
349
|
+
|
|
350
|
+
Confirm the installation succeeded:
|
|
351
|
+
|
|
352
|
+
```bash
|
|
353
|
+
go version
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
Expected output for 64-bit (version numbers may vary):
|
|
357
|
+
|
|
358
|
+
```
|
|
359
|
+
go version go1.25.5 linux/arm64
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
Expected output for 32-bit:
|
|
363
|
+
|
|
364
|
+
```
|
|
365
|
+
go version go1.25.5 linux/arm
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
#### Troubleshooting
|
|
369
|
+
|
|
370
|
+
**Problem**: `cannot execute binary file: Exec format error`
|
|
371
|
+
|
|
372
|
+
**Solution**: You downloaded the wrong architecture. Check your architecture with `uname -m` and download the matching version:
|
|
373
|
+
|
|
374
|
+
- `aarch64` -> `linux-arm64.tar.gz`
|
|
375
|
+
- `armv7l` or `armv6l` -> `linux-armv6l.tar.gz`
|
|
376
|
+
|
|
377
|
+
**Problem**: Very slow compilation
|
|
378
|
+
|
|
379
|
+
**Solution**: Raspberry Pi has limited CPU and RAM. Compilation is slower than on desktop systems. Consider:
|
|
380
|
+
|
|
381
|
+
- Using a faster SD card or USB/SSD boot
|
|
382
|
+
- Adding swap space if you have less than 2 GB RAM
|
|
383
|
+
- Cross-compiling on a more powerful machine
|
|
384
|
+
|
|
385
|
+
**Problem**: Out of memory during compilation
|
|
386
|
+
|
|
387
|
+
**Solution**: Add swap space:
|
|
388
|
+
|
|
389
|
+
```bash
|
|
390
|
+
sudo fallocate -l 2G /swapfile
|
|
391
|
+
sudo chmod 600 /swapfile
|
|
392
|
+
sudo mkswap /swapfile
|
|
393
|
+
sudo swapon /swapfile
|
|
394
|
+
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
**Problem**: `apt install golang-go` installs very old version
|
|
398
|
+
|
|
399
|
+
**Solution**: The Raspberry Pi OS repositories contain outdated Go versions. Use the manual installation method above for the latest version.
|
|
400
|
+
|
|
401
|
+
---
|
|
402
|
+
|
|
403
|
+
### Amazon Linux (DNF/YUM)
|
|
404
|
+
|
|
405
|
+
#### Prerequisites
|
|
406
|
+
|
|
407
|
+
- Amazon Linux 2023 (AL2023) or Amazon Linux 2 (AL2)
|
|
408
|
+
- sudo privileges
|
|
409
|
+
- EC2 instance or compatible environment
|
|
410
|
+
|
|
411
|
+
**Note**: Amazon Linux 2023 uses DNF as the package manager. Amazon Linux 2 uses YUM. The version in Amazon's repositories may be older than the latest stable release. This guide uses the official Go distribution for the latest version.
|
|
412
|
+
|
|
413
|
+
First, remove any existing Go installations:
|
|
414
|
+
|
|
415
|
+
```bash
|
|
416
|
+
sudo rm -rf /usr/local/go 2>/dev/null || true
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
#### Installation Steps
|
|
420
|
+
|
|
421
|
+
**Step 1: Install required utilities**
|
|
422
|
+
|
|
423
|
+
For Amazon Linux 2023:
|
|
424
|
+
|
|
425
|
+
```bash
|
|
426
|
+
sudo dnf install -y wget curl tar
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
For Amazon Linux 2:
|
|
430
|
+
|
|
431
|
+
```bash
|
|
432
|
+
sudo yum install -y wget curl tar
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
**Step 2: Download and install Go**
|
|
436
|
+
|
|
437
|
+
```bash
|
|
438
|
+
GO_VERSION=$(curl -sL 'https://go.dev/VERSION?m=text' | head -n1)
|
|
439
|
+
wget -q "https://go.dev/dl/${GO_VERSION}.linux-amd64.tar.gz" -O /tmp/go.tar.gz
|
|
440
|
+
sudo tar -C /usr/local -xzf /tmp/go.tar.gz
|
|
441
|
+
rm /tmp/go.tar.gz
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
**Step 3: Configure environment variables**
|
|
445
|
+
|
|
446
|
+
Add Go to your PATH:
|
|
447
|
+
|
|
448
|
+
```bash
|
|
449
|
+
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc
|
|
450
|
+
echo 'export PATH=$PATH:$HOME/go/bin' >> ~/.bashrc
|
|
451
|
+
source ~/.bashrc
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
**Alternative: Install from Amazon Repositories (older version)**
|
|
455
|
+
|
|
456
|
+
If you prefer to use the version from Amazon's repositories (may be older):
|
|
457
|
+
|
|
458
|
+
For Amazon Linux 2023:
|
|
459
|
+
|
|
460
|
+
```bash
|
|
461
|
+
sudo dnf install -y golang
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
For Amazon Linux 2:
|
|
465
|
+
|
|
466
|
+
```bash
|
|
467
|
+
sudo yum install -y golang
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
**Note**: The repository version may be Go 1.19 or older. Use the manual installation above for the latest version.
|
|
471
|
+
|
|
472
|
+
#### Verification
|
|
473
|
+
|
|
474
|
+
Confirm the installation succeeded:
|
|
475
|
+
|
|
476
|
+
```bash
|
|
477
|
+
go version
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
Expected output (version numbers may vary):
|
|
481
|
+
|
|
482
|
+
```
|
|
483
|
+
go version go1.25.5 linux/amd64
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
Verify the environment:
|
|
487
|
+
|
|
488
|
+
```bash
|
|
489
|
+
go env GOROOT
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
Expected output:
|
|
493
|
+
|
|
494
|
+
```
|
|
495
|
+
/usr/local/go
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
#### Troubleshooting
|
|
499
|
+
|
|
500
|
+
**Problem**: `go: command not found` after installation
|
|
501
|
+
|
|
502
|
+
**Solution**: Source your bash profile or start a new shell session:
|
|
503
|
+
|
|
504
|
+
```bash
|
|
505
|
+
source ~/.bashrc
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
**Problem**: Repository version is too old
|
|
509
|
+
|
|
510
|
+
**Solution**: Use the manual installation method documented above to get the latest version from the official Go website.
|
|
511
|
+
|
|
512
|
+
**Problem**: Conflict between manual and repository installations
|
|
513
|
+
|
|
514
|
+
**Solution**: Remove the repository version before manual installation:
|
|
515
|
+
|
|
516
|
+
For Amazon Linux 2023:
|
|
517
|
+
|
|
518
|
+
```bash
|
|
519
|
+
sudo dnf remove -y golang
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
For Amazon Linux 2:
|
|
523
|
+
|
|
524
|
+
```bash
|
|
525
|
+
sudo yum remove -y golang
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
---
|
|
529
|
+
|
|
530
|
+
### Windows (Chocolatey/winget)
|
|
531
|
+
|
|
532
|
+
#### Prerequisites
|
|
533
|
+
|
|
534
|
+
- Windows 10 version 1809 or later, or Windows 11
|
|
535
|
+
- Administrator PowerShell or Command Prompt
|
|
536
|
+
- Chocolatey or winget package manager installed
|
|
537
|
+
|
|
538
|
+
If neither package manager is installed, install Chocolatey by running this command in an Administrator PowerShell:
|
|
539
|
+
|
|
540
|
+
```powershell
|
|
541
|
+
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
#### Installation Steps
|
|
545
|
+
|
|
546
|
+
Run the following command in an Administrator PowerShell or Command Prompt:
|
|
547
|
+
|
|
548
|
+
```powershell
|
|
549
|
+
choco install golang -y
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
The `-y` flag automatically confirms all prompts, enabling fully non-interactive installation. Chocolatey uses the official Go MSI installer with silent installation flags (`/qn /norestart`).
|
|
553
|
+
|
|
554
|
+
**Alternative: Using winget**
|
|
555
|
+
|
|
556
|
+
If you prefer winget (built into Windows 11 and Windows 10 21H2+):
|
|
557
|
+
|
|
558
|
+
```powershell
|
|
559
|
+
winget install --id GoLang.Go --silent --accept-package-agreements --accept-source-agreements
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
After installation, close and reopen your terminal for the PATH changes to take effect. Alternatively, in PowerShell, run:
|
|
563
|
+
|
|
564
|
+
```powershell
|
|
565
|
+
refreshenv
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
#### Verification
|
|
569
|
+
|
|
570
|
+
Open a new Command Prompt or PowerShell window, then run:
|
|
571
|
+
|
|
572
|
+
```powershell
|
|
573
|
+
go version
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
Expected output (version numbers may vary):
|
|
577
|
+
|
|
578
|
+
```
|
|
579
|
+
go version go1.25.5 windows/amd64
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
Verify the installation path:
|
|
583
|
+
|
|
584
|
+
```powershell
|
|
585
|
+
go env GOROOT
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
Expected output (default installation):
|
|
589
|
+
|
|
590
|
+
```
|
|
591
|
+
C:\Program Files\Go
|
|
592
|
+
```
|
|
593
|
+
|
|
594
|
+
#### Troubleshooting
|
|
595
|
+
|
|
596
|
+
**Problem**: `go: The term 'go' is not recognized` after installation
|
|
597
|
+
|
|
598
|
+
**Solution**: The PATH was not updated. Close and reopen PowerShell, or manually refresh the environment:
|
|
599
|
+
|
|
600
|
+
```powershell
|
|
601
|
+
refreshenv
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
If using Command Prompt, close and reopen it.
|
|
605
|
+
|
|
606
|
+
**Problem**: Installation fails with access denied
|
|
607
|
+
|
|
608
|
+
**Solution**: Ensure you are running PowerShell or Command Prompt as Administrator. Right-click the application and select "Run as administrator".
|
|
609
|
+
|
|
610
|
+
**Problem**: Old version persists after upgrade
|
|
611
|
+
|
|
612
|
+
**Solution**: Uninstall and reinstall Go:
|
|
613
|
+
|
|
614
|
+
```powershell
|
|
615
|
+
choco uninstall golang -y
|
|
616
|
+
choco install golang -y
|
|
617
|
+
```
|
|
618
|
+
|
|
619
|
+
**Problem**: Multiple Go versions installed
|
|
620
|
+
|
|
621
|
+
**Solution**: Remove the extra installation. Check `C:\Program Files\Go` and `C:\Go` for duplicate installations.
|
|
622
|
+
|
|
623
|
+
---
|
|
624
|
+
|
|
625
|
+
### WSL (Ubuntu)
|
|
626
|
+
|
|
627
|
+
#### Prerequisites
|
|
628
|
+
|
|
629
|
+
- Windows 10 version 2004 or later, or Windows 11
|
|
630
|
+
- WSL 2 enabled with Ubuntu distribution installed
|
|
631
|
+
- sudo privileges within WSL
|
|
632
|
+
|
|
633
|
+
**Note**: WSL runs a full Linux environment, so the installation process is identical to native Ubuntu. The commands below are specific to Ubuntu running under WSL.
|
|
634
|
+
|
|
635
|
+
First, remove any existing Go installations:
|
|
636
|
+
|
|
637
|
+
```bash
|
|
638
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get remove -y golang-go golang 2>/dev/null || true
|
|
639
|
+
sudo rm -rf /usr/local/go 2>/dev/null || true
|
|
640
|
+
```
|
|
641
|
+
|
|
642
|
+
#### Installation Steps
|
|
643
|
+
|
|
644
|
+
Run these commands in your WSL Ubuntu terminal:
|
|
645
|
+
|
|
646
|
+
**Step 1: Install required utilities**
|
|
647
|
+
|
|
648
|
+
```bash
|
|
649
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get update -y
|
|
650
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y wget curl
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
**Step 2: Download and install Go**
|
|
654
|
+
|
|
655
|
+
```bash
|
|
656
|
+
GO_VERSION=$(curl -sL 'https://go.dev/VERSION?m=text' | head -n1)
|
|
657
|
+
wget -q "https://go.dev/dl/${GO_VERSION}.linux-amd64.tar.gz" -O /tmp/go.tar.gz
|
|
658
|
+
sudo tar -C /usr/local -xzf /tmp/go.tar.gz
|
|
659
|
+
rm /tmp/go.tar.gz
|
|
660
|
+
```
|
|
661
|
+
|
|
662
|
+
**Step 3: Configure environment variables**
|
|
663
|
+
|
|
664
|
+
Add Go to your PATH:
|
|
665
|
+
|
|
666
|
+
```bash
|
|
667
|
+
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc
|
|
668
|
+
echo 'export PATH=$PATH:$HOME/go/bin' >> ~/.bashrc
|
|
669
|
+
source ~/.bashrc
|
|
670
|
+
```
|
|
671
|
+
|
|
672
|
+
#### Verification
|
|
673
|
+
|
|
674
|
+
Confirm the installation succeeded:
|
|
675
|
+
|
|
676
|
+
```bash
|
|
677
|
+
go version
|
|
678
|
+
```
|
|
679
|
+
|
|
680
|
+
Expected output (version numbers may vary):
|
|
681
|
+
|
|
682
|
+
```
|
|
683
|
+
go version go1.25.5 linux/amd64
|
|
684
|
+
```
|
|
685
|
+
|
|
686
|
+
#### Troubleshooting
|
|
687
|
+
|
|
688
|
+
**Problem**: `go: command not found` after installation
|
|
689
|
+
|
|
690
|
+
**Solution**: Source your bash profile or close and reopen the WSL terminal:
|
|
691
|
+
|
|
692
|
+
```bash
|
|
693
|
+
source ~/.bashrc
|
|
694
|
+
```
|
|
695
|
+
|
|
696
|
+
**Problem**: Very slow file operations when code is on Windows filesystem
|
|
697
|
+
|
|
698
|
+
**Solution**: Keep your Go code on the Linux filesystem (`~/projects`) rather than the Windows filesystem (`/mnt/c/`). WSL 2 performs significantly better with files on the native Linux filesystem.
|
|
699
|
+
|
|
700
|
+
**Problem**: Cannot access Go tools installed with `go install` from Windows
|
|
701
|
+
|
|
702
|
+
**Solution**: Go binaries installed in WSL are Linux executables and cannot run directly from Windows. Use VS Code with the Remote - WSL extension or run Go commands from within WSL.
|
|
703
|
+
|
|
704
|
+
**Problem**: IDE cannot find Go installation
|
|
705
|
+
|
|
706
|
+
**Solution**: When using VS Code with Remote - WSL extension, ensure you open VS Code from within WSL by running `code .` in your project directory. VS Code will automatically detect the Go installation in WSL.
|
|
707
|
+
|
|
708
|
+
---
|
|
709
|
+
|
|
710
|
+
### Git Bash (Windows Installation)
|
|
711
|
+
|
|
712
|
+
#### Prerequisites
|
|
713
|
+
|
|
714
|
+
- Windows 10 or Windows 11 (64-bit)
|
|
715
|
+
- Git Bash installed (comes with Git for Windows)
|
|
716
|
+
- Go installed on Windows (see Windows section)
|
|
717
|
+
|
|
718
|
+
**Note**: Git Bash on Windows does not require a separate Go installation. Git Bash inherits the Windows PATH, so once Go is installed on Windows using Chocolatey or winget, the `go` command is automatically available in Git Bash.
|
|
719
|
+
|
|
720
|
+
#### Installation Steps
|
|
721
|
+
|
|
722
|
+
1. Install Go on Windows using Chocolatey (see Windows section):
|
|
723
|
+
|
|
724
|
+
```bash
|
|
725
|
+
# Run from Administrator PowerShell or Command Prompt
|
|
726
|
+
choco install golang -y
|
|
727
|
+
```
|
|
728
|
+
|
|
729
|
+
2. Close and reopen Git Bash to pick up the PATH changes
|
|
730
|
+
|
|
731
|
+
3. The `go` command is now available in Git Bash
|
|
732
|
+
|
|
733
|
+
If you need to manually add Go to the Git Bash PATH (typically not required), add to your `~/.bashrc`:
|
|
734
|
+
|
|
735
|
+
```bash
|
|
736
|
+
echo 'export PATH="$PATH:/c/Program Files/Go/bin"' >> ~/.bashrc
|
|
737
|
+
echo 'export PATH="$PATH:$HOME/go/bin"' >> ~/.bashrc
|
|
738
|
+
source ~/.bashrc
|
|
739
|
+
```
|
|
740
|
+
|
|
741
|
+
#### Verification
|
|
742
|
+
|
|
743
|
+
In Git Bash, confirm Go is accessible:
|
|
744
|
+
|
|
745
|
+
```bash
|
|
746
|
+
go version
|
|
747
|
+
```
|
|
748
|
+
|
|
749
|
+
Expected output (version numbers may vary):
|
|
750
|
+
|
|
751
|
+
```
|
|
752
|
+
go version go1.25.5 windows/amd64
|
|
753
|
+
```
|
|
754
|
+
|
|
755
|
+
Test that Go commands work:
|
|
756
|
+
|
|
757
|
+
```bash
|
|
758
|
+
go env GOROOT
|
|
759
|
+
```
|
|
760
|
+
|
|
761
|
+
Expected output:
|
|
762
|
+
|
|
763
|
+
```
|
|
764
|
+
C:\Program Files\Go
|
|
765
|
+
```
|
|
766
|
+
|
|
767
|
+
#### Troubleshooting
|
|
768
|
+
|
|
769
|
+
**Problem**: `go: command not found` in Git Bash
|
|
770
|
+
|
|
771
|
+
**Solution**: The PATH may not be inherited. First, ensure Go is installed on Windows and works in PowerShell/Command Prompt. Then add Go to Git Bash's PATH manually:
|
|
772
|
+
|
|
773
|
+
```bash
|
|
774
|
+
echo 'export PATH="$PATH:/c/Program Files/Go/bin"' >> ~/.bashrc
|
|
775
|
+
source ~/.bashrc
|
|
776
|
+
```
|
|
777
|
+
|
|
778
|
+
**Problem**: Path conversion issues with Go commands
|
|
779
|
+
|
|
780
|
+
**Solution**: Git Bash automatically converts Unix-style paths to Windows paths. This can occasionally cause issues. To disable path conversion for a specific command, prefix it with `MSYS_NO_PATHCONV=1`:
|
|
781
|
+
|
|
782
|
+
```bash
|
|
783
|
+
MSYS_NO_PATHCONV=1 go build -o /c/Users/me/myapp.exe
|
|
784
|
+
```
|
|
785
|
+
|
|
786
|
+
**Problem**: Go modules fail to download (SSL/TLS errors)
|
|
787
|
+
|
|
788
|
+
**Solution**: Ensure Git is configured with proper SSL settings:
|
|
789
|
+
|
|
790
|
+
```bash
|
|
791
|
+
git config --global http.sslBackend schannel
|
|
792
|
+
```
|
|
793
|
+
|
|
794
|
+
**Problem**: `go install` puts binaries in unexpected location
|
|
795
|
+
|
|
796
|
+
**Solution**: Go uses `%USERPROFILE%\go\bin` on Windows. In Git Bash, this translates to `$HOME/go/bin`. Ensure this is in your PATH:
|
|
797
|
+
|
|
798
|
+
```bash
|
|
799
|
+
echo 'export PATH="$PATH:$HOME/go/bin"' >> ~/.bashrc
|
|
800
|
+
source ~/.bashrc
|
|
801
|
+
```
|
|
802
|
+
|
|
803
|
+
---
|
|
804
|
+
|
|
805
|
+
## Post-Installation Configuration
|
|
806
|
+
|
|
807
|
+
After installing Go on any platform, consider these optional but recommended configurations.
|
|
808
|
+
|
|
809
|
+
### Verifying Go Modules Work
|
|
810
|
+
|
|
811
|
+
Modern Go uses modules for dependency management (enabled by default since Go 1.16). Test that modules work:
|
|
812
|
+
|
|
813
|
+
```bash
|
|
814
|
+
mkdir -p /tmp/gotest && cd /tmp/gotest
|
|
815
|
+
go mod init example.com/test
|
|
816
|
+
go get golang.org/x/tools/gopls@latest
|
|
817
|
+
```
|
|
818
|
+
|
|
819
|
+
If this completes without errors, Go modules are working correctly.
|
|
820
|
+
|
|
821
|
+
### Installing Common Development Tools
|
|
822
|
+
|
|
823
|
+
Install frequently used Go tools:
|
|
824
|
+
|
|
825
|
+
```bash
|
|
826
|
+
go install golang.org/x/tools/gopls@latest # Go language server (for IDE support)
|
|
827
|
+
go install github.com/go-delve/delve/cmd/dlv@latest # Debugger
|
|
828
|
+
go install golang.org/x/tools/cmd/goimports@latest # Import organizer
|
|
829
|
+
```
|
|
830
|
+
|
|
831
|
+
These binaries are installed to `$HOME/go/bin` (or `%USERPROFILE%\go\bin` on Windows). Ensure this directory is in your PATH.
|
|
832
|
+
|
|
833
|
+
### Configuring Your Editor
|
|
834
|
+
|
|
835
|
+
**VS Code:**
|
|
836
|
+
|
|
837
|
+
1. Install the "Go" extension by the Go Team at Google
|
|
838
|
+
2. Open a `.go` file and accept the prompt to install Go tools
|
|
839
|
+
3. The extension uses `gopls` for language features
|
|
840
|
+
|
|
841
|
+
**GoLand:**
|
|
842
|
+
|
|
843
|
+
GoLand automatically detects Go installations. Verify the SDK path in Settings > Go > GOROOT.
|
|
844
|
+
|
|
845
|
+
**Vim/Neovim:**
|
|
846
|
+
|
|
847
|
+
Install the `vim-go` plugin or use native LSP with `gopls`.
|
|
848
|
+
|
|
849
|
+
### Setting Up Private Module Access
|
|
850
|
+
|
|
851
|
+
If you use private Go modules (from private Git repositories), configure Git authentication:
|
|
852
|
+
|
|
853
|
+
```bash
|
|
854
|
+
# For GitHub
|
|
855
|
+
git config --global url."git@github.com:".insteadOf "https://github.com/"
|
|
856
|
+
|
|
857
|
+
# Set GOPRIVATE for your private repos
|
|
858
|
+
export GOPRIVATE="github.com/your-org/*"
|
|
859
|
+
```
|
|
860
|
+
|
|
861
|
+
Add `GOPRIVATE` to your shell profile for persistence.
|
|
862
|
+
|
|
863
|
+
---
|
|
864
|
+
|
|
865
|
+
## Common Issues
|
|
866
|
+
|
|
867
|
+
### Issue: "go: module requires Go X.Y"
|
|
868
|
+
|
|
869
|
+
**Symptoms**: Error message indicating the module requires a newer Go version than installed.
|
|
870
|
+
|
|
871
|
+
**Solutions**:
|
|
872
|
+
|
|
873
|
+
- Update Go to the latest version using your package manager
|
|
874
|
+
- Or use the version specified by the module (check `go.mod`)
|
|
875
|
+
|
|
876
|
+
### Issue: "cannot find package" or Module Download Failures
|
|
877
|
+
|
|
878
|
+
**Symptoms**: `go get` or `go build` cannot find or download packages.
|
|
879
|
+
|
|
880
|
+
**Solutions**:
|
|
881
|
+
|
|
882
|
+
- Ensure you have internet connectivity
|
|
883
|
+
- Check if the package exists and the URL is correct
|
|
884
|
+
- For corporate networks, configure proxy settings:
|
|
885
|
+
|
|
886
|
+
```bash
|
|
887
|
+
export HTTP_PROXY=http://proxy.example.com:8080
|
|
888
|
+
export HTTPS_PROXY=http://proxy.example.com:8080
|
|
889
|
+
export NO_PROXY=localhost,127.0.0.1
|
|
890
|
+
```
|
|
891
|
+
|
|
892
|
+
- For private modules, configure `GOPRIVATE`:
|
|
893
|
+
|
|
894
|
+
```bash
|
|
895
|
+
export GOPRIVATE="github.com/your-org/*"
|
|
896
|
+
```
|
|
897
|
+
|
|
898
|
+
### Issue: "GOROOT" or "GOPATH" Confusion
|
|
899
|
+
|
|
900
|
+
**Symptoms**: Errors related to GOROOT or GOPATH configuration.
|
|
901
|
+
|
|
902
|
+
**Solutions**:
|
|
903
|
+
|
|
904
|
+
Modern Go (1.16+) handles these automatically:
|
|
905
|
+
|
|
906
|
+
- `GOROOT`: Location of Go installation (auto-detected)
|
|
907
|
+
- `GOPATH`: Location for downloaded modules and installed binaries (defaults to `$HOME/go`)
|
|
908
|
+
|
|
909
|
+
You typically do not need to set these. If you have them set from an old installation, remove them:
|
|
910
|
+
|
|
911
|
+
```bash
|
|
912
|
+
unset GOROOT
|
|
913
|
+
unset GOPATH
|
|
914
|
+
```
|
|
915
|
+
|
|
916
|
+
### Issue: "Permission Denied" When Installing Packages
|
|
917
|
+
|
|
918
|
+
**Symptoms**: `go install` fails with permission errors.
|
|
919
|
+
|
|
920
|
+
**Solutions**:
|
|
921
|
+
|
|
922
|
+
Go should install to `$HOME/go/bin`, which does not require root. If it is trying to install elsewhere:
|
|
923
|
+
|
|
924
|
+
- Check `go env GOBIN` and `go env GOPATH`
|
|
925
|
+
- Ensure `$HOME/go/bin` exists and is writable:
|
|
926
|
+
|
|
927
|
+
```bash
|
|
928
|
+
mkdir -p ~/go/bin
|
|
929
|
+
```
|
|
930
|
+
|
|
931
|
+
- Never run `go install` with sudo
|
|
932
|
+
|
|
933
|
+
### Issue: Slow First-Time Builds
|
|
934
|
+
|
|
935
|
+
**Symptoms**: Initial compilation takes a long time.
|
|
936
|
+
|
|
937
|
+
**Solutions**:
|
|
938
|
+
|
|
939
|
+
This is normal. Go caches compiled packages, so subsequent builds are much faster. To ensure caching works:
|
|
940
|
+
|
|
941
|
+
- Check the cache location: `go env GOCACHE`
|
|
942
|
+
- Ensure you have sufficient disk space
|
|
943
|
+
- On CI systems, cache the Go build cache and module cache
|
|
944
|
+
|
|
945
|
+
---
|
|
946
|
+
|
|
947
|
+
## References
|
|
948
|
+
|
|
949
|
+
- [Go Official Download Page](https://go.dev/dl/)
|
|
950
|
+
- [Go Installation Documentation](https://go.dev/doc/install)
|
|
951
|
+
- [Go Wiki: Ubuntu](https://go.dev/wiki/Ubuntu)
|
|
952
|
+
- [Go Homebrew Formula](https://formulae.brew.sh/formula/go)
|
|
953
|
+
- [Go Chocolatey Package](https://community.chocolatey.org/packages/golang)
|
|
954
|
+
- [Go winget Package](https://winstall.app/apps/GoLang.Go)
|
|
955
|
+
- [AWS: Go in Amazon Linux 2023](https://docs.aws.amazon.com/linux/al2023/ug/go.html)
|
|
956
|
+
- [Installing Go on Raspberry Pi](https://www.jeremymorgan.com/tutorials/raspberry-pi/install-go-raspberry-pi/)
|
|
957
|
+
- [Installing Go on WSL](https://dev.to/pu-lazydev/installing-go-golang-on-wsl-ubuntu-18b7)
|
|
958
|
+
- [Go Modules Documentation](https://go.dev/blog/using-go-modules)
|