3
3

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 by Example: Hello World

Posted at

Goを学ぶための gobyexample.comの和訳とメモです。

Install go

brew update
brew install go

Set Environment vairable in .bashrc or .zshrc

export GOROOT=/usr/local/opt/go/libexec
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH

hello-world.go

package main

import "fmt"

func main() {
	fmt.Println("hello world")
}

プログラムを実行するためには、上記のコードをhello-world.goに書き、go runを使う。

バイナリにコンパイルしたいときは、go buildを使う。バイナリは直接実行できる。

$ go run hello-world.go
hello world

$ go build hello-world.go
$ ls
hello-world hello-world.go

$./hello-world
hello world

ref:
https://gobyexample.com/hello-world

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?