How to install Golang on centos

Go 2018. 4. 12. 11:36

$>wget https://dl.google.com/go/go1.10.1.linux-amd64.tar.gz

$>sudo tar -C /usr/local -xzf go1.10.1.linux-amd64.tar.gz

$>export PATH=$PATH:/usr/local/go/bin

$>go env
...

GOPATH="/home/centos/go"

...

$>mkdir /home/centos/go

$>cd /home/centos/go

$>mkdir src pkg bin

If you want,
you can add "export PATH=$PATH:/usr/local/go/bin" on ~/.bash_profile





'Go' 카테고리의 다른 글

How to run go app in heroku by your own project (with github)  (0) 2017.02.24
LITE IDE setup  (0) 2015.01.28
cannot download, $GOPATH not set  (0) 2015.01.28
블로그 이미지

시간을 거스르는자

ytkang86@gmail.com

,


Reference: https://devcenter.heroku.com/articles/getting-started-with-go#deploy-the-app


0. Prepare your github project containing go app

this is mine: https://github.com/ytkang/golang_chat_bot

for newbee, important thing is your folder is going to be under src folder. so, there is no src or pkg folder in  github (related go structure).


if you already have $GOPATH just skip #1, 2 

1. Make some folder whatever you named, I named it "go"

$mkdir go
$cd go


2. Set gopath

go>$export GOROOT=/usr/local/go
go>$export GOPATH=`pwd`
go>$export PATH=$PATH:$GOPATH/bin


3. Login to heroku

you should install this first. 
https://devcenter.heroku.com/articles/getting-started-with-go#set-up

go>$heroku login


4. Get your project into this folder

go>$go get github.com/ytkang/golang_chat_bot

then, whatever there is an error or not,
"go/src/github.com/ytkang/golang_chat_bot" folder is created.

if you got an import like error when you "go get" then, It will be something occurred from your own module.

you should change your import path to solve this.

if you have folder and files like this,

github.com/ytkang/golang_chat_bot/chat.go
github.com/ytkang/golang_chat_bot/jarvis/jarvis.go

and if chat.go imports jarvis.go, then it should be like this

import github.com/ytkang/jarvis O
import ./jarvis X


4. Deploy to heroku!

go/src/github.com/ytkang/golang_chat_bot>$heroku create
go/src/github.com/ytkang/golang_chat_bot>$git push heroku master

if you got "reject" error something like "failed to detect set buildpack" then you should add "godep"


How to godep

$go get -u github.com/tools/godep   // install

go/src/github.com/ytkang/golang_chat_bot>$godep save  // make godep after this you got Godep folder

go/src/github.com/ytkang/golang_chat_bot>$git add -A; git commit -am "godep added" // important! you should apply this to your github

(after this, retry git push heroku master command. It should work!)


last command

go/src/github.com/ytkang/golang_chat_bot>$heroku open









'Go' 카테고리의 다른 글

How to install Golang on centos  (0) 2018.04.12
LITE IDE setup  (0) 2015.01.28
cannot download, $GOPATH not set  (0) 2015.01.28
블로그 이미지

시간을 거스르는자

ytkang86@gmail.com

,

LITE IDE setup

Go 2015. 1. 28. 12:58

https://github.com/visualfc/liteide/blob/master/liteidex/deploy/welcome/en/install.md

* MAC OS X 사용


1. ./update_pkg.sh

./update_pkg.sh 하는순간

../liteide-master/liteidex/src/golang.org/x/tools/astutil (from $GOPATH)

이런 에러를 경험한다.

일단 $GOPATH를 ~~~/liteide-master/liteidex 로 잡아준뒤

go get golang.org/x/tools/go/ast/astutil

로 패키지 설치해줌

그런뒤 실행해보면 똑같은 에러를 경험할 것이다. 자세히 보면

../liteide-master/liteidex/src/golang.org/x/tools/go/ast/astutil

설치는 여기 되어있는데 이상한데서 찾고있음

소스코드가 업데이트 중이라는데 아직 반영안됬나봄 짱나서 그냥 심링크 걸어줌

ln -s /Users/ytkang/liteide-master/liteidex/src/golang.org/x/tools/go/ast/astutil /Users/ytkang/liteide-master/liteidex/src/golang.org/x/tools/astutil


그리고 실행하면 이런 에러를 맞본다

liteidex/src/golang.org/x/tools/astutil expects import "golang.org/x/tools/go/ast/astutil"

코드 다 찾아가서 import "golang.org/x/tools/go/ast/astutil" 로 바꿔줌 (파일 2개밖에 안됨)

이제 ./update_pkg.sh 통과.


2. ./build_osx.sh

이거 할려면 QT SDK를 깔아야되는데 망할 다운로드 페이지가 열리지 않는다. QT Creator를 깔았는데 폴더 구조가 맞지 않음 ==;;

그래서 아직 진행중.. 데밋! IDE까는게 왜케 힘들어!


'Go' 카테고리의 다른 글

How to install Golang on centos  (0) 2018.04.12
How to run go app in heroku by your own project (with github)  (0) 2017.02.24
cannot download, $GOPATH not set  (0) 2015.01.28
블로그 이미지

시간을 거스르는자

ytkang86@gmail.com

,

http://golang.org/doc/code.html

이걸 따라하고나면 GOPATH는 잡혀있을 것이다.

근데 자꾸 없다고 난리리. 문제는 sudo로 실행해서 그런것!

permission 문제는 아래 명령어로 해결해준다.

sudo chown -R "$USER:" "$GOPATH"


References

1. http://stackoverflow.com/questions/24778565/go-go-get-gopath-error-when-gopath-is-set

2. http://stackoverflow.com/questions/21463261/package-download-fails-gopath-not-set-why

'Go' 카테고리의 다른 글

How to install Golang on centos  (0) 2018.04.12
How to run go app in heroku by your own project (with github)  (0) 2017.02.24
LITE IDE setup  (0) 2015.01.28
블로그 이미지

시간을 거스르는자

ytkang86@gmail.com

,