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, world ")

}

测试程序运行是否正常

k8ser@dmaster:~$ go run hello.go

hello, world

展开阅读全文

页面更新:2024-04-25

标签:软件包   最新版   环境变量   语言   版本   网址   文件   测试   程序   最新

1 2 3 4 5

上滑加载更多 ↓
推荐阅读:
友情链接:
更多:

本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828  

© CopyRight 2020-2024 All Rights Reserved. Powered By 71396.com 闽ICP备11008920号-4
闽公网安备35020302034903号

Top