1
0

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.

【golang環境構築】とりあえずhello worldまで

Last updated at Posted at 2019-07-22

参考にさせて頂いた記事

環境

OS:macOS Mojave
シェル:zsh

環境構築手順

手順1:goのインストール

Homebrewで入れる

$ brew update
$ brew install go

手順2:workspace作成

どうやらworkspaseを作成しそこにpathを通さなければいけないらしい

$ cd workspace
$ mkdir -p go/{src,bin,pkg}

.zshrcに以下を追加

  • /usr/local/bin/go の場所は $ which go で確認する
export GOPATH=$HOME/workspace/go
export GOROOT=/usr/local/opt/go/libexec
export PATH="$PATH:$GOROOT/bin:$GOPATH/bin"

手順3:hello worldを書く

$ cd ~/workspace/go/src
$ mkdir hello
$ cd hello
$ vim hello.go
hello.go
package main

import "fmt"

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

$ go build
$ ./hello
hello, world

以上、とりあえずhello worldまで。
次回から色々と環境を整えたい。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?