Import package error

$ echo $GOPATH
/home/lupe/prog/go

Under /home/lupe/prog/go/src/github.com/lpvm/newest_sapo_jobs there’s:

go.mod
main.go
controllers/controller.go
models/models.go
templates/index.gohtml

Under /home/lupe/prog/go/src/github.com/lpvm/empregos_sapo_scraper there’s:

go.mod
main.go
scraper/scraper.go

This main.go is:

package main
import "github.com/lpvm/empregos_sapo_scraper/scraper"
func main() {
	scraper.Scrape()
}

The file scraper/scraper.go:

package scraper
import (
	"github.com/lpvm/newest_sapo_jobs/models"
)

When running go run main.go from the latter directory, there’s an error:

$ go run main.go
go: finding module for package github.com/lpvm/newest_sapo_jobs/models
go: found github.com/lpvm/newest_sapo_jobs/models in github.com/lpvm/newest_sapo_jobs v0.0.0-20200424210640-7bd36b493046
go: github.com/lpvm/empregos_sapo_scraper/scraper imports
github.com/lpvm/newest_sapo_jobs/models: github.com/lpvm/newest_sapo_jobs@v0.0.0-20200424210640-7bd36b493046/go.mod: verifying module: github.com/lpvm/newest_sapo_jobs@v0.0.0-20200424210640-7bd36b493046/go.mod: reading https://sum.golang.org/lookup/github.com/lpvm/newest_sapo_jobs@v0.0.0-20200424210640-7bd36b493046: 410 Gone
server response:
not found: github.com/lpvm/newest_sapo_jobs@v0.0.0-20200424210640-7bd36b493046: invalid version: git fetch -f origin refs/heads/:refs/heads/ refs/tags/:refs/tags/ in /tmp/gopath/pkg/mod/cache/vcs/b1317fd2236a1ac7a6e82f4ba99f4dd56f6632bcee6f2923d3066ac5061b7d6f: exit status 128:
fatal: could not read Username for ‘https://github.com’: terminal prompts disabled

The last piece of information that might be relevant is that I’ve unpushed a former push to github from the former package github.com/lpvm/newest_sapo_jobs.

How to solve this issue.

Another question. Since the latter package is connected the the former could it be placed as a subdirectory of this one, as:

go.mod
main.go
scraper/scraper.go
controllers/controller.go
models/models.go
templates/index.gohtml
Or would it make more sense if placed there?

There were several suggestions to solve this issue.
The one that worked for me was to set the environmental variable
GOPRIVATE=github.com/mygithubusername/*, and use it before the go run main.go or some go get command.

So, to make it permanent, added it to ~/.bashrc
export GOPRIVATE=github.com/mygithubusername/*

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.