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/gomvpkg: moving package "example/foo" rewrites imports of "example/fooooo" #21991

Closed
ericchiang opened this issue Sep 23, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@ericchiang
Copy link

commented Sep 23, 2017

Please answer these questions before submitting your issue. Thanks!

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

$ go version
go version go1.9 linux/amd64
$ cd $GOPATH/src/golang.org/x/tools/ && git rev-parse HEAD
e531a2a1c15f94033f6fa87666caeb19a688175f

Does this issue reproduce with the latest release?

Yes

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

$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/eric"
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-build199275394=/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"

What did you do?

Tried to move the package k8s.io/api, which rewrote all imports of k8s.io/apimachinery.

Reproducible example:

#!/bin/bash -e

GOPATH=$( mktemp -d )
trap "{ CODE=$?; rm -rf $GOPATH ; exit $CODE; }" EXIT

# Make three packages. "example/foo", "example/fooooo" and "example/bar".
# "example/bar" imports "example/fooooo"

mkdir -p $GOPATH/src/example/foo
mkdir -p $GOPATH/src/example/fooooo
mkdir -p $GOPATH/src/example/bar

echo "package foo" > $GOPATH/src/example/foo/foo.go
echo "package foobar" > $GOPATH/src/example/fooooo/fooooo.go


cat << EOF > $GOPATH/src/example/bar/bar.go
package bar

import _ "example/fooooo"
EOF

echo "Before gomvpkg"
go list example/...

# Renaming "example/foo" impacts "example/bar" even though "example/bar" doesn't import it.
gomvpkg -from example/foo -to example/spam

echo "After gomvpkg"
go list example/...

cat $GOPATH/src/example/bar/bar.go

This script rewrites imports of example/fooooo even though it moves example/foo.

$ ./gomvpkg.sh 
Before gomvpkg
example/bar
example/foo
example/fooooo
After gomvpkg
example/bar
example/fooooo
example/spam
package bar

// Import should be "example/fooooo" but will be renamed "example/spamfoo"
import _ "example/spamooo"

What did you expect to see?

Moving k8s.io/api, to not rewrite imports of k8s.io/apimachinery.

@gopherbot gopherbot added this to the Unreleased milestone Sep 23, 2017

@gopherbot

This comment has been minimized.

Copy link

commented Sep 24, 2017

Change https://golang.org/cl/65672 mentions this issue: cmd/gomvpkg: Only process path that are children

@golang golang locked and limited conversation to collaborators Jan 17, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.