In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to install the go language in Fedora, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!
Go is designed as a system programming language for giant central servers equipped with Web servers, storage clusters or similar purposes. for the field of high-performance distributed systems, Go language is undoubtedly more efficient than most other languages. It provides massive parallelism support, which is perfect for the development of game servers.
Install Go on Fedora
Fedora can easily and quickly install the Go language through the official library.
$sudo dnf install-y golang$ go versiongo version go1.12.7 linux/amd64
With Go installed, let's write a simple program, compile and run it.
The first Go program
Let's write a wave of "Hello, World!" in Go. First create the main.go file, and then enter or copy the following.
Package mainimport "fmt" func main () {fmt.Println ("Hello, World!")}
It is easy to run this program.
$go run main.goHello, World!
Go compiles main.go into binaries in a temporary directory and executes it, and then deletes the temporary directory. This command is ideal for running programs quickly during development, and it also highlights the compilation speed of Go.
Compiling an executable program is as simple as running it. $go build main.go$. / mainHello, World! Modules that use Go
Go 1.11,1.12 introduced initial support for modules. The module can be used to manage various dependency packages for the application. Go explicitly defines the version of the dependent package through the go.mod and go.sum files.
To demonstrate how to use the module, let's add a dependency to the hello world program.
Before changing the code, you need to initialize the module.
$go mod init helloworldgo: creating new go.mod: module helloworld$ lsgo.mod main main.go
Then modify the main.go file as follows.
Package mainimport "github.com/fatih/color" func main () {color.Blue ("Hello, World!")}
In the modified main.go, instead of using the standard library fmt to print "Hello, World!", it uses a third-party library to print colored fonts.
Let's run the new version of the program.
$go run main.goHello, World! Because the program relies on the github.com/fatih/color library, it needs to download all dependent packages before compiling. Then add the dependent packages to the go.mod and record their version numbers and hash values in the go.sum. The above is all the contents of the article "how to install GE language in Fedora". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.