Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install golang language programming environment in ubuntun

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

It is believed that many inexperienced people have no idea about how to install golang language programming environment in ubuntun. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

First download the installation package for goLang using the tool curl:

Sudo curl-O https://storage.googleapis.com/golang/go1.9.2.linux-amd64.tar.gz

Then the downloaded installation package is unzipped and a compressed file is extracted via tar.

Sudo tar-xvf go1.9.2.linux-amd64.tar.gz

After unzipping, a go directory is generated.

Use the command line mv to move the directory to the directory / usr/local:

Add the bin folder in the go directory to the environment variable of ubuntu:

Echo 'export PATH=$PATH:/usr/local/go/bin' > > ~ / .profile

Source / .profile

The command line go version displays the version, indicating that the environment variable is in effect.

Use go language to implement a simple program for calculating factorial:

Package mainimport "fmt" func Factorial (n uint64) (result uint64) {if (n > 0) {result = n * Factorial (nmur1) return result} return 1} func main () {var i int = 15 fmt.Printf ("func (% d):% d", I, Factorial (uint64 (I)}

Use go build hello.go to compile to an executable file, and then execute. / hello.

After reading the above, have you mastered how to install the golang programming environment in ubuntun? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

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: 231

*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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report