Go语言极简入门教程: Go Notes

20190504

最近工作上需要用到Go,发现真是容易上手的一门语言。比起JAVA的tutorial都看得头昏眼花,Go实在是很小清新了。开始学了两个周左右,项目就要贡献代码了。还是个非常新的Gopher,记一下自己走过的一些路。

  1. Go tour
    这个真是最好的入门教程了,跟着练一遍非常的清爽哈哈。
    https://tour.golang.org/list

  2. 环境配置
    环境配置很简单,这里有一个值得注意的地方
    https://stackoverflow.com/questions/7970390/what-should-be-the-values-of-gopath-and-goroot
    GOPATH is discussed in the cmd/go documentation
    https://golang.org/cmd/go/#hdr-GOPATH_environment_variable
    GOROOT is discussed in the installation instructions
    https://golang.org/doc/install#tarball_non_standard
    这是一个完整的例子:
    https://www.youtube.com/watch?v=XCsL89YtqCs

  3. Go build
    如果不在IDE的话,我们需要把Go Project进行编译来执行。这也算从python过来的小伙伴一个不太熟悉的地方。
    go install vs go build
    https://pocketgophers.com/go-install-vs-go-build/Both

  • go install and go build will compile the package in the current directory when ran without additional arguments.
  • If the package is package main, go build will place the resulting executable in the current directory. go install will put the executable in $GOPATH/bin (using the first element of $GOPATH, if you have more than one).
  • If the package is not package main, go install and go build will compile the package, displaying any errors encountered

你可能感兴趣的:(Go)