Masterminds / glide

Package Management for Golang
https://glide.sh
Other
8.15k stars 541 forks source link

Build error when referencing cloud.google.com/go/storage #847

Open l3x opened 7 years ago

l3x commented 7 years ago

Looks like glide is pulling from a different repo than go get uses for the Google Cloud storage package.

$ glide install
$ go build
# <MY_PROJECT>/vendor/cloud.google.com/go/storage
vendor/cloud.google.com/go/storage/copy.go:84: cannot use res.TotalBytesRewritten (type int64) as type uint64 in argument to c.ProgressFunc
vendor/cloud.google.com/go/storage/copy.go:84: cannot use res.ObjectSize (type int64) as type uint64 in argument to c.ProgressFunc

Now, replace the go api folders in vendor (installed by glide) with those from go get command:

$ cp -r $GOPATH/src/cloud.google.com/go/ $MY_PROJECT_DIR/vendor/cloud.google.com/go/
$ go build
$ # No build error!

Snippet from glide.lock:

- name: google.golang.org/api
  version: 324744a33f1f37e63dd1695cfb3ec9a3e4a1cb05
  subpackages:
  - gensupport
  - googleapi
  - googleapi/internal/uritemplates
  - googleapi/transport
  - internal
  - iterator
  - option
  - storage/v1
  - transport

... which seem to be almost identical to files downloaded by go get -d cloud.google.com/go/storage ... but older.

FILE: go/storage/copy.go

The code with error (from google.golang.org/api):

c.ProgressFunc(uint64(res.TotalBytesRewritten), res.ObjectSize)

The code without the error (from cloud.google.com/go/storage):

c.ProgressFunc(res.TotalBytesRewritten, res.ObjectSize)
rohanthewiz commented 7 years ago

I had a similar error when referencing google cloud. Now this needs to be a feature request, but Glide Cache was the issue. Some of the core golang packages do not use semantic versioning which makes it difficult for Glide to know when to update the cache. For example golang.org/x/net is a huge culprit. Manually clear the cache for any suspect packages (let me know if there is a better way to do this -- that's the feature request - perhaps a time expiry like 2 weeks would be nice).

Anyway here is how I cleared the cache for golang.org/x/net. rm -rf ~/.glide/cache/src/https-golang.org-x-net. Perhaps do that for all golang and google packages. You will have to clear those entries from your glide.lock too, and hopefully you don't have any hashes for those explicit in your glide.yaml. Hope that helps!