{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/13023","labels_url":"https://api.github.com/repos/golang/go/issues/13023/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/13023/comments","events_url":"https://api.github.com/repos/golang/go/issues/13023/events","html_url":"https://github.com/golang/go/issues/13023","id":112861111,"number":13023,"title":"x/tools/cmd/goimports: incorrectly adds imports for variables that match package names","user":{"login":"cep21","id":20358,"avatar_url":"https://avatars.githubusercontent.com/u/20358?v=3","gravatar_id":"","url":"https://api.github.com/users/cep21","html_url":"https://github.com/cep21","followers_url":"https://api.github.com/users/cep21/followers","following_url":"https://api.github.com/users/cep21/following{/other_user}","gists_url":"https://api.github.com/users/cep21/gists{/gist_id}","starred_url":"https://api.github.com/users/cep21/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cep21/subscriptions","organizations_url":"https://api.github.com/users/cep21/orgs","repos_url":"https://api.github.com/users/cep21/repos","events_url":"https://api.github.com/users/cep21/events{/privacy}","received_events_url":"https://api.github.com/users/cep21/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/golang/go/milestones/22","html_url":"https://github.com/golang/go/milestones/Unreleased","labels_url":"https://api.github.com/repos/golang/go/milestones/22/labels","id":1067491,"number":22,"title":"Unreleased","description":"Issues that do not affect released Go code and binaries.\r\n","creator":{"login":"rsc","id":104030,"avatar_url":"https://avatars.githubusercontent.com/u/104030?v=3","gravatar_id":"","url":"https://api.github.com/users/rsc","html_url":"https://github.com/rsc","followers_url":"https://api.github.com/users/rsc/followers","following_url":"https://api.github.com/users/rsc/following{/other_user}","gists_url":"https://api.github.com/users/rsc/gists{/gist_id}","starred_url":"https://api.github.com/users/rsc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsc/subscriptions","organizations_url":"https://api.github.com/users/rsc/orgs","repos_url":"https://api.github.com/users/rsc/repos","events_url":"https://api.github.com/users/rsc/events{/privacy}","received_events_url":"https://api.github.com/users/rsc/received_events","type":"User","site_admin":false},"open_issues":344,"closed_issues":270,"state":"open","created_at":"2015-04-14T18:48:22Z","updated_at":"2015-10-22T22:02:08Z","due_on":"2099-12-31T05:00:00Z","closed_at":null},"comments":7,"created_at":"2015-10-22T18:21:13Z","updated_at":"2015-10-22T22:33:29Z","closed_at":null,"body":"Please see the following console output as a test case.  ```log``` is a varaible defined in another file and therefor does not need a package import.  The expected behavior is for goimports to detect no issues.\r\n\r\n```\r\n11:19:35 jack@Jacks-MacBook-Pro.local:/tmp/b\r\n< go get -u golang.org/x/tools/cmd/goimports\r\n11:20:02 jack@Jacks-MacBook-Pro.local:/tmp/b\r\n< ls -la\r\ntotal 16\r\ndrwxr-xr-x   4 jack  wheel   136B Oct 22 11:18 .\r\ndrwxrwxrwt  32 root  wheel   1.1K Oct 22 11:17 ..\r\n-rw-r--r--   1 jack  staff   111B Oct 22 11:18 a.go\r\n-rw-r--r--   1 jack  staff    82B Oct 22 11:18 a_test.go\r\n11:20:05 jack@Jacks-MacBook-Pro.local:/tmp/b\r\n< cat a.go \r\npackage main\r\n\r\nimport \"github.com/Sirupsen/logrus\"\r\n\r\nvar log *logrus.Logger\r\n\r\nfunc init() {\r\n\tlog = logrus.New()\r\n}\r\n11:20:07 jack@Jacks-MacBook-Pro.local:/tmp/b\r\n< cat a_test.go \r\npackage main\r\n\r\nimport \"testing\"\r\n\r\nfunc TestB(t *testing.T) {\r\n\tlog.Printf(\"Hello\")\r\n}\r\n11:20:09 jack@Jacks-MacBook-Pro.local:/tmp/b\r\n< goimports -d .\r\ndiff a_test.go gofmt/a_test.go\r\n--- /var/folders/5r/x8pdxnqs0sdg7w_262278m800000gn/T/gofmt282742701\t2015-10-22 11:20:12.000000000 -0700\r\n+++ /var/folders/5r/x8pdxnqs0sdg7w_262278m800000gn/T/gofmt424960296\t2015-10-22 11:20:12.000000000 -0700\r\n@@ -1,6 +1,9 @@\r\n package main\r\n \r\n-import \"testing\"\r\n+import (\r\n+\t\"log\"\r\n+\t\"testing\"\r\n+)\r\n \r\n func TestB(t *testing.T) {\r\n \tlog.Printf(\"Hello\")\r\n```"},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/150374889","html_url":"https://github.com/golang/go/issues/13023#issuecomment-150374889","issue_url":"https://api.github.com/repos/golang/go/issues/13023","id":150374889,"user":{"login":"mdempsky","id":38349,"avatar_url":"https://avatars.githubusercontent.com/u/38349?v=3","gravatar_id":"","url":"https://api.github.com/users/mdempsky","html_url":"https://github.com/mdempsky","followers_url":"https://api.github.com/users/mdempsky/followers","following_url":"https://api.github.com/users/mdempsky/following{/other_user}","gists_url":"https://api.github.com/users/mdempsky/gists{/gist_id}","starred_url":"https://api.github.com/users/mdempsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdempsky/subscriptions","organizations_url":"https://api.github.com/users/mdempsky/orgs","repos_url":"https://api.github.com/users/mdempsky/repos","events_url":"https://api.github.com/users/mdempsky/events{/privacy}","received_events_url":"https://api.github.com/users/mdempsky/received_events","type":"User","site_admin":false},"created_at":"2015-10-22T22:33:29Z","updated_at":"2015-10-22T22:33:29Z","body":"Ah, I suppose gofmt doesn't separate stdlib imports from third-party imports like goimports does.  If you separate them yourself, it should still sort contiguous runs of imports."}}