>
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
#csutom go project path
export GOPATH="/home/richard/project/project_go"
#go install path
export GOROOT=/usr/local/go
export PATH=$PATH:${GOPATH}/bin:${GOROOT}/bin
# Enable the go modules feature
export GO111MODULE=on
# Set the GOPROXY environment variable
export GOPROXY=https://goproxy.io
配置插件安装:
go get -u -v github.com/nsf/gocode
go get -u -v github.com/rogpeppe/godef
go get -u -v golang.org/x/lint/golint
//执行go mod 会把依赖拷贝过来 godef 就能找到 定义
go mod vendor
emacs 配置
;;;custom go ide
;;;代码释义用M-x godef-describe或者C-c C-d
;;;代码跳转用M-x godef-jump 或者C-c C-j
(require 'go-autocomplete)
(require 'go-eldoc)
(require 'go-mode)
(require 'auto-complete-config)
(require 'golint)
(ac-config-default)
(defun go-mode-setup ()
(go-eldoc-setup)
(setq gofmt-command "goimports")
(setq compile-command "go build -v && go test -v && go vet")
(define-key (current-local-map) "\C-c\C-c" 'compile)
(add-hook 'before-save-hook 'gofmt-before-save)
(local-set-key (kbd "M-.") 'godef-jump))
(add-hook 'go-mode-hook 'go-mode-setup)