分类 Golang 下的文章

Golang其实非常之怪异的。
好,废话不多说,我终于搞明白这些问题:

  • GOROOT: 这个就是Golang的安装路径,UNIX-like系统,一般是/usr/local/go,Windows一般就是C:\Go。 一般不需要设置。
  • GOPATH : 这个就是你的workspace,比如你放在D盘,比如哈,D:\goworks或者/home/yumin/goworks。那么,这个目录下,会有三个目录,src, bin, pkg。那么呢,你需要在环境变量里设置export GOPATH=/home/yumin/goworks,以及export PATH=$PATH:$GOROOT/bin:$GOPATH/bin。Windows同样道理,自己手动设置环境变量GOPATHD:\goworks, PATH环境变量要添加2个:C:\GO\bin(这个一般是安装golang的时候已经帮你设置了),D:\goworks\bin(需自己手动设置)。

- 阅读剩余部分 -

Golang不支持函数重载。

Why does Go not support overloading of methods and operators?

Method dispatch is simplified if it doesn't need to do type matching as well. Experience with other languages told us that having a variety of methods with the same name but different signatures was occasionally useful but that it could also be confusing and fragile in practice. Matching only by name and requiring consistency in the types was a major simplifying decision in Go's type system.

Regarding operator overloading, it seems more a convenience than an absolute requirement. Again, things are simpler without it.

- 阅读剩余部分 -