KEMBAR78
Incorrect import by auto-complete when pkgname != last part of pkg path · Issue #647 · microsoft/vscode-go · GitHub
Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

Incorrect import by auto-complete when pkgname != last part of pkg path #647

@AlekSi

Description

@AlekSi

That's a continuation of #613. Get code from https://github.com/AlekSi/vscode-bug and then edit main.go as shown:

2016-11-24_16-11-38

Two things are wrong after hitting Enter:

  1. It adds sarama.v1 to code. As I explained in Format removes imports of vendored packages in use #613, the package name is sarama, not sarama.v1. Package name != last part of import path.
  2. It adds vendor/gopkg.in/Shopify/sarama.v1 which is incorrect import path. vendor/ is treated differently by Go toolchain. goreturns does the right thing:
$ goreturns -d src/bugger/cmd/bugger/main.go
diff src/bugger/cmd/bugger/main.go gofmt/src/bugger/cmd/bugger/main.go
--- /var/folders/fl/c3xvc0tj1js__3jnrnbkjll40000gn/T/gofmt002523159	2016-11-24 16:22:09.000000000 +0300
+++ /var/folders/fl/c3xvc0tj1js__3jnrnbkjll40000gn/T/gofmt440158346	2016-11-24 16:22:09.000000000 +0300
@@ -1,5 +1,7 @@
 package main

+import sarama "gopkg.in/Shopify/sarama.v1"
+
 func main() {
 	sarama.V0_10_0_0
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions