LoginSignup
7
7

More than 5 years have passed since last update.

はじめてのGo

Last updated at Posted at 2014-07-12

最終更新日 2014年7月13日

Goの環境構築

Goをダウンロード

Screen Shot 2014-07-13 at 2.21.56.png

公式サイト、Donloadsから自分の環境に合ったものをダウンロードします。

Goの$PATHを通す

公式サイトだと以下のようになっています。

export GOROOT=$HOME/go
export PATH=$PATH:$GOROOT/bin

しかし、これだと動かない場合があるので /go がある場所を探してパスを通します。自分の場合は以下のようになっています。

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

インストールが無事にできたか確認

hello.goというファイルに以下のように書きます。

package main

import "fmt"

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

そして無事にインストールが出来ていれば以下のようになります。

$ go run hello.go
hello, world


Goデバック方法

Go便利なツール

Debugには GDB というデバッカーが使えます。

Screen Shot 2014-07-13 at 2.18.41.png

GDBのインストール

GDB : http://www.gnu.org/software/gdb/

$ cd ~/path/to/gdb-7.7
$ ./configure
$ make 
$ make install

CDBの使い方チュートリアル

Debugging Go Code with GDB : http://golang.org/doc/gdb



参考になるサイト

7
7
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
7
7