Upload
jaehoon-kim
View
125
Download
4
Embed Size (px)
DESCRIPTION
Citation preview
목차
• 개요• 설치• 프로젝트• 크로스 컴파일
개요
1. 목적 - Windows 환경에서 Go 언어를 이용하기 위한 개발 환경을 구축 ( Eclipse + GoClipse +EGit )
2. 대상 - Go 언어를 처음 접해보는 사용자 - Eclipse 를 처음 접해보는 사용자
설치 - 다운로드 및 설치
1. Go ( https://code.google.com/p/go/downloads/list?q=OpSys-Windows+Type%3DInstaller )
2. Eclipse ( ver 3.7 이상 ) ( http://www.eclipse.org/downloads/ )
3. GoClipse ( ver 0.7.6 ) ( https://code.google.com/p/goclipse/ )
( http://goclipse.googlecode.com/svn/trunk/goclipse-update-site/ )
4. EGit ( http://www.eclipse.org/egit/ )
( http://download.eclipse.org/egit/updates/ )
설치 - GoClipse
1. Help -> Install New Software...
2. Work with 항목( http://goclipse.googlecode.com/svn/trunk/goclipse-update-site )
3. Add
4. Add Repository 에서 'OK' 선택
설치 - GoClipse
1. GoClipse -> Next -> Next
2. 라이센스동의 -> Finish
3. Eclipse 재시작
* Security Warning 창은 OK 버튼 클릭
설치 - EGit
1. Help -> Install New Software...
2. Work with (http://download.eclipse.org/egit/updates/)
3. Add
4. Add Repository 에서 'OK' 선택
설치 - EGit
1. Eclipse EGit 선택 ->
Next -> Next
2. 라이센스 동의 -> Finish
3. Eclipse 재시작
설치 - 환경설정 (기본 )
1. Window -> Preferences
2. GOROOT 에 Go 가 설치된 디렉토리를 선택
3. Apply
* GOROOT 아래에 bin 디렉토리가 존재하면 , Go Tools 항목은 자동으로 채워짐
설치 - 환경설정 (GDB)
1. gdb.exe ( http://www.equation.com/servlet/equation.cmd?fa=gdb )
( http://www.drangon.org/mingw/ )
바이너리 다운로드
2. GDB Path 에 경로 추가
* Unable to get gdb version 이라 표시가 나타나는 gdb 는 디버깅 불가
설치 - 환경설정 (GDB)
1. Run->
Debug Configurations...
2. Go Application
3. 항목 Name : Debug 타이틀
Project : 디버깅을 진행 할 프로젝트
Main source file : main 메소드가 있는 파일
Arguments : 디버깅 옵션
Build configurations : DEBUG
4. Debug
설치 - 환경설정 (GoCode)
2. gocode.exe ( 자동 완성 ) ( https://code.google.com/p/goclipse/downloads/list )
( https://github.com/nsf/gocode )
소스를 직접 빌드
3. GOROOT\bin 에 복사
* Eclipse 에서는 굳이 설정을 안해도 잘 됨 .
설치 - 환경설정 (EGit)
1. Window -> Preferences
2. General ->
Network Connections ->
SSH2
3. Key Management ->
Generate RSA Key...
4. Save Private Key...
5. Apply
설치 - 환경설정 (EGit)
1. Window -> Preferences
2. Team -> Git
3. Cloning repositories : Eclipse 의 workspace 경로
4. Apply
설치 - 환경설정 (Console)
1. 한글 Windows 의 Console 은CodePage 가 949
2. UTF-8 형식으로 변경 ex)
> chcp 65001
3. 속성 -글꼴 : 래스터 글꼴 -> Lucida Console
* code page 를 변경해야 한글이 정상적으로 표시
프로젝트 - github
1. 샘플 프로젝트를 위한 git 서버로 github 를 이용
2. 프로젝트 저장소 생성
프로젝트 - Eclipse(import)
1. File -> Import
2. Git -> Projects from Git
3. URI
4. Source Git Repository : URI : 프로젝트 저장소의 주소
프로젝트 - Eclipse(import)
1. host(github) 인증 만드는 것 확인
2. Branch Selection
프로젝트 - Eclipse(import)
2. Select a wizard use for importing projects : 새로운 프로젝트 생성을 위해 Use the New Project wizard 선택
1. Local Destination : 프로젝트 다운로드 받을 위치
프로젝트 - Eclipse( 프로젝트 만들기 )
1. Go Project 생성
2. 프로젝트 생성 : bin, pkg, src 를 기본으로 생성
프로젝트 - Eclipse( 프로젝트 만들기 )
1. 파일 추가
2. Source File Type : Package Source File
: Command Source File
( Empty Main Function,
Main Function Parameters,
Simple Web Server )
: Test Source File
프로젝트 - Eclipse( 프로젝트 만들기 )
1. 패키지는 폴더로 구분
2. main 패키지 구성 : src/Sample1 과 같이 폴더 생성
3. calc 패키지 구성 : src/calc 와 같이 폴더 생성
* main 도 하나의 패키지
프로젝트 - Eclipse(git-push)
크로스 컴파일 - 준비사항
1. Go 는 개발환경에 상관없이 원하는 OS 와 CPU 타입의 binary 를 만들어 낼 수있음 .
(windows-386, MinGW 설치 )
2. 각 환경에 따른 세팅 값 ( 이외에도 몇 가지가 더 있음 )OS GOOS GOARCH
윈도우 windows 386, amd64
리눅스 linux 386, amd64, arm
맥 darwin 386, amd64
크로스 컴파일 - 준비사항
3. C:\Go\src 로 이동
4. make.bat 를 실행
5. 컴파일러 , 링커 install : arm(5), amd64(6), 386(8)
: a(assembler), c(c compiler),
g(compiler), l(linker) ex)
> go tool dist install -v cmd/6a
> go tool dist install -v cmd/6c
> go tool dist install -v cmd/6g
> go tool dist install -v cmd/6l
크로스 컴파일 - 준비사항
6. Target 환경으로 설정 변경 ex)
> set GOOS=linux
> set GOARCH=amd64
> set CGO_ENABLED=0
7. 표준 명령 , 라이브러리Install
ex)
> go tool dist install -v pkg/runtime
> go install -v -a std
크로스 컴파일 - cmd
1. binary 를 만들 OS 와 ARCH 를 지정 ex)
> set GOOS=linux
> set GOARCH=amd64
2. GOPATH 지정 : 빌드하고자 하는 프로젝트의 경로를 지정
: Sample1\bin, pkg, src
ex)
> set GOPATH=C:\Users\redef\workspace\Sample1
크로스 컴파일 - cmd
3. 패키지 build & install ex)
src> cd calc
calc> go install
: [결과물 ] pkg\linux_amd64\calc.a
4. main 패키지 build & install
ex)
src> cd Sample1
Sample1> go install
: [결과물 ] bin\linux_amd64\Sample1
크로스 컴파일 - GoClipse
1. GoClipse 에서 크로스 컴파일은 현재 가능하지 않음
2. GoClipse 이슈 목록 https://code.google.com/p/goclipse/issues/detail?id=99 https://code.google.com/p/goclipse/issues/detail?id=111
감사합니다 .
참고* http://golang.org/doc
* http://golang.org/cmd/
* http://woogyun.tistory.com/351
* http://bosoa.egloos.com/3893190
* http://www.youtube.com/watch?v=XCsL89YtqCs&feature=youtu.be
* http://www.vogella.com/articles/EGit/article.html
* https://code.google.com/p/goclipse/
* http://juhoi.tistory.com/46
* http://www.mirwing.com/2012/05/golang-cross-compiling.html
* https://code.google.com/p/go-wiki/wiki/WindowsCrossCompiling
* http://gocor.eu/how-to-install-and-setup-go-on-windows-8/
* http://richitexperience.wordpress.com/2012/10/19/goclipse_preferences/
* http://ryulib.tistory.com/182
* http://www.drangon.org/mingw/