4

I have a package that uses some local packages

module mycompany.com/clientname/server

go 1.14

require (
    github.com/lib/pq v1.7.0
    github.com/99designs/gqlgen v0.11.3
    github.com/vektah/gqlparser/v2 v2.0.1
    golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
    mycompany.com/clientname/models v0.0.0-00010101000000-000000000000
    mycompany.com/common/utils v0.0.0-00010101000000-000000000000
)

replace mycompany.com/common/utils => ../../common/utils

replace mycompany.com/clientname/models => ../models

the mycompany.com domain doesn't serve the package, it is just a fictional path (and I use it in my gopath ~/go/src/mycompany.com/...)

the problem is that when I run go get -u all, I want the 'valid' packages to be updated (like the github.com/lib/pq or github.com/99designs/gqlgen), but to leave the local (fictional) packages as they are.

but go get -u all just prints out the new versions, then prints the errors on the local packages and then doesn't change go.mod.

go: google.golang.org/grpc upgrade => v1.30.0
go: go.opencensus.io upgrade => v0.22.4
go: github.com/mattn/go-runewidth upgrade => v0.0.9
go: github.com/gogs/chardet upgrade => v0.0.0-20191104214054-4b6791f73a28
go: golang.org/x/text upgrade => v0.3.3
go: github.com/mitchellh/mapstructure upgrade => v1.3.2
go get all: unrecognized import path "mycompany.com/clientname/models": reading https://mycompany.com/clientname/models?go-get=1: 404 Not Found
go get all: unrecognized import path "mycompany.com/common/utils": reading https://mycompany.com/common/utils?go-get=1: 404 Not Found
microo8
  • 3,568
  • 5
  • 37
  • 67
  • 1
    Check this out! https://stackoverflow.com/questions/58305567/how-to-set-goprivate-environment-variable/58306008#58306008 – ifnotak Jul 16 '20 at 14:20
  • doesn't work :( I tried `go env -w GOPRIVATE=mycompany.com`, `go env -w GOPRIVATE='mycompany.com/*'`, `go env -w GOPRIVATE=mycompany.com/common/utils` and non of it works. it prints out the same thing `go get all: unrecognized import path "mycompany.com/common/utils": reading https://mycompany.com/common/utils?go-get=1: 404 Not Found` – microo8 Jul 17 '20 at 05:47

1 Answers1

1

The error from go get -u was a bug in the go command, fixed in the upcoming Go 1.16 release. See https://golang.org/issue/32567 for detail.

(That said, ideally you should be hosting the modules in version control and using GOPRIVATE=mycompany.com instead of slotting things in locally via replace directives.)

bcmills
  • 4,391
  • 24
  • 34