LoginSignup
6
6

More than 5 years have passed since last update.

お盆なのでGo言語を触ってみた 〜 hello, world 編 〜

Posted at

お盆休みなのでなにか新しいことを...と思って Go を触りました.
Mac だと brew で一発でインストールできました.便利ですね.

次は簡単なスクリプトをなにか作りたいと思います.

作業ログ


[issei@zion] ~ $ brew install go
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/go-1.3.mavericks.bottle.tar.gz
######################################################################## 100.0%
==> Pouring go-1.3.mavericks.bottle.tar.gz
==> Caveats
As of go 1.2, a valid GOPATH is required to use the `go get` command:
  http://golang.org/doc/code.html#GOPATH

`go vet` and `go doc` are now part of the go.tools sub repo:
  http://golang.org/doc/go1.2#go_tools_godoc

To get `go vet` and `go doc` run:
  go get code.google.com/p/go.tools/cmd/godoc
  go get code.google.com/p/go.tools/cmd/vet

You may wish to add the GOROOT-based install location to your PATH:
  export PATH=$PATH:/usr/local/opt/go/libexec/bin

Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

zsh completion has been installed to:
  /usr/local/share/zsh/site-functions
==> Summary
?  /usr/local/Cellar/go/1.3: 4339 files, 114M
[issei@zion] ~ $ go -v
flag provided but not defined: -v
Go is a tool for managing Go source code.

Usage:

        go command [arguments]

The commands are:

    build       compile packages and dependencies
    clean       remove object files
    env         print Go environment information
    fix         run go tool fix on packages
    fmt         run gofmt on package sources
    get         download and install packages and dependencies
    install     compile and install packages and dependencies
    list        list packages
    run         compile and run Go program
    test        test packages
    tool        run specified go tool
    version     print Go version
    vet         run go tool vet on packages

Use "go help [command]" for more information about a command.

Additional help topics:

    c           calling between Go and C
    filetype    file types
    gopath      GOPATH environment variable
    importpath  import path syntax
    packages    description of package lists
    testflag    description of testing flags
    testfunc    description of testing functions

Use "go help [topic]" for more information about that topic.

[issei@zion] ~ $ mkdir -p tmp/golang/hello
[issei@zion] ~ $ cd tmp/golang/hello/
[issei@zion] ~/tmp/golang/hello $ vi hello.go
[issei@zion] ~/tmp/golang/hello $ cat hello.go
package main

import "fmt"

func main() {
    fmt.Printf("hello, world\n")
}
[issei@zion] ~/tmp/golang/hello $ go run hello.go
hello, world
6
6
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
6
6