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

,