我想为使用go
构建的OSS项目做出贡献,但我很难编译它。看起来好像我失去了一些明显的东西。无法构建开源项目
我认为这个问题与我的电脑上安装的go
而不是项目本身有关,因此我将它发布到StackOverflow上,而不是项目的“问题”部分。
以下是我正在做的事情。
我使用
homebrew
安装go
:$ brew install go Updating Homebrew... ==> Auto-updated Homebrew! Updated 1 tap (homebrew/core). ==> Updated Formulae libebml ==> Downloading https://homebrew.bintray.com/bottles/go-1.8.3.sierra.bottle.tar.gz Already downloaded: /Users/gmile/Library/Caches/Homebrew/go-1.8.3.sierra.bottle.tar.gz ==> Pouring go-1.8.3.sierra.bottle.tar.gz ==> Caveats A valid GOPATH is required to use the `go get` command. If $GOPATH is not specified, $HOME/go will be used by default: https://golang.org/doc/code.html#GOPATH You may wish to add the GOROOT-based install location to your PATH: export PATH=$PATH:/usr/local/opt/go/libexec/bin ==> Summary /usr/local/Cellar/go/1.8.3: 7,035 files, 282.0MB $
然后我克隆回购:
$ hub clone lucapette/fakedata
我跑
make setup
(每条指令),起初没成功完成:$ make setup go get -u github.com/alecthomas/gometalinter gometalinter --install make: gometalinter: No such file or directory make: *** [setup] Error 1 $
我想这是因为
gometalinter
是无处我$PATH
,因此增加了它(我使用fish-shell):$ set fish_user_paths /Users/gmile/go/bin
运行
make setup
现在似乎已经成功。这是输出:$ make setup go get -u github.com/alecthomas/gometalinter gometalinter --install Installing: aligncheck deadcode dupl errcheck gas goconst gocyclo goimports golint gosimple gotype ineffassign interfacer lll megacheck misspell safesql staticcheck structcheck unconvert unparam unused varcheck $
运行
make build
失败:$ make build go build main.go:11:2: cannot find package"github.com/lucapette/fakedata/pkg/fakedata" in any of: /usr/local/Cellar/go/1.8.3/libexec/src/github.com/lucapette/fakedata/pkg/fakedata (from $GOROOT) /Users/gmile/go/src/github.com/lucapette/fakedata/pkg/fakedata (from $GOPATH) main.go:12:2: cannot find package "github.com/spf13/pflag" in any of: /usr/local/Cellar/go/1.8.3/libexec/src/github.com/spf13/pflag (from $GOROOT) /Users/gmile/go/src/github.com/spf13/pflag (from $GOPATH) make: *** [build] Error 1 $
因此,无论Contributing方针是不完整的,或者说我缺少明显的东西有关安装和管理去包。
谢谢!这有帮助。 – gmile