歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Ubuntu下使用Sublime Text 2搭建Go開發環境

Ubuntu下使用Sublime Text 2搭建Go開發環境

日期:2017/2/28 15:48:18   编辑:Linux教程

  大家好,這幾天搗鼓了下 golang 的環境,今天跟大家分享下心得。

  Go is an open source programming environment that makes it easy to build simple, reliable, and efficient software.   摘自 golang.org 首頁的介紹。

  Go是Google開發的一種編譯型,並發型,並具有垃圾回收功能的編程語言。

  羅伯特·格瑞史莫(Robert Griesemer),羅勃·派克(Rob Pike)及肯·湯普遜於2007年9月開始設計Go語言,Go語言是基於Inferno操作系統所開發的。Go語言於2009年11月正式宣布推出,並在Linux及Mac OS X平台上進行了實現.  摘自維基百科

  下面這個是Go的吉祥物,很可愛吧。  

  這個是Go的 hello world 代碼:

package main

import "fmt"

func main() {
fmt.Println("Hello, 世界")
}

第一眼看上去,是不是感覺很像 c 呀,接下來為大家帶來,Go開發環境的安裝。

  首先是安裝Go,這裡有很詳細的安裝說明,http://code.google.com/p/golang-china/wiki/Install 來自golang-china 這邊大家按照順序做就行,不重復造車了。這裡由於版本不同,系統不同,可以會有些差異,首先我的操作系統為 Ubuntu 64位,go源碼目錄為 $HOME/go,安裝成功後,沒有出現下面這行:

  ***You need to add /home/you/go/bin to your $PATH.***
  The compiler is6g.

  接下來是 .bashrc配置如下:

  export GOROOT=$HOME/go
  export GOARCH=amd64
  export GOOS=linux
  export GOBIN=$GOROOT/bin
  export PATH=$PATH:$GOROOT/bin

  編譯 helloworld.go 如下:

  go build helloworld.go

  運行如下:

  ./helloworld

  注意,我的 helloworld.go 文件在 $HOME 目錄下。

  上面是安裝過程中,我遇到的跟上面文章不同的。

Copyright © Linux教程網 All Rights Reserved