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

After upgrade to GO extension 0.6.56 version, some errors about package #892

Closed
amnotbusy opened this issue Mar 30, 2017 · 35 comments
Closed

Comments

@amnotbusy
Copy link

gobug1
gobug2

win7 64bit
vscode 1.10.2
how to fix it? thx

@amnotbusy
Copy link
Author

image

@amnotbusy
Copy link
Author

@mattetti @buckett @saml @AlekSi @neelance reinstall golang vscode and tools,this bug still here

@amnotbusy
Copy link
Author

image

@ansencumt
Copy link

ansencumt commented Mar 30, 2017

image

Uploading image.png…

I also get the same error.

@ansencumt
Copy link

The word "ode" is not exist in my system folder.

@amnotbusy
Copy link
Author

I build 0.6.54, install it can work normal, remenber uninstall 0.6.56 first
Open the extensions menu in VSCode and choose Install from VSIX and select the Go-xxx.vsix
I upload zip file failed, share url to download Go-0.6.54.vsix

@amnotbusy
Copy link
Author

@ansencumt

@ansencumt
Copy link

@a57571735 thx

@nezorflame
Copy link
Contributor

nezorflame commented Mar 30, 2017

getting the same issue on MacOS.
seems like it somehow trims the start of the package name thus failing to find the package.
@lukehoban @ramya-rao-a please take a look.

@nezorflame
Copy link
Contributor

Here's the previous build for the time being for those who like me are unable to install from previous link by @a57571735
Go-0.6.54.vsix.zip

@asdine
Copy link

asdine commented Mar 30, 2017

I don't think it's related to Go 1.8 but only to the version 0.6.56. The bug occured the moment i upgraded

@ramya-rao-a
Copy link
Contributor

Hello people,

just saw this.
Thanks for reporting.

Most likely culprit is #864

Will send out a fix soon

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Mar 30, 2017

Looking at all the error messages posted here, it looks like a classic off by 1 error.
dataAccess -> ataAccess
code -> ode

But unfortunately, neither did I see this error while testing, nor can I see it now in any of my Go projects.

All of my Go project paths are of the form $GOPATH/src/github.com/somebody/someproject and I cant see this error in any of them.

So I created another project right under $GOPATH/src like @a57571735. Can't repro the bug then either :(

@a57571735 @nezorflame Since you have local dev env available for the Go extension, can you help me debug this issue? You need to put a breakpoint at https://github.com/Microsoft/vscode-go/blob/master/src/goCheck.ts#L167 and see what values you are getting for currentGoWorkspace and importPath variables

@nezorflame
Copy link
Contributor

@ramya-rao-a sure, in a couple of minutes (on the road right now)

@ramya-rao-a ramya-rao-a changed the title After upgrade GO to 1.8 version, some errors about package After upgrade to GO extension 0.6.56 version, some errors about package Mar 30, 2017
@ramya-rao-a
Copy link
Contributor

@a57571735 @asdine @nezorflame @ansencumt
Can you share some details about your GOPATH?

  • Is your GOPATH set to multiple workspaces
  • Are you using the go.gopath setting to override the GOPATH env variable
  • Do you have go.inferGopath set to true ?
  • Can you run the command Go: Current GOPATH and see if that looks right to you?

@nezorflame
Copy link
Contributor

nezorflame commented Mar 30, 2017

@ramya-rao-a

  • yeah (set in .bash_profile: GOPATH="${GOPATH1}:${GOPATH2}:${GOPATH3}")
  • no
  • no
  • seems OK

the funny thing is that if I create an empty folder in a folder path it tries to find, the error goes away.
it definitely has something to do with the project name.

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Mar 30, 2017

Alright, found the issue.

Commited the fix: d417fd6

Update 0.6.57 is out.

This issue only affects those who have multiple GOPATHs, and the Go project being worked on is not the first one among the multiple GOPATHs and the right GOPATH is shorter in length than the first GOPATH.

I know, thats a mouthful. And quite silly. I apologize for not testing multiple GOPATHs from my side.

Happy Coding!

@nezorflame
Copy link
Contributor

nezorflame commented Mar 30, 2017

@ramya-rao-a can confirm that it's fixed now (built from the latest comment).

@ramya-rao-a
Copy link
Contributor

Thanks @nezorflame! The update is out as well.

@AaronReboot
Copy link

AaronReboot commented Mar 30, 2017

Hi, I was experiencing the issue described in this issue with 0.6.56. I just updated to 0.6.57 and there's still a problem:

It's now reporting "cannot import absolute path" at the top of all my package names

image

@ramya-rao-a
Copy link
Contributor

@AaronReboot Can you share the build output from the output channel?

@ramya-rao-a
Copy link
Contributor

@AaronReboot Make sure that the project you have opened is under the GOPATH that you get by running the command Go: Current GOPATH

@AaronReboot
Copy link

AaronReboot commented Mar 30, 2017

Sure thing. Here's my build output:


Finished running tool: /usr/local/go/bin/go build -i -o /var/folders/n_/7lfk4kw11hg0q83fy9kqc8jr0000gn/T/go-code-check -tags "" /Users/aaron/code/LLAPI
can't load package: package /Users/aaron/code/LLAPI: import "/Users/aaron/code/LLAPI": cannot import absolute path


Finished running tool: /usr/local/go/bin/go tool vet /Users/aaron/code/LLAPI/balance.go```

And here's my GOPATH
`Current GOPATH: /Users/aaron/code`

@ramya-rao-a
Copy link
Contributor

Is there any reason, your project is directly under $GOPATH and not $GOPATH/src?

@AaronReboot
Copy link

It's just how things are organized at the firm I'm working for. It removes some of the complications with deploying App Engine projects.

I'd like to note there's been no difficulty with this simplified path structure prior to 0.6.56

@ramya-rao-a
Copy link
Contributor

In 0.6.56 we pass the import path of the current package to go build

And to find the import path we assume that the current file is under $GOPATH/src
If we can't find the import path this way, then the path to the current directory is used (which is wrong, causing the error you are seeing, we should have used ., we will fix that soon)

@liaoya
Copy link

liaoya commented Mar 31, 2017

I met the same problem on both my Linux and Windows VSCode 1.10.2 and Go 0.6.57. There is only one folder in my GOPATH. I also move the code to src and has the same problem.

The following is output on my Windows.
file: 'file:///d%3A/temp/gopl/src/helloworld/helloworld.go'
severity: 'Error'
message: 'can't load package: package d:/temp/gopl/src/helloworld: cannot find package "d:/temp/gopl/src/helloworld" in any of:
C:\tools\go\src\d:\temp\gopl\src\helloworld (from $GOROOT)
c:\opt\gopath\src\d:\temp\gopl\src\helloworld (from $GOPATH)
'
at: '1,1'
source: ''

@ramya-rao-a
Copy link
Contributor

Since I am not able to repro, can you uninstall the Go extension you have, and install it using the Go-0.6.58.vsix to confirm if the fix works for you?

  • Uninstall Go extension
  • Download the vsix file Go-0.6.58.vsix
  • Run code --install-extension Go-0.5.58.vsix from the location where you downloaded the file

@ramya-rao-a
Copy link
Contributor

@liaoya Please use the workaround above, that should fix the issue for you.

Also, I am curious about your set up. Do you have multiple GOPATHs set?
You are trying to build d:/temp/gopl/src/helloworld from which I am assuming d:/temp/gopl is your GOPATH. Can you run the command Go: Current GOPATH and share the result?

@liaoya
Copy link

liaoya commented Mar 31, 2017

The following is output of "go env" about gopath
set GOPATH=c:\opt\gopath
I use 0.6.58 in issue #895, and it works as before.

I will not put the workspace in environment variable gopath and there's one item in gopath which store third party library and tool.

I'm just a beginner of Go. Thank you very much for the wonderful extension.

@AaronReboot
Copy link

AaronReboot commented Mar 31, 2017

Hi. I'm happy to report that everything is fixed here too after manually installing 0.6.58!

@asdine
Copy link

asdine commented Mar 31, 2017

Me too ! 👍

@lzelevinsky
Copy link

I had the same problem as others with 0.6.57. I have a single simple GOPATH.
Manually updating to 0.6.58 worked for me as well.

@gevg
Copy link

gevg commented Apr 1, 2017

Me too ! 👍

@ramya-rao-a
Copy link
Contributor

I just released an update (0.6.59) yesterday which has the fix

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants