Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go mod download does not fallback to http if https is not available #36394

Open
graywolf opened this issue Jan 5, 2020 · 5 comments
Open

go mod download does not fallback to http if https is not available #36394

graywolf opened this issue Jan 5, 2020 · 5 comments

Comments

@graywolf
Copy link

@graywolf graywolf commented Jan 5, 2020

What version of Go are you using (go version)?

$ go version
go version go1.13.5 linux/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/wolf/.cache/go-build"
GOENV="/home/wolf/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/wolf/go"
GOPRIVATE=""
GOPROXY="direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/tmp/foo/go.mod"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build915742668=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Given source code:

+   $ tree .
.
├── aaa.go
└── go.mod

0 directories, 2 files
+   $ cat aaa.go
package foo

import (
        "127.0.0.1/foo/bar"
)
+   $ cat go.mod
module xxx

go 1.13

require 127.0.0.1/foo/bar v0.0.0

use sequence of commands:

+   $ nc -l 127.0.0.1 80 &
+   $ go mod download 127.0.0.1/foo/bar

What did you expect to see?

To see some output from netcat.

What did you see instead?

+   $ go mod download 127.0.0.1/foo/bar
go: 127.0.0.1/foo/bar@v0.0.0: unrecognized import path "127.0.0.1/foo/bar" (https fetch: Get https://127.0.0.1/foo/bar?go-get=1: dial tcp 127.0.0.1:443: connect: connection refused)
@graywolf graywolf changed the title go mod download does to fallback to http if https is not available go mod download does not fallback to http if https is not available Jan 5, 2020
@mvdan
Copy link
Member

@mvdan mvdan commented Jan 6, 2020

I think this might be a case of the XY problem. Why are you trying to use HTTP? Why are you trying to download a module from 127.0.0.1?

@mvdan mvdan added the WaitingForInfo label Jan 6, 2020
@graywolf
Copy link
Author

@graywolf graywolf commented Jan 6, 2020

I'm trying to explore if this suggestion https://groups.google.com/d/msg/golang-nuts/MCvH-Bivmn8/YKgbyYH2BwAJ is working for my use case or not but having really hard time figuring out how to do it locally.

@mvdan
Copy link
Member

@mvdan mvdan commented Jan 6, 2020

You can use a module proxy, like GOPROXY=http://localhost:8080. There are multiple proxy implementations out there, like general purpose ones (athens) as well as more specific ones, like https://godoc.org/github.com/rogpeppe/go-internal/goproxytest for tests.

@bcmills
Copy link
Member

@bcmills bcmills commented Jan 6, 2020

As of Go 1.14, you can also set the GOINSECURE environment variable.

(See https://tip.golang.org/cmd/go/#hdr-Environment_variables.)

@graywolf
Copy link
Author

@graywolf graywolf commented Jan 10, 2020

Thank you very much. Will download beta build of go 1.14 and explore if it helps me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.