Hello World
定番のHello Worldを作成してみる。 まず、プロジェクトを作成する。いよいよ、ソースの作成だ。$mkdir -p $GOPATH/src/example/hello
かなりシンプル。package main import "fmt" func main() { fmt.Println("Hello, World!") }
次に実行。
出来た!$pwd $HOME/go $go install example/hello $ls bin src $ls bin hello $bin/hello Hello, World!
Install
We can use apt to install go.$ sudo apt-get install golang-go
Test Program
Making Workspace
It’s easy with managing to make work space . You can use only mkdir command to make workspace.And then setting workspace.$mkdir ~/go
$vim ~/.bashrc export GOPATH=$HOME/go $source ~/.bashrc
Hello World
Try to make hello world program. At first let’s make project.Finally programming.$mkdir -p $GOPATH/src/example/hello
So simple. And then run.package main import "fmt" func main() { fmt.Println("Hello, World!") }
Good!$pwd $HOME/go $go install example/hello $ls bin src $ls bin hello $bin/hello Hello, World!