程序Linux上运行Go语言程序的指南(linux运行go)
Nowadays, Go language has become one of the most popular programming languages for developers, and this guide is about running Go program on Linux platform.
1. Download and install Go
Before running Go code on any platform, the first step is to install the language itself. To do this, the most popular way is to download and install the Go binaries:
$ wget https://dl.google.com/go/go1.14.linux-amd64.tar.gz # download Go
$ tar -xzf go1.14.linux-amd64.tar.gz # extract the files
$ sudo mv go /usr/local # move it to the proper location
After that, the installation should be completed.
2. Set your environment
Since Go compiles code in your environment, we need to set some environment variables to make sure the compiled code can find proper Go functions. You can accomplish this task with two commands:
$ export GOROOT=/usr/local/go # setup GOROOT for go commands
$ export PATH=$PATH:/usr/local/go/bin # append the go binary path to PATH
These two commands will link our current environment to the Go installation so that it can use the Go binaries.
3. Verify the setup
To further confirm our setup was successful, we can run some test code to verify the Go environment:
package main
import fmt
func main() {
fmt.Printf( Hello, Go on Linux!\n )
}
If the output shows “Hello, Go on Linux!”, then it shows that the setup is completed.
4. Write your own Go code
Now, with the environment ready, developers can begin to code with Go. Once the code is written, it can be build and ran:
$ go build myprogram.go # build the program
$ sudo ./myprogram # run the program
By following these steps, developers should be able to successfully install and run Go on Linux.
我想要获取技术服务或软件
服务范围:MySQL、ORACLE、SQLSERVER、MongoDB、PostgreSQL 、程序问题
服务方式:远程服务、电话支持、现场服务,沟通指定方式服务
技术标签:数据恢复、安装配置、数据迁移、集群容灾、异常处理、其它问题
本站部分文章参考或来源于网络,如有侵权请联系站长。
数据库远程运维 程序Linux上运行Go语言程序的指南(linux运行go)
相关文章
- go pprof命令(Go语言性能分析命令)完全攻略
- 上传文件至Linux服务器:步骤指南(上传到linux服务器)
- 改变Linux系统下环境语言设置的方法(修改linux的环境语言)
- Xen下的Linux安装之旅(xen安装linux)
- Linux入门:哪个版本最适合初学者?(linux入门哪个版本好)
- 探究Linux:以何种语言开发?(linux用什么语言写的)
- C语言与Linux系统变量之间的关系(c语言与linux变量)
- 指导Linux进程管理实验:管理计算机任务的技巧(linux进程管理实验)
- 最好最适合你的 Linux 版本(什么版本的linux)
- 如何在Linux中编写c语言程序(linux怎么编辑c语言)
- 操作Linux系统关机指南(linux语言关机)
- Linux下设置语言的操作指南(linux设置lang)
- Linux:基于C语言的操作系统(linux基于什么语言)
- Linux下删除Nginx服务器的方法(linux删除nginx)
- 在 Linux 中编写 C 语言程序(linux下编写c程序)
- 解锁Linux中的注释之谜(linux代码注释)
- Linux下如何高效调试C语言程序?(linux调试c语言程序)
- Linux支持的多语言字符集精彩展现(linux支持的字符集)
- 如何在 Linux 上挂载共享的文件夹(linux挂载共享文件夹)
- Linux 上学习Go语言,开启编程新世界(linuxgo语言)
- 简单指南:Linux下如何使用RPM包进行安装(linux下rpm安装)
- 如何在Linux上安装Go语言?——简单易懂的指南(linux安装go语言)
- 搭建高效的Linux代理服务,传输数据更快更安全(linux 代理服务)
- 轻松修改Linux默认字符集:让你的系统支持更多语言!(修改linux默认字符集)
- 学习Linux:简单易懂的语言设置(linux 语言设置)
- Go语言链接Oracle数据库的实践记录(go 链接oracle)