우분투 18.04 에서 진행하였습니다.
1) default utility install
sudo apt install net-tools
sudo apt install build-essential
sudo apt install vim
sudo apt install git
sudo apt install mercurial
sudo apt install ssh
sudo apt install curl
2) golang 1.13.8 설치
wget https://dl.google.com/go/go1.13.8.linux-amd64.tar.gz
tar xvzf go1.13.8.linux-amd64.tar.gz
sudo mv go /usr/local/go
3) go 환경설정
vi .bashrc
export GO=/usr/local/go
export PATH=$GO/bin:$PATH
export GOROOT=$GO
export GOPATH=$HOME/golang
export PATH=$PATH:$GOPATH/bin
bash 적용
source ~/.bashrc
2-0) mercurial 설치
sudo apt install mercurial
2) vim-go 설치
console
cd ~/.vim ; mkdir autoload ; mkdir bundle ;cd autoload ; curl -LSso pathogen.vim https://tpo.pe/pathogen.vim ; cd ~/.vim/bundle ; git clone https://github.com/fatih/vim-go.git ; echo "execute pathogen#infect() filetype plugin indent on" >> ~/.vimrc; git clone https://github.com/vim-airline/vim-airline.git ~/.vim/bundle/vim-airline ; git clone https://github.com/scrooloose/nerdtree.git ~/.vim/bundle/nerdtree
vi command mode 에서
GoInstallBinaries -> 실행하면
설치완료
3) vimrc 에 go script 추가
" for Golang
set updatetime=100
" 저장할 때 자동으로 formatting 및 import
let g:go_fmt_command = "goimports"
let g:go_list_type = "quickfix"
let g:go_addtags_transform = "camelcase"
let g:go_autodetect_gopath = 1
let g:go_highlight_types = 1
let g:go_highlight_fields = 1
let g:go_highlight_functions = 1
let g:go_highlight_function_calls = 1
let g:go_highlight_extra_types = 1
let g:go_highlight_generate_tags = 1
let g:go_highlight_operators = 1
let g:go_auto_type_info = 1
let g:go_auto_sameids = 1
" quickfix 이동 및 open/close
nnoremap <C-n> :cnext<CR>
nnoremap <C-p> :cprevious<CR>
nnoremap <LocalLeader>q :call ToggleQuickfixList()<CR>
" 테스트 커버리지 검사 및 색깔 표시 토글
nnoremap <LocalLeader>c :GoCoverageToggle<CR>
" 자주 쓰는 기능들
autocmd FileType go nnoremap <Tab>b :GoBuild<CR>
autocmd FileType go nnoremap <Tab>r :GoRun<CR>
autocmd FileType go nnoremap <Tab><Tab>r :GoRun %<CR>
autocmd FileType go nnoremap <Tab>t :GoTest<CR>
autocmd FileType go nnoremap <Tab><Tab>t :GoTestFunc<CR>
autocmd FileType go nnoremap <Tab>c :GoCoverageToggle<CR>