Debian11下安装go语言开发包

Debian11下安装go语言开发包

从下列网址下载最新linux版本软件包,当前最新版本是1.19.2

https://golang.google.cn

wget https://golang.google.cn/dl/go1.19.2.linux-amd64.tar.gz

将软件包解压到/usr/local下

tar -zxvf go1.19.2.linux-amd64.tar.gz -C /usr/local/

设置PATH环境变量,在profile文件中export PATH前添加一行PATH=/usr/local/go/bin:$PATH

root@dmaster:~# vi /etc/profile

# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))

# and Bourne compatible shells (bash(1), ksh(1), ash(1), …).

if [ “$(id -u)” -eq 0 ]; then

PATH=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin”

else

PATH=”/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games”

fi

PATH=/usr/local/go/bin:$PATH

export PATH

if [ “${PS1-}” ]; then

if [ “${BASH-}” ] && [ “$BASH” != “/bin/sh” ]; then

# The file bash.bashrc already sets the default PS1.

# PS1=’h:w$ ‘

if [ -f /etc/bash.bashrc ]; then

. /etc/bash.bashrc

fi

else

if [ “$(id -u)” -eq 0 ]; then

PS1=’# ‘

else

PS1=’$ ‘

fi

fi

fi

if [ -d /etc/profile.d ]; then

for i in /etc/profile.d/*.sh; do

if [ -r $i ]; then

. $i

fi

done

unset i

fi

使配置生效

source /etc/profile

查看一下软件版本是否ok

k8ser@dmaster:~$ go version

go version go1.19.2 linux/amd64

创建一个测试程序

k8ser@dmaster:~$vim hello.go

package main

import “fmt”

func main() {

fmt.Printf(“hello, worldn”)

}

测试程序运行是否正常

k8ser@dmaster:~$ go run hello.go

hello, world

来源:大智家plus

声明:本站部分文章及图片转载于互联网,内容版权归原作者所有,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2022年9月15日
下一篇 2022年9月15日

相关推荐