Make Linux server a good helper for Go developers
Installing a Linux system is still a relatively complicated matter for many people, let alone using a Linux system to develop Go. But now, with the convenience provided by major cloud server manufacturers, you can easily own a Linux server and just log in using a remote terminal. For those newbies who are not familiar with Linux systems and Go development, here are some simple settings and steps to help you use Linux systems to develop Go programs more smoothly.

- I still remember when I was in college, installing a Linux system was still a relatively complicated matter.
- You need to download the image first, then burn it to a CD, and then install it with the CD.
- The biggest headache is that the quality of the optical drive in my laptop is not very good, so I don't know if there is a problem because the installation steps are wrong or because my optical drive is not running well in the first place.
- Of course, I can also install it in a virtual machine, but I am paranoid and want to install it directly in the hardware.
- Nowadays, with major cloud server manufacturers, you can easily own a Linux server.
- When novices get a Linux server, they often don't know how to use it, and their scalp goes numb looking at the command line. Here I will sort it out for you, so that you can use the Linux system more smoothly.
- The system I use is CentOS8, and the corresponding other Linux operating systems should be similar.
1. Remote login tool
Generally when we do server development, we must use a remote terminal to log in to the Linux server, and then perform corresponding operations.
XShell and SeucreCrt are both very useful tools. You can try them. I use Xshell myself, because it has a free version, so I don’t have to worry about cracking it.
Generally when purchasing a cloud server, the manufacturer will ask you to set a username and password. Here I directly use the root user to log in.
2. Set up the software source
The software source that comes with Linux may be slow, we can replace it with a domestic source.
Run the following command
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 update
3. Install rzsz tool
This is a set of upload and download tools that can easily upload your local files to the cloud server and download the files from the cloud server to the local.
yum install lrzsz
Download is the sz command, upload is the rz command
4. Install vim
The vim version that comes with CentOS8 is already quite high, so there is no need to reinstall it.
If the version is relatively low, you can install the latest vim version. Because subsequent installation of the vim-go plug-in requires a higher version of vim.
Because I have always used vim, I will use vim to complete the places that need to be edited later.
I also hope that readers can learn to use vim, because it will make your work a lot easier (server direction only).
The installation steps are as follows:
yum install gcc ncurses-devel wget https://github.com/vim/vim/archive/master.zip unzip master.zip cd vim-master/src/ ./configure make make install
5. Configure vimrc
In order to make the vim editor more useful, we can configure the .vimrc file.
This is my own configuration. Readers can download it and put it in the /root directory.
Link: https://pan.baidu.com/s/1yJBuDEDggjUqEt76r9difg Extraction code: imy2.
This file follows the user. When you switch to another user, it needs to be placed in the corresponding user directory.
6. Configure environment variables
Environment variables can be configured under the two files /root/.bash_rc /root/.bash_profile, just choose one.
These two files also follow the user. When you switch to another user, you switch to the environment variables of the corresponding user.
My configuration is as follows, the original code of the file does not need to be touched, just add these later.
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 export LD_LIBRARY_PATH export LANG export GOROOT export GOPATH export GOPROXY export GO111MODULE export GOCACHE export GOBIN
PS1 sets the format of the bash command prompt. You can set it to different styles according to your own preferences. You can check the specific details by yourself.
PATH sets the directory where executable commands are stored.
LANG sets the language encoding format.
The following 6 settings are all Go-related variables. Once set here, you will not need to set them when you install Go later.
After setting up, export through export.
Then save.
It will take effect after running the following command:
source .bashrc
6. Install Go
Go to https://golang.google.cn/ to download the latest Go installation package, which is currently go1.15.2.linux-amd64.tar.
After downloading, upload it to the server through the rz tool.
run:
tar xvf go1.15.2.linux-amd64.tar -C .
Because we have configured environment variables before, we only need to decompress it here.
Run the following command. If the go version number is output, the installation is successful.
go version
7.vim install Go plug-in
In order to use vim for Go programming more conveniently, you can install the vim-go plug-in, which integrates many Go tools.
Run the command:
yum install git git clone https://github.com/fatih/vim-go.git ~/.vim/pack/plugins/start/vim-go vim: GoInstallBinaries 等待安装
After installation, we can happily write code.
8. Summary
Using a Linux system to develop Go programs may still be a challenge for some people, but these basic settings and steps we provide can help you get started easily. With just some time and effort, you can make your Linux server a great helper for developing Go programs. Whether you're a newbie or an experienced developer, you'll benefit from this introductory tutorial.
The above is the detailed content of Make Linux server a good helper for Go developers. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

The reasons for the installation of VS Code extensions may be: network instability, insufficient permissions, system compatibility issues, VS Code version is too old, antivirus software or firewall interference. By checking network connections, permissions, log files, updating VS Code, disabling security software, and restarting VS Code or computers, you can gradually troubleshoot and resolve issues.

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

vscode built-in terminal is a development tool that allows running commands and scripts within the editor to simplify the development process. How to use vscode terminal: Open the terminal with the shortcut key (Ctrl/Cmd). Enter a command or run the script. Use hotkeys (such as Ctrl L to clear the terminal). Change the working directory (such as the cd command). Advanced features include debug mode, automatic code snippet completion, and interactive command history.

Writing code in Visual Studio Code (VSCode) is simple and easy to use. Just install VSCode, create a project, select a language, create a file, write code, save and run it. The advantages of VSCode include cross-platform, free and open source, powerful features, rich extensions, and lightweight and fast.

VS Code is available on Mac. It has powerful extensions, Git integration, terminal and debugger, and also offers a wealth of setup options. However, for particularly large projects or highly professional development, VS Code may have performance or functional limitations.
