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

x/tools/cmd/goimports: adds redundant alias to package paths containing hyphen/dash #46635

Open
perrydunn opened this issue Jun 7, 2021 · 7 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@perrydunn
Copy link

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

$ go version
go version go1.14.14 linux/amd64

Does this issue reproduce with the latest release?

Yes (compiled with go1.16.5 too)

$ git log -n 1
commit 1225b6f53f675b0732bdf025af585b173de322ec (HEAD -> master, origin/master, origin/HEAD)

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/peregrine/.cache/go-build"
GOENV="/home/peregrine/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/peregrine/go:/home/peregrine/core3:/home/peregrine/core3/src/plz-out/go:/home/peregrine/core3/src/plz-out/gen/third_party/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/tm/tools/go/1.14.14/usr/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/tm/tools/go/1.14.14/usr/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="cc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/peregrine/go/src/golang.org/x/tools/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-build730235714=/tmp/go-build -gno-record-gcc-switches"

What did you do?

https://play.golang.org/p/8VOphLYHxto

What did you expect to see?

No redundant alias

What did you see instead?

Redundant alias added

@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Jun 7, 2021
@gopherbot gopherbot added this to the Unreleased milestone Jun 7, 2021
@cherrymui cherrymui added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 7, 2021
@cherrymui
Copy link
Member

cc @heschi @bradfitz

@heschi
Copy link
Contributor

heschi commented Jun 7, 2021

goimports has a hardcoded rule for go- prefixes; I suppose it could expand to cover golang-. Other than that, this is working as intended.

@perrydunn
Copy link
Author

Thanks. Will these rules be documented (so that, for example, people coming up with names can bear them in mind)? If they're already documented, I apologise, though I haven't been able to find such references.

@heschi
Copy link
Contributor

heschi commented Jun 9, 2021

It's not documented anywhere, and I suppose it wouldn't hurt if there's a reasonable place to put it. None occur to me offhand though. Is there somewhere in particular you would have expected to find a description?

@perrydunn
Copy link
Author

Perhaps in the godoc overview?

@dsh2dsh
Copy link

dsh2dsh commented Jul 27, 2023

Wow! At least I found the answer, why I'm getting

import (
	"log"

	dotenv "github.com/dsh2dsh/expx-dotenv"
)

instead of

import (
	"log"

	"github.com/dsh2dsh/expx-dotenv"
)

It really should be documented somewhere. Hmm... now I have a question. Why does it add redundant alias? I thought Go imports github.com/dsh2dsh/expx-dotenv and makes it accessible as dotenv by default? Yes, I just tried and can confirm it works without alias. Could somebody explain the reason or give a link to an explanation? Thanks.

@heschi
Copy link
Contributor

heschi commented Jul 27, 2023

See #28428.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

5 participants