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

package main disallowed import path #35230

Closed
crusj opened this issue Oct 29, 2019 · 2 comments
Closed

package main disallowed import path #35230

crusj opened this issue Oct 29, 2019 · 2 comments

Comments

@crusj
Copy link

crusj commented Oct 29, 2019

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

$ go version
go version go1.13.3 darwin/amd64

Does this issue reproduce with the latest release?

i don't know ,first use module, mac down but linux works well with the same situation

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

$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/crusj/Library/Caches/go-build"
GOENV="/Users/crusj/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/crusj/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/crusj/go/src/micro/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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/x8/v_x56q612ml4rk7b51lmy5140000gn/T/go-build739983740=/tmp/go-build -gno-record-gcc-switches -fno-common"

go env Output

What did you do?

go run main.go

├── go.mod
├── go.sum
├── main.go
└── test
    └── test.go
main.go

package main

import (
	"fmt"
	"github.com/crusj/testmod"
	"mod/test"
)

func main() {
	fmt.Println(testmod.Hi("roberto"))
	test.T()
}

test.go

package test
func T(){
  println(111)
}

go.mod

module mod

go 1.13

require github.com/crusj/testmod v1.0.1

What did you expect to see?

111

What did you see instead?

package main
imports mod/test: disallowed import path "mod/test"

@ianlancetaylor
Copy link
Member

This is working as expected. In general import paths should either be in the standard library or should start with a domain name. In effect the go tool treats all paths starting with "mod" as being in the standard library, but none of those paths may be imported.

@crusj
Copy link
Author

crusj commented Oct 30, 2019

3q

@golang golang locked and limited conversation to collaborators Oct 29, 2020
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