Skip to content

x/tools/cmd/goimports: doesn't traverse hidden files (dotfiles) #34100

@presmihaylov

Description

@presmihaylov

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

$ go version
go version go1.12.9 darwin/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/pmihaylov/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/pmihaylov/programming/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.9/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.9/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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/9v/vvj1r6_54pb855bvmtqv3wn80000gn/T/go-build618023056=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

In a go project:

  1. Create the file .gen/foo/foo.go with contents:
package foo

import "fmt"

func Foo() {
	fmt.Println("Foo")
}
  1. Create the file bar/bar.go with contents:
package bar

import "fmt"

func Bar() {
	fmt.Println("Bar")
}
  1. Create the file main.go with contents:
package main

func main() {
	foo.Foo()
	bar.Bar()
}
  1. Run goimports main.go.

What did you expect to see?

Both foo and bar packages included

What did you see instead?

Only bar package was included

It would be great if goimports traverses hidden directories as we use a .gen folder for storing auto-generated code (e.g. protobuf). Or at least to export a flag that enables this feature.

From a little tweaking, it seems that Intellij and GoLand already support this feature and that doesn't come from the integrated goimports.

NOTE: If I add the import manually, the program compiles.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions