Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

auto import doesn't work with () imports #1618

Closed
gflarity opened this issue Apr 10, 2018 · 4 comments
Closed

auto import doesn't work with () imports #1618

gflarity opened this issue Apr 10, 2018 · 4 comments

Comments

@gflarity
Copy link

package main

import (
	"log"
	"time"

	apicorev1 "k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/client-go/kubernetes"
	typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1"
)

func main() {

	lo := apicorev1.ListOptions
	
}

Type 'fmt' and try to auto import it. You'll get:

package main

import (
import "fmt"
	"log"
	"time"

	apicorev1 "k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/client-go/kubernetes"
	typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1"
)

func main() {

	lo := apicorev1.ListOptions
	fmt
}
@ramya-rao-a
Copy link
Contributor

We stop parsing the lines when we find a func or const or type or var declaration. The regular expression used for this was missing to look for a space after these keywords and so mistook typedcorev1 for type declaration :)

I have pushed a fix. Until I release an update, you can do the following to get the fix:

@gflarity
Copy link
Author

So far so good. Thanks for fixing this so quickly. Big fan of vscode+go.

@ramya-rao-a
Copy link
Contributor

Thanks :)

@ramya-rao-a
Copy link
Contributor

This bug fix is now out in the latest update to the Go extension (0.6.79)
Thanks for reporting @gflarity!

@vscodebot vscodebot bot locked and limited conversation to collaborators May 27, 2018
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants