0
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Go言語 Macにインストール

Last updated at Posted at 2018-08-20

はじめに

Go言語が一番年収が高いということでお勉強したことをまとめていきます。
その方が頭に入るし。(たぶん)
ただの備忘録になるとは思いますがあしからず。。。

インストールの前に

Playgroundがあるみたいなので、簡単なやつはここGo Playgroundで実行できるみたい。

インストール

Macの場合はHomebrewでインストールできる。

brew install go

ビルド&実行

サンプルコードを作成します。

hello.go
package main

import "fmt"

func main() {
  fmt.Println("Hello World")
}

ターミナルを開いてビルド&実行していきます。
コンパイル&ビルドするときはgo buildコマンドを実行します。

$ go build hello.go

するとhelloファイルができているはず。

$ ls
hello           hello.go

ではhelloを実行してみましょう。

$ ./hello
Hello World

Hello Worldが出力されてます!

なんか即時ビルド&実行できるらしく、その場合はgo runコマンドを実行。

$ go run hello.go
Hello World

この場合はコンパイルしたファイルは生成されないみたいです。

インストール編はここまで。
ではでは。

参考

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?