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

Commented import statement not ignored #22169

Closed
ajholland opened this issue Oct 6, 2017 · 2 comments
Closed

Commented import statement not ignored #22169

ajholland opened this issue Oct 6, 2017 · 2 comments

Comments

@ajholland
Copy link

ajholland commented Oct 6, 2017

Please answer these questions before submitting your issue. Thanks!

What did you do?

Two different files

package main // import "github.com/dummy"

package main 
 
import (
      "fmt"
)

func main() {
       fmt.Println("Hello")
}

What did you expect to see?

Build

This builds on Windows but not on Linux. On the first line, the comment should be ignored. It's not ignored and the build fails because it evaluates the import statement. Ideally one would never put an incorrect import statement and not on the first line with the package declaration. But also, everything should be avoided after the comment, irregardless of statement.

What did you see instead?

can't load package: package github.com/ajholland/hello: code in directory /home/alex/goWork/src/github.com/ajholland/hello expects import "github.com/dummy"

System details

go version go1.9.1 linux/amd64
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/alex/goWork"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build716432716=/tmp/go-build -gno-record-gcc-switches"
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"
GOROOT/bin/go version: go version go1.9.1 linux/amd64
GOROOT/bin/go tool compile -V: compile version go1.9.1
uname -sr: Linux 4.4.0-93-generic
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.3 LTS
Release:	16.04
Codename:	xenial
/lib/x86_64-linux-gnu/libc.so.6: GNU C Library (Ubuntu GLIBC 2.23-0ubuntu9) stable release version 2.23, by Roland McGrath et al.
gdb --version: GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
@ianlancetaylor
Copy link
Member

You have run into import path checking as documented at https://golang.org/cmd/go/#hdr-Import_path_checking .

Closing because I don't think there is a bug here.

@ajholland
Copy link
Author

You're correct, my apologies.

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