LoginSignup
2
2

More than 5 years have passed since last update.

CentOSにGo言語をインストール。Hello Worldまで。

Posted at

CentOSは以下を使用

cat /etc/system-release
CentOS release 6.5 (Final)

Go言語をインストール

こちらのリンクから最新版のURLを取得してください。
今回は1.6.2を使用

cd /usr/local/src
sudo wget https://storage.googleapis.com/golang/go1.6.2.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.6.2.linux-amd64.tar.gz

パスを読み込みます。
今回はbashの例で。

~/.bashrc
export PATH=$PATH:/usr/local/go/bin
source ~/.bashrc

これで準備は終了です。

Go言語でHello World

hello.go
package main

import "fmt"

func main() {
    fmt.Printf("hello, world\n")
}

では実行してみます。

go run hello.go
hello, world
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2