Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- maven
- 그래픽카드
- Docker
- centos
- django
- ThingPlug
- GTK
- Big-Data
- OpenSOC
- DBMS
- Cisco
- VNC
- Apache Metron
- HTML
- 리눅스
- Python
- Windows 10
- ubuntu
- MVC
- apache spark
- golang
- db
- Notepad++
- 오버워치
- gns3
- IOT
- Linux
Archives
- Today
- Total
¡Hola, Mondo!
[CentOS] golang , vim-go 설치 본문
*CentOS 7
1. golang install
1-1. golang 설치
: go verseion - 1.6
cd /usr/local
sudo wget https://storage.googleapis.com/golang/go1.6.linux-amd64.tar.gz
sudo tar xvfz go1.6.linux-amd64.tar.gz
sudo rm -rf go1.6.linux-amd64.tar.gz
1-2. 환경변수 설정
- /etc/profile.d 디렉토리안에 파일은 시스템이 시작될 때, 자동으로 실행된다.
- GOROOT : golang 설치 디렉토리
- GOPATH : 작성할 go 소스코드와 패키지, 바이너리가 위치할 디렉토리로써 자신이 작업하기 편한 위치로 지정
- GOBIN : GOPATH 내에 바이너리 디렉토리
vim /etc/profile.d/go.sh
source /etc/profile.d/go.sh
mkdir -p /home/UserName/workspace/GoApp
mkdir /home/UserName/workspace/GoApp/bin
2. vim-go install
2-1. vim 패키지 매니저 - pathogen
이 중 vim-go가 가장 간단히 설치되는 pathogen를 설치한다.
mkdir -p ~/.vim/autoload ~/.vim/bundle
cd ~/.vim/autoload
curl -LSso pathogen.vim https://tpo.pe/pathogen.vim
vim ~/.vimrc
2-2. vim-go
cd ~/.vim/bundle
git clone https://github.com/fatih/vim-go.git
yum install -y mercurial
vim
3. YouCompleteMe
: 자동완성을 위한 플러그인
yum -y install python-devel python3-devel automake gcc gcc-c++ kernel-devel cmake clang
yum groupinstall "Development Tools"
cd ~/.vim/bundle
git clone https://github.com/Valloric/YouCompleteMe.git
cd YouCompleteMe
git submodule update --init --recursive
./install.py
4. 사용법
//실행
:GoRun
:GoRun
//빌드
:GoBuild
:GoBuild
//$GOBIN에 바이너리 생성
:GoInstall
:GoInstall
//(go 문서) 문서를 볼 패키지이름이나 패키지의 함수이름 첫글자에 커서를 둔다.
:GoDoc
:GoDoc
//(go 변수/함수 정의) 정의 부분을 볼 함수나 변수 이름 첫글자에 커서를 둔다.
:GoDef
:GoDef
//자동 줄맞춤, 들여쓰기
:GoFmt
:GoFmt
//패키지 자동 임포트
:GoImports
:GoImports
5. 단축키 매핑
vim ~/.vimrc
f5 = GoRun
f7 = GoBuild
//// <c->는 Ctrl 키
ctrl+f = GoFmt
ctrl+i = GoImports
ctrl+f = GoFmt
ctrl+i = GoImports
////<leader>는 \
\r = go run
\b = go build
\r = go run
\b = go build
vim mapping key | 대응되는 key |
---|---|
<c-1> <leader> <BS> | Ctrl+1 \ Backspace |
<Tab> | Tab |
<CR> | Enter |
<Enter> | Enter |
<Return> | Enter |
<Esc> | Escape |
<Space> | Space |
<Up> | Up arrow |
<Down> | Down arrow |
<Left> | Left arrow |
<Right> | Right arrow |
<F1> - <F12> | Function keys 1 to 12 |
#1, #2..#9,#0 | Function keys F1 to F9, F10 |
<Insert> | Insert |
<Del> | Delete |
<Home> | Home |
<End> | End |
<PageUp> | Page-Up |
<PageDown> | Page-Down |
'Programming > Go' 카테고리의 다른 글
Json Data to Go Struct : unmarshal vs decode (0) | 2016.09.07 |
---|---|
go tool pprof (0) | 2016.06.30 |
Golang 공부 참고 사이트 (0) | 2016.06.10 |
Go Concurrency (0) | 2016.06.10 |
Comments