I ran in to this error when attempting to add this import to my Go code:
assistedv1beta1 "github.com/openshift/assisted-service/api/v1beta1"
As you can see Goland fails to import it, but even when clicking the “Sync dependencies” it did not work. So I tried to fix it from the terminal:
$ go mod tidy
go: finding module for package github.com/openshift/assisted-service/api/v1beta1
go: found github.com/openshift/assisted-service/api/v1beta1 in github.com/openshift/assisted-service/api v0.0.0-20230328104027-c12a024ee43b
go: downloading github.com/openshift/assisted-service/models v0.0.0
gitlab.cee.redhat.com/cnf/cnf-gotests/test/ran/ztp/ranztphelper imports
github.com/openshift/assisted-service/api/v1beta1 imports
github.com/openshift/assisted-service/models: reading github.com/openshift/assisted-service/models/models/go.mod at revision models/v0.0.0: unknown revision models/v0.0.0
Mario Vázquez was kind to assist me solve this:
I tried this:
go clean -modcache
and then:
go mod tidy
but still got the error.
So Mario suggested to add these lines directly to go.mod:
require (
github.com/onsi/ginkgo/v2 v2.5.1
github.com/onsi/gomega v1.24.0
...
github.com/openshift/assisted-service/api v0.0.0
github.com/openshift/assisted-service/models v0.0.0
...
replace (
...
github.com/openshift/api => github.com/openshift/api v0.0.0-20220525145417-ee5b62754c68 // release-4.11
github.com/openshift/assisted-service/api => github.com/openshift/assisted-service/api v0.0.0-20220928142635-a40422bdea61
github.com/openshift/assisted-service/models => github.com/openshift/assisted-service/models v0.0.0-20220928142635-a40422bdea61
...
)
Then go mod tidy
Worked!