LoginSignup
0
0

More than 3 years have passed since last update.

環境構築, Buildまで -Go編-

Posted at

Goについて

静的型付けプログラミング言語として急速に人気が向上しているGo言語(Golang)。

1. インストール

go コマンドを使用する。
正常にインストールされていたら、以下のような結果が表示がされます。

Go is a tool for managing Go source code.

Usage:

    go <command> [arguments]

The commands are:

    bug         start a bug report
    build       compile packages and dependencies
    clean       remove object files and cached files
    doc         show documentation for package or symbol
    env         print Go environment information
    fix         update packages to use new APIs
    fmt         gofmt (reformat) package sources
    generate    generate Go files by processing source
    get         download and install packages and dependencies
    install     compile and install packages and dependencies
    list        list packages or modules
    mod         module maintenance
    run         compile and run Go program
    test        test packages
    tool        run specified go tool
    version     print Go version
    vet         report likely mistakes in packages

Use "go help <command>" for more information about a command.

2. 実際にコードをBuild

package main

import "fmt"

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

Go言語はPHPやperlなどのインタプリタ言語とは違い、コンパイル言語です。
ファイルの実行をする前に必ずコンパイルをして、実行可能な状態にしなければなりません。

go build hello.go

//コンパイルが完了すると、「hello」というファイルが作成されます。
./hello

web業界出身だとPHPやRuby、javascriptといったコンパイルの必要がないインタプリタ言語がメインなので、コンパイル言語かつ静的型付け言語のGoを敬遠しがちかもしれません。が、習得は比較的簡単な言語といわれています。

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