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/importer: GOARCH=386 can't find import: "crypto/tls" #25723

Closed
gyuho opened this issue Jun 4, 2018 · 3 comments
Closed

go/importer: GOARCH=386 can't find import: "crypto/tls" #25723

gyuho opened this issue Jun 4, 2018 · 3 comments

Comments

@gyuho
Copy link
Contributor

gyuho commented Jun 4, 2018

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

go version go1.10.2 linux/amd64

Does this issue reproduce with the latest release?

Yes. Tried it with cf2c2ea.

$ cd $HOME && $HOME/go-master/bin/go version
go version devel +cf2c2ea89d Mon Jun 4 17:32:17 2018 +0000 linux/amd64

~ $ GOARCH=386 $HOME/go-master/bin/go run main.go
can't find import: "crypto/tls"

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

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/gyuho/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/gyuho/go"
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
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-build230277318=/tmp/go-build -gno-record-gcc-switches"

What did you do?

package main

import (
	"fmt"
	"go/importer"
)

func main() {
	_, err := importer.Default().Import("crypto/tls")
	if err != nil {
		fmt.Println(err)
	}
}
$ GOARCH=386 go run main.go
can't find import: "crypto/tls"

What did you expect to see?

No error.

What did you see instead?

$ GOARCH=386 go run main.go
can't find import: "crypto/tls"
@ianlancetaylor ianlancetaylor changed the title GOARCH=386 can't find import: "crypto/tls" go/importer: GOARCH=386 can't find import: "crypto/tls" Jun 4, 2018
@ianlancetaylor
Copy link
Contributor

I believe that this is working as expected. The docs for importer.Default say that it returns an Importer for the compiler that built the binary, which in this case is "gc". The docs for Importer.For say that for "gc" it returns an importer that works on installed packages. You presumably haven't installed the "crypto/tls" package for 386.

You should either use importer.For("source") or run GOARCH=386 go install crypto/tls.

Closing because I don't think there is anything to fix. Please comment if you disagree.

@gyuho
Copy link
Contributor Author

gyuho commented Jun 4, 2018

@ianlancetaylor Makes sense. Thanks for explanation! Please feel free to close it!

@gyuho
Copy link
Contributor Author

gyuho commented Jun 4, 2018

importer.For("source") worked :)

@gyuho gyuho closed this as completed Jun 4, 2018
@golang golang locked and limited conversation to collaborators Jun 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants