Bye Bye Moore

PoCソルジャーな零細事業主が作業メモを残すブログ

GOPATHがないとか言われたら

GOPATHを設定していない場合、ライブラリの導入時にエラーがでます
この場合

$ ls -dF ~/

とやってhomeを確認した上で

export GOPATH='/Users/shuzo/src'

とでもやっておけば大丈夫です。
URLは驚いた事に何でもよいらしく

$ go help gopath
The Go path is used to resolve import statements.
It is implemented by and documented in the go/build package.

Here's an example directory layout:

    GOPATH=/home/user/gocode

    /home/user/gocode/
        src/
            foo/
                bar/               (go code in package bar)
                    x.go
                quux/              (go code in package main)
                    y.go
        bin/
            quux                   (installed command)
        pkg/
            linux_amd64/
                foo/
                    bar.a          (installed package object)

Go searches each directory listed in GOPATH to find source code,
but new packages are always downloaded into the first directory
in the list.

参考もと

  • go help gopath