Quickly Set Up a CentOS 8 Server for Go Development
This step‑by‑step guide shows new Linux server users how to configure remote login, switch to fast mirrors, install essential tools like lrzsz and vim, set up environment variables, install Go, and add the vim‑go plugin on a CentOS 8 system.
Remote login
Use an SSH client (e.g., Xshell or SecureCRT) to connect to the cloud server with the provided root credentials.
Replace default CentOS‑8 software mirrors
Speed up package installation by switching to a faster mirror:
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
yum makecache
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
yum -y updateInstall lrzsz (rz/sz) file‑transfer tools
yum install lrzszInstall or upgrade Vim (optional)
If the repository version is insufficient for plugins, compile the latest Vim from source:
yum install gcc ncurses-devel
wget https://github.com/vim/vim/archive/master.zip
unzip master.zip
cd vim-master/src/
./configure
make
make installConfigure Vim
Place a customized .vimrc in the home directory of the user that will run the development environment (e.g., /root/.vimrc).
Set Go‑related environment variables
Add the following lines to either /root/.bashrc or /root/.bash_profile (choose one) and then reload the file with source .bashrc:
PS1='[\t \u@\H:\w]$ '
PATH=$PATH:~/bin:~/go/bin:~/gopkg/bin
LANG=zh_CN.UTF-8
GOROOT=~/go
GOPATH=~/gopkg
GO111MODULE=on
GOPROXY=https://goproxy.cn,direct
GOCACHE=~/gocache
GOBIN=~/bin
export PATH LD_LIBRARY_PATH LANG GOROOT GOPATH GOPROXY GO111MODULE GOCACHE GOBINInstall Go
Download the latest Go tarball from the official site (e.g., https://golang.google.cn/dl/go1.15.2.linux-amd64.tar.gz), upload it to the server (using rz), and extract it:
tar -xvf go1.15.2.linux-amd64.tar.gz -C .Verify the installation:
go versionInstall the vim-go plugin
Clone the plugin repository and enable Go binaries inside Vim:
yum install git
git clone https://github.com/fatih/vim-go.git ~/.vim/pack/plugins/start/vim-go
# Inside Vim:
:GoInstallBinariesResult
After completing the steps above, the server provides a ready‑to‑use Go development environment with Vim configured for Go coding.
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.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
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.
