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
Open

x/tools/cmd/eg: clean imports after refactoring #21328

LOZORD opened this issue Aug 6, 2017 · 4 comments
Labels
Refactoring Issues related to refactoring tools Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@LOZORD
Copy link

LOZORD 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
Copy link
Author

LOZORD commented Aug 6, 2017

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

@clairew
Copy link

clairew commented Aug 6, 2017

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

@gopherbot
Copy link
Contributor

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

@gopherbot
Copy link
Contributor

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

@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Sep 12, 2019
@stamblerre stamblerre changed the title x/tools/cmd/eg: Clean imports after refactoring x/tools/cmd/eg: clean imports after refactoring Apr 14, 2020
@adonovan adonovan added the Refactoring Issues related to refactoring tools label Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactoring Issues related to refactoring tools Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants