goimports has been updated.If you've been frustrated by its speed lately, run:$ go get -u golang.org/x/tools/cmd/goimports... and things should be much nicer.Details at https://golang.org/cl/24941
Damian
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
-- Zlatko
-j
I do not use goimports. My 2c anyway: What about checking for .goimportsignore in the root of the subtree that should be skipped?
-- Zlatko
On Fri, Jul 15, 2016 at 9:49 AM, Peter Waller <pe...@pdftables.com> wrote:
> Another suggestion which might be even nicer for the implementation: if a
> directory contains `.goimportsignore`, that directory is skipped.
That would have to be in addition to a file that lists directories,
otherwise you can't skip submodules and subtree merges and the like
(external code where you don't have the ability to add a
.goimportsignore file).
Thanks Brad.I also use $GOPATH ($HOME/src) for code non-Go projects.I'd be in favour of a more automated solution to ignoring folders that don't contain any *.go files (until such time as they start using *.go).
goimports has been updated.If you've been frustrated by its speed lately, run:$ go get -u golang.org/x/tools/cmd/goimports... and things should be much nicer.Details at https://golang.org/cl/24941
Awesome!For me it brings the CPU time from 6.5s to 3s. Wall from 2.9s to 2s. A noticable improvement.One thing that still makes it slow for me (2s instead of 500ms, I just tested), is that I have several of deep trees which aren't go code in my $GOPATH/src. To name a few: linux, clang, llvm.I feel silly for asking, but any chance of having a mechanism to ignore these non-go trees, or does anyone have any other clever ideas how to avoid this?
Why not put non go code in another directory tree? That seems much simpler.
Why not put non go code in another directory tree? That seems much simpler.
hey brad, is it possible to have a ```goimports version``` so that we know what versions we currently have?
go get -u -v golang.org/x/tools/cmd/goimports
for _, pkg := range dirScan { if !strings.Contains(strings.ToLower(lastTwoComponents(pkg.importPathShort)), pkgName) { // Speed optimization to minimize disk I/O: // the last two components on disk must contain the // package name somewhere. // // This permits mismatch naming like directory // "go-foo" being package "foo", or "pkg.v3" being "pkg", // or directory "google.golang.org/api/cloudbilling/v1" // being package "cloudbilling", but doesn't // permit a directory "foo" to be package // "bar", which is strongly discouraged // anyway. There's no reason goimports needs // to be slow just to accomodate that. continue } if !canUse(filename, pkg.dir) { continue } candidates = append(candidates, pkg)}
func TestFindImportGoPath(t *testing.T) { goroot, err := ioutil.TempDir("", "goimports-") if err != nil { t.Fatal(err) } defer os.RemoveAll(goroot)
origStdlib := stdlib defer func() { stdlib = origStdlib }() stdlib = nil
withEmptyGoPath(func() { // Test against imaginary bits/bytes package in std lib bytesDir := filepath.Join(goroot, "src", "pkg", "bits", "Bytes") for _, tag := range build.Default.ReleaseTags { // Go 1.4 rearranged the GOROOT tree to remove the "pkg" path component. if tag == "go1.4" { bytesDir = filepath.Join(goroot, "src", "bits", "Bytes") } } if err := os.MkdirAll(bytesDir, 0755); err != nil { t.Fatal(err) } bytesSrcPath := filepath.Join(bytesDir, "bytes.go") bytesPkgPath := "bits/Bytes" bytesSrc := []byte(`package bytes
type Buffer2 struct {}`) if err := ioutil.WriteFile(bytesSrcPath, bytesSrc, 0775); err != nil { t.Fatal(err) } build.Default.GOROOT = goroot
got, rename, err := findImportGoPath("bytes", map[string]bool{"Buffer2": true}, "x.go") if err != nil { t.Fatal(err) } if got != bytesPkgPath || !rename { t.Errorf(`findImportGoPath("bytes", Buffer2 ...)=%q, %t, want "%s", false`, got, rename, bytesPkgPath) }
got, rename, err = findImportGoPath("bytes", map[string]bool{"Missing": true}, "x.go") if err != nil { t.Fatal(err) } if got != "" || rename { t.Errorf(`findImportGoPath("bytes", Missing ...)=%q, %t, want "", false`, got, rename) } })}
goimports has been updated.If you've been frustrated by its speed lately, run:$ go get -u golang.org/x/tools/cmd/goimports... and things should be much nicer.Details at https://golang.org/cl/24941
On Jul 19, 2016 3:16 AM, "roger peppe" <rogp...@gmail.com> wrote:
>
> On 15 July 2016 at 16:44, <dgla...@gmail.com> wrote:
> > On Thursday, July 14, 2016 at 10:34:36 PM UTC-7, bradfitz wrote:
> >>
> >> goimports has been updated.
> >>
> >> If you've been frustrated by its speed lately, run:
> >>
> >> $ go get -u golang.org/x/tools/cmd/goimports
> >>
> >> ... and things should be much nicer.
> >>
> >> Details at https://golang.org/cl/24941
> >
> >
> > In addition to all the performance work, I'm excited to see:
> >
> >> * when adding imports, add names to imports when the imported package name
> >> > doesn't match the baes of its import path. For example: > import foo
> >> "example.net/foo/v1"
> >
> > if for no other reason than that godef works better with these imports
> > (https://github.com/rogpeppe/godef/issues/40).
>
> FWIW that particular issue isn't usually a problem for the
> way that most people use godef (as an editor plugin), as
> it only affects you if you use it directly on the command line,
> something that I assume is fairly unusual.
Huh, I do see that issue when using godef in emacs. But maybe either my godef or its emacs integration is out of date.
Why not put non go code in another directory tree? That seems much simpler.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.