search
HomeSystem TutorialLINUXMake Linux server a good helper for Go developers

Make Linux server a good helper for Go developers

Feb 13, 2024 pm 07:51 PM
linuxlinux tutoriallinux systemLinux operating systemlinux commandshell scriptembeddedlinuxGetting started with linuxlinux learning

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.

Make Linux server a good helper for Go developers
  • 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!

Statement
This article is reproduced at:良许Linux教程网. If there is any infringement, please contact admin@php.cn delete
Why is Windows commonly used for desktop computing and gaming?Why is Windows commonly used for desktop computing and gaming?Apr 27, 2025 am 12:01 AM

Windowsispreferredfordesktopcomputingandgamingdueto:1)itsvastsoftwareandgamelibrary,2)user-friendlyandcustomizableinterface,3)extensivehardwarecompatibility,and4)performanceoptimizationcapabilities,despitesomeresource-heavyandupdate-relatedissues.

The Future of Linux Software: Will Flatpak and Snap Replace Native Desktop Apps?The Future of Linux Software: Will Flatpak and Snap Replace Native Desktop Apps?Apr 25, 2025 am 09:10 AM

For years, Linux software distribution relied on native formats like DEB and RPM, deeply ingrained in each distribution's ecosystem. However, Flatpak and Snap have emerged, promising a universal approach to application packaging. This article exami

What are the differences in how Linux and Windows handle device drivers?What are the differences in how Linux and Windows handle device drivers?Apr 25, 2025 am 12:13 AM

The differences between Linux and Windows in handling device drivers are mainly reflected in the flexibility of driver management and the development environment. 1. Linux adopts a modular design, and the driver can be loaded and uninstalled dynamically. Developers need to have an in-depth understanding of the kernel mechanism. 2. Windows relies on the Microsoft ecosystem, and the driver needs to be developed through WDK and signed and certified. The development is relatively complex but ensures the stability and security of the system.

Compare and contrast the security models of Linux and Windows.Compare and contrast the security models of Linux and Windows.Apr 24, 2025 am 12:03 AM

The security models of Linux and Windows each have their own advantages. Linux provides flexibility and customizability, enabling security through user permissions, file system permissions, and SELinux/AppArmor. Windows focuses on user-friendliness and relies on WindowsDefender, UAC, firewall and BitLocker to ensure security.

How does hardware compatibility differ between Linux and Windows?How does hardware compatibility differ between Linux and Windows?Apr 23, 2025 am 12:15 AM

Linux and Windows differ in hardware compatibility: Windows has extensive driver support, and Linux depends on the community and vendors. To solve Linux compatibility problems, you can manually compile drivers, such as cloning RTL8188EU driver repository, compiling and installing; Windows users need to manage drivers to optimize performance.

What are the differences in virtualization support between Linux and Windows?What are the differences in virtualization support between Linux and Windows?Apr 22, 2025 pm 06:09 PM

The main differences between Linux and Windows in virtualization support are: 1) Linux provides KVM and Xen, with outstanding performance and flexibility, suitable for high customization environments; 2) Windows supports virtualization through Hyper-V, with a friendly interface, and is closely integrated with the Microsoft ecosystem, suitable for enterprises that rely on Microsoft software.

What are the main tasks of a Linux system administrator?What are the main tasks of a Linux system administrator?Apr 19, 2025 am 12:23 AM

The main tasks of Linux system administrators include system monitoring and performance tuning, user management, software package management, security management and backup, troubleshooting and resolution, performance optimization and best practices. 1. Use top, htop and other tools to monitor system performance and tune it. 2. Manage user accounts and permissions through useradd commands and other commands. 3. Use apt and yum to manage software packages to ensure system updates and security. 4. Configure a firewall, monitor logs, and perform data backup to ensure system security. 5. Troubleshoot and resolve through log analysis and tool use. 6. Optimize kernel parameters and application configuration, and follow best practices to improve system performance and stability.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function