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/imports: Removes comments if it doesn't see "package" #8637

Open
gopherbot opened this issue Sep 3, 2014 · 1 comment
Open

x/tools/imports: Removes comments if it doesn't see "package" #8637

gopherbot opened this issue Sep 3, 2014 · 1 comment
Milestone

Comments

@gopherbot
Copy link

@gopherbot gopherbot commented Sep 3, 2014

$ printf '// i am precious\n' >i.go && goimports -d i.go
diff i.go gofmt/i.go
--- /home/tv/tmp/gofmt524290255 2014-09-03 11:33:53.118042810 -0700
+++ /home/tv/tmp/gofmt219767778 2014-09-03 11:33:53.118042810 -0700
@@ -1 +1 @@
-// i am precious
+
$ gofmt -d i.go 
i.go:1:18: expected 'package', found 'EOF'

$ printf '// i am precious\nfunc f() {}' >i.go && goimports -d i.go
diff i.go gofmt/i.go
--- /home/tv/tmp/gofmt433476709 2014-09-03 11:36:09.002716626 -0700
+++ /home/tv/tmp/gofmt636561536 2014-09-03 11:36:09.002716626 -0700
@@ -1,2 +1 @@
-// i am precious
 func f() {}
\ No newline at end of file

I'm ok with getting an error about invalid Go, or having a still-invalid file that
preserves the comments. I am not ok with losing my input.

This is extra annoying when goimports is hooked into editor save, and I move a
documented function into a new file.
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Sep 3, 2014

Comment 1:

Labels changed: added repo-tools, release-none.

@bradfitz bradfitz removed the new label Dec 18, 2014
@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@rsc rsc removed the release-none label Apr 10, 2015
@rsc rsc changed the title go.tools/imports: Removes comments if it doesn't see "package" x/tools/imports: Removes comments if it doesn't see "package" Apr 14, 2015
@rsc rsc modified the milestones: Unreleased, Unplanned Apr 14, 2015
@rsc rsc removed the repo-tools label Apr 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants