LoginSignup
0
0

More than 1 year has passed since last update.

ど初心者がgolangでhello worldをする

Last updated at Posted at 2021-04-27

ローカルで実行環境を用意

https://golang.org/dl/
からそれぞれ環境にあったインストーラーをダウンロード
※僕のPCはMacなのでMacOSのインストーラーをダウンロードします

# インストーラーのダウンロードができたらコマンドラインでバージョンを確認
$ go versoin
-> go version go1.16.3 darwin/amd64

このようにgoのバージョンが表示されたら成功

hello worldの準備

$ mkdir hello
$ cd hello
$ go mod init example.com/hello # modがパッケージ管理ツール?
$ touch hello.go

そしたら以下のコードをhello.goに記述

package main

import "fmt"

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

コードを実行

$ go run .
-> Hello, World!
0
0
1

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
0