10

I want to import a module I have created into another project. The source code is in GitHub, in a public repo, but I get the following error when trying to import in GoLand:

go: finding module for package github.com/ambye85/gophercises/link
go: downloading github.com/ambye85/gophercises/link v0.0.0-20200323082040-d484a876f7e8
go: downloading github.com/ambye85/gophercises v0.0.0-20200323082040-d484a876f7e8
github.com/ambye85/gophercises/sitemap imports
    github.com/ambye85/gophercises/link: github.com/ambye85/gophercises/link@v0.0.0-20200323082040-d484a876f7e8: verifying module: github.com/ambye85/gophercises/link@v0.0.0-20200323082040-d484a876f7e8: reading https://sum.golang.org/lookup/github.com/ambye85/gophercises/link@v0.0.0-20200323082040-d484a876f7e8: 410 Gone
    server response:
    not found: github.com/ambye85/gophercises/link@v0.0.0-20200323082040-d484a876f7e8: invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /tmp/gopath/pkg/mod/cache/vcs/a488fe783593bd6e7b765f40dfed37c7e534d0a80ca8e1bff63e11e21f02e8fd: exit status 128:
        fatal: could not read Username for 'https://github.com': terminal prompts disabled

All the searching I have done seems to indicate that this is caused by trying to access a private repo. That is not the case here.

Does anyone know what the cause and fix is?

Output of go env:

go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/ashleyb/Library/Caches/go-build"
GOENV="/Users/ashleyb/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/ashleyb/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.14/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.14/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/pn/8n7495nd5yn6mxxthgv5ghqhtn2mwj/T/go-build279336926=/tmp/go-build -gno-record-gcc-switches -fno-common"
Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
junglie85
  • 1,243
  • 10
  • 30

1 Answers1

6

Can be fixed using:

$ git config --global --add url."git@github.com:".insteadOf "https://github.com/"

This problem may occur when you’re trying to authenticate with https but you have 2FA enabled. This can be solved by forcing git to use ssh for all interactions.

Resources:

Kamol Hasan
  • 12,218
  • 1
  • 37
  • 46