26

001 go语言开发环境配置

 4 years ago
source link: https://www.tuicool.com/articles/ZJvQbuA
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

ubuntu系统安装Go和liteide及环境配置

一、通过apt-get安装

1、安装

sudo apt-get install golang

2、设置GOPATH变量

GOPATH是扩展库的目录,Go先搜索标准库目录,然后搜索GOPATH库目录,所有的非标准库都放在GOPATH下。以GOPATH为“/home/zzh/gopath”目录为例子:

7BBZni7.png!web

image.png

(1)把export GOPATH=/home/zzh/gopath

加入到~/.bashrc文件的最后。

(2)source ~/.bashrc 重新加载配置

3MBbiyj.png!web

image.png

这样就加好了GOPATH。注意:apt-get命令安装只能安装go1.6版本现在很多开源项目都用上了1.7以上建议手动安装更高版本。

二. 压缩包安装

安装配置Golang

  • 可以从 Golang中国 这里下载,下载好后使用 sudo tar -xvzf ~/Downloads/go*.linux-amd64.tar.gz -C /usr/local/ 命令将其解压到 /usr/local/ 位置,然后配置环境变量。

  • 使用命令 vim ~/.bashrc 打开.bashrc文件,然后在最后追加下面内容:

    export GOROOT=/usr/local/go

    export PATH= n2Anqun.png!web

    GOROOT/bin

    export GOPATH=~/Go

  • 然后使用命令 source ~/.bashrc 使其生效,需要注意的是,GOPATH这个环境变量指的是之后需要存放源码的目录,我使用的是 ~/Go 目录

  • 使用 go version 以及 go env 等命令来查看是否正确安装Go

安装配置LiteIDE

  • 可以从 Golang中国 这里下载,然后将其解压到某个目录,这里我是解压到了 /opt 目录,然后在该目录下,就可以看到 liteide 目录了
  • 然后执行命令 sudo gedit /usr/share/applications/liteide.desktop
  • 然后将下面的内容写到新建的 liteide.desktop 文件中:
[Desktop Entry]
Name=liteIDE 
Comment=Integrated Development Environment 
Exec=/opt/liteide/bin/liteide
Icon=/opt/liteide/share/liteide/welcome/images/liteide400.png
Terminal=false
Type=Application
Categories=Development;IDE; 
Encoding=UTF-8
StartupNotify=true
  • 然后我们就可以搜索到LiteIDE了,将其固定到桌面,打开之后在选项中修改LiteEnv的linux64以及linux64-local这两个文件,将其中的GOROOT修改为/usr/local/go

这样就完成了LiteIDE的安装配置了

yyQB73A.png!web

image.png


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK