In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
What is the method of installing Go on the CentOS 7 system, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can get something.
Here is how to install Go on a CentOS 7 system, along with how to install Go on Ubuntu 18.04. Go can be installed using either method 1 or method 2 below.
Introduction to Go
Go is an open source programming language with a novel type system that enables flexible modular program construction and makes programmers more efficient. Using the concurrency mechanism, it is easy to write programs that make full use of multicore and networked machines. As we all know, Go is efficient, clean, expressive and concise.
Go compiles quickly to machine code, but it has the convenience of garbage collection and the power of runtime reflection. It is a fast, statically typed compiled language that feels like a dynamically typed interpreting language.
How to install Go
We have two ways to install Go on CentOS 7 systems.
Method 1. Use the Go repository (for CentOS 7 only)
We will use the Go repository to ensure that we get the latest version:
Rpm-- import https://mirror.go-repo.io/centos/RPM-GPG-KEY-GO-REPO
Curl-s https://mirror.go-repo.io/centos/go-repo.repo | tee / etc/yum.repos.d/go-repo.repo
After adding the repository, install the golang package:
Sudo yum install golang
The Go binaries will be placed under / bin/go:
# which go
/ bin/go
Attachment: for Ubuntu 18.04system
For the Ubuntu 18.04 server, run:
$sudo add-apt-repository ppa:gophers/archive
$sudo apt-get update
$sudo apt-get install golang-go
Set $GOPATH:
Mkdir-p ~ / go/ {bin,pkg,src}
Echo 'export GOPATH='$HOME/go'' > > ~ / .bashrc
Echo 'export PATH='$PATH:$ {GOPATH//://bin:} / bin'' > > ~ / .bashrc
Method 2. Download Go manually
The second method involves downloading the Go file and installing it on the system.
First check the Go download page to get the latest version: https://yisu.com/linuxrj/2803.html
Ensure that wget is installed on the system:
Sudo yum install wget (for CentOS 7)
Sudo apt install wget (for Ubuntu 18.04)
Then download Go:
VER=1.9.2
Wget https://golangtc.com/static/go/1.9.2/go1.9.2.linux-amd64.tar.gz
Sudo tar-C / usr / local-xzf go1.9.2.linux-amd64.tar.gz
Rm go1.9.2.linux-amd64.tar.gz
Set the Go PATH variable:
Vim / .bashrc
Join:
Export PATH=$PATH:/usr/local/go/bin
Get the file of the PATH to update:
Source / etc/profile
Test:
Mkdir-p ~ / go/src/test
Vim ~ / go/src/test/test.go
Add print Hello Gophers message:
Package main
Import 'fmt'
Func main () {
Fmt.Printf ('Hello, Gophers\ n')
}
Build the test.go file:
Cd ~ / go/src/test
Run the binaries to test:
$. / test
Hello, Gophers
At this point, the installation of Go is complete.
What is go golang is a compiled language that can compile the code into machine code, and the compiled binaries can be deployed directly to the target machine without additional dependencies, so golang outperforms other interpretive languages and can use goroutine in golang to achieve concurrency. It provides a very elegant goroutine scheduler system that can easily generate millions of goroutine.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.