To install Go (Golang) and set up the environment so that tools like subfinder,nuclei etc. work properly, follow these step-by-step instructions.
✅ 1. Download and Install Go
🔹 For Linux / WSL / Kali:
1
2
3
4
5
6
7
8
| # Remove any existing Go installation
sudo rm -rf /usr/local/go
# Download the latest version of Go (change version if needed)
wget https://go.dev/dl/go1.22.2.linux-amd64.tar.gz
# Extract it to /usr/local
sudo tar -C /usr/local -xzf go1.22.2.linux-amd64.tar.gz
|
✅ 2. Set Up Go Environment Variables
Edit your shell profile file:
If you use bash, edit:
If you use zsh, edit:
Add the following at the bottom:
1
2
3
| export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
|
Apply changes:
1
| source ~/.bashrc # or source ~/.zshrc
|
You can find out which shell you’re using with any of the following commands:
✅ Method 1: Check current shell in use
- This shows your default login shell (e.g.,
/bin/bash, /bin/zsh).
✅ Method 2: Check your active shell process
- This shows the current shell process you’re actively using.
- Output example:
1
2
| PID TTY TIME CMD
1234 pts/0 00:00:00 bash
|
✅ Method 3: Using echo $0
- It may return:
bashzshsh (for minimal POSIX shell)-bash (if it’s a login shell)
If you need to switch to bash or zsh, just run:
1
2
| bash # Switch to bash
zsh # Switch to zsh (if installed)
|
✅ 3. Verify Installation
Expected output:
1
| go version go1.22.2 linux/amd64
|
It will be installed at:
So now you can just run:
✅ 5. (Optional) Check Go Paths
1
2
| echo $GOPATH
echo $PATH
|
You should see something like:
1
2
| /home/youruser/go
...:/usr/local/go/bin:/home/youruser/go/bin
|
And that’s it for this article. Hope you like it.
Happy Learning and Keep Hacking.