由于是盂兰盆节,我想尝试一下谷歌语言——Hello, World版本

因为是盂兰盆节假期,所以我想尝试些新事物,于是开始使用 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
广告
将在 10 秒后关闭
bannerAds