Skip to content

x/tools/refactor/eg: Using ./... only matches one file even though there are many more #70414

@connorszczepaniak-wk

Description

@connorszczepaniak-wk

Go version

go version go1.23.3 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE='on'
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/connorszczepaniak/Library/Caches/go-build'
GOENV='/Users/connorszczepaniak/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/connorszczepaniak/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/connorszczepaniak/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/connorszczepaniak/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.3.darwin-arm64'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/connorszczepaniak/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.3.darwin-arm64/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.23.3'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/connorszczepaniak/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/path/to/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/14/dl88pgbs11766nqnslc5ry8h0000gs/T/go-build3037559288=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

I have a template looks approximately like this in abstract:

package mypkg

import (
	"testing"

	"github.com/myRepo/x/internal/a"
	"github.com/myRepo/x/internal/a/b"
)

func before(t testing.TB, widget *b.Widget, name string) string {
	return a.FunctionToReplace(t, widget, name, "", -1)
}

func after(t testing.TB, widget *b.Widget, name string) string {
	return a.NewFunction().SomethingElse(name).Another(t, widget)
}

I'm attempting to run eg -w -t template.go github.com/myRepo/... to replace all usages in this module.

What did you see happen?

When I run eg -w -t template.go ./... from the root of github.com/myRepo, I notice that only one usage gets replaced although there are many, many more in packages matched by this pattern. If I run eg -w -t template.go github.com/myRepo/x/internal/some/other/pkg, where this package contains a lot of call sites of the old function, then all of the matches appear and get replaced.

Maybe not relevant, but I noticed that for some specific packages that would be included in github.com/myRepo/..., there are errors that occur when running eg.

// when running eg -w -t template.go github.com/myRepo/x/internal/a/...
eg: template.go:11:45: cannot use widget (variable of type *b.Widget) as *b.Widget value in argument to a.FunctionToReplace

// when running eg -w -t template.go github.com/myRepo/x/internal/a/subpkg
eg: template.go:6:2: could not import github.com/myRepo/x/internal/a (package "github.com/myRepo/x/internal/a" not found)

What did you expect to see?

All call sites within the list of packages matched by github.com/myRepo/... to be replaced.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions