golang 开发 环境搭建

1. 操作系统以及golang安装

使用操作系统redhat7.2 x86_64为,将golang解压后拷贝到/usr/local/目录下,通常目录将是这个样子:

/usr/local/go/bin

在~/.bash_profile中添加

export GOROOT=/usr/local/go

export PATH=$PATH:$GOROOT/bin

2 gocode下载安装

golang的安装目录中自带了go和gofmt命令。gocode命令需要另行下载。在~/目录下创建目录Gopath

在Gopath目录下创建bin 、src和pkg三个目标,并在.bash_profile中添加GOPATH

export GOPATH=~/Gopath

export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

在$GOPATH/src

go get -u github.com/nsf/gocode     // (-u flag for “update”)

扫描二维码关注公众号,回复: 1119549 查看本文章

go build github.com/nsf/gocode

产生gocode

cp -rf gocode $GOPATH/bin


3. guru下载安装

首先在 $GOPATH/src 路径下建立golang.org/x 文件夹,然后到这个文件夹下执行:

 go get golang.org/x/tools/cmd/guru 

 go build golang.org/x/tools/cmd/guru

在$GOPAH/bin 下找到guru ,将其移动到/usr/bin目录下,或者直接将$GOPAH/bin加入.bashrc:

4 eclipse golang插件安装

goclipse.github.io-master.zip这个文件下载后解压将release和plugin拷贝到eclipse/


5 godef下载安装

go get -u -v github.com/rogpeppe/godef

go build github.com/rogpeppe/godef

cp godef $GOPATH/bin

6 go-vim

安装最新的vim版本

git clone https://github.com/vim/vim.git

yum install gcc-c++ ncurses-devel  (在ubuntu上使用ncurses-dev)

make 

make install

1、安装Vundle.vim

Vundle.vim的安装步骤如下:

mkdir ~/.vim/bundle

git clonehttps://github.com/gmarik/Vundle.vim.git~/.vim/bundle/Vundle.vim

创建~/.vimrc文件(如果你没有这个文件的话),在文件顶部添加有关Vundle.vim的配置:

set rtp+=~/.vim/bundle/Vundle.vim

call vundle#begin()

Plugin 'gmarik/Vundle.vim'

Plugin 'fatih/vim-go'

call vundle#end()       

在Vim内执行PluginInstall,


猜你喜欢

转载自blog.csdn.net/haolifengwang/article/details/79501040