报错格式一般如下:
../../../internal/github.com/hyperledger/fabric/protoutil/signeddata.go:16:2: cannot find package "github.com/gogo/protobuf/proto" in any of:
/usr/local/go/src/github.com/gogo/protobuf/proto (from $GOROOT)
/opt/gopath/src/github.com/gogo/protobuf/proto (from $GOPATH)
/opt/gopath/src/google.golang.org/grpc/status/status.go:37:2: cannot find package "google.golang.org/genproto/googleapis/rpc/status" in any of:
/usr/local/go/src/google.golang.org/genproto/googleapis/rpc/status (from $GOROOT)
/opt/gopath/src/google.golang.org/genproto/googleapis/rpc/status (from $GOPATH)
简单shell脚本拉取:
grep -i "cannot find package" [错误信息文件名] | awk '{print $5}' | sed 's/"/go get /' | sed 's/"//' | sh