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/eg: Clean imports after refactoring #21328

Open
LOZORD opened this issue Aug 6, 2017 · 4 comments

Comments

Projects
None yet
3 participants
@LOZORD
Copy link

commented Aug 6, 2017

tl;dr: While new imports are correctly added by the refactoring, imports that are made obsolete still exist unnecessarily (and therefore break compilation). We need to run something like goimports after performing the eg transformation.

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

go version go1.8.1 darwin/amd64

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

darwin/amd64

What did you do?

Leos-MBP:~ LeoRudberg$ go build golang.org/x/tools/cmd/eg
Leos-MBP:~ LeoRudberg$ go version
go version go1.8.1 darwin/amd64
Leos-MBP:~ LeoRudberg$ cat test-eg/template.go 
package template

import (
	"errors"
	"fmt"
)

func before(s string) error { return fmt.Errorf("%s", s) }
func after(s string) error  { return errors.New(s) }
Leos-MBP:~ LeoRudberg$ cat test-eg/example.go 
package example

import (
	"fmt"
)

func Whoops(s string) error {
	return fmt.Errorf("%s", "Whoops: "+s)
}
Leos-MBP:~ LeoRudberg$ eg -t test-eg/template.go test-eg/example.go 
=== test-eg/example.go (1 matches)
package example

import (
	"fmt"
	"errors"
)

func Whoops(s string) error {
	return errors.New("Whoops: " + s)
}

What did you expect to see?

The import section for the result should only contain errors.

What did you see instead?

The import section contained errors, but also fmt unnecessarily.

@gopherbot gopherbot added this to the Unreleased milestone Aug 6, 2017

@LOZORD LOZORD changed the title x/cmd/eg: Clean imports after refactoring x/tools/cmd/eg: Clean imports after refactoring Aug 6, 2017

@LOZORD

This comment has been minimized.

Copy link
Author

commented Aug 6, 2017

At Gophercon, @Alaska started work on this I believe. @clairew also expressed interest in fixing this, too.

@clairew

This comment has been minimized.

Copy link

commented Aug 6, 2017

@LOZORD Thanks for issuing this - will take a look at what I can do!

@gopherbot

This comment has been minimized.

Copy link

commented Nov 14, 2017

Change https://golang.org/cl/77530 mentions this issue: refactor/eg: Fix all imports after modifying files.

@gopherbot

This comment has been minimized.

Copy link

commented Jun 4, 2018

Change https://golang.org/cl/116222 mentions this issue: refactor/eg: Fix all imports after modifying files.

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