ubuntu 安装go语言开发环境

u010165367 · · 2256 次点击 · · 开始浏览    
这是一个创建于 的文章,其中的信息可能已经有所发展或是发生改变。

There are many ways to configure the Go development environment on your computer, you can choose any one you like. The three most common ways are as follows.

1、Official installation packages
The Go team provides convenient installation packages in Windows, Linux, Mac
and other operating systems. The easiest way to get started.

2、Install from source code
Popular with developers who are familiar with Unix-like systems.

3、Use third-party tools
There are many third-party tools and package managers for installing Go, like apt-
get in Ubuntu and homebrew for Mac.

In case you want to install more than one version of Go in one computer, you should take a look at the tool called GVM. It is the best tool I’ve seen so far for achieving this job, otherwise you have to know how to deal with this problem by yourself.

第一种安装方法
Using GVM

  1. Make sure to install pre-requisite libraries first

sudo apt-get update
sudo apt-get install curl git mercurial make binutils bison gcc

  1. Install GVM

bash < <(curl -s https://raw.github.com/moovweb/gvm/master/binscripts/gvm-installer)

  1. Install Go

gvm install go1.2
gvm use go1.1.2 [–default]
gvm list

第二种安装方法
Install Go Binary

  1. Install required libraries

sudo apt-get install python-software-properties # 12.04
sudo add-apt-repository ppa:duh/golang
sudo apt-get update

  1. Install Go

sudo apt-get install golang

  1. export the settings you’re gonna need to bash_rc or equivalent:

export GOROOT=/usr/lib/go
export GOBIN=/usr/bin/g

第三种安装方法
From Source

  1. Dependencies

sudo apt-get update
sudo apt-get install gcc make mercurial git libc6-de

  1. Building from source

hg clone -u release https://code.google.com/p/go
cdgo/src ./all.bas

  1. The GOPATH environment variable

Go commands all rely on one important environment variable which is called GOPATH.NoticethatthisisnottheGOROOT where Go is installed. This variable points to the workspace of Go in your computer. (I use this path in my computer, if you don’t have the same directory structure, please replace by yourself.)

export GOPATH=HOME/gocodeexportPATH=PATH:$GOPATH/bin

Note:- If your Go version is greater than 1.0, you don’t have to set GOBIN,anditwillautomaticallyberelatedtoyourGOROOT/bin, which we will talk about in the next section

You can install any of the above three way. I mostly prefer using GVM. I hope it will help you.!


有疑问加站长微信联系(非本文作者)

本文来自:CSDN博客

感谢作者:u010165367

查看原文:ubuntu 安装go语言开发环境

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

2256 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传