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

No go files in Microsoft VS Code issue #1481

Closed
burzum0727 opened this issue Jan 24, 2018 · 14 comments
Closed

No go files in Microsoft VS Code issue #1481

burzum0727 opened this issue Jan 24, 2018 · 14 comments

Comments

@burzum0727
Copy link

Hello y'all
I recently downloaded golang and vs code. It's my first attempt to work on this language anyways. I have set the GOPATH and GOROOT correctly. Go extension installed as well and I can see them in my bin file however on problems part I'm receiving this error.
file: 'file:///Untitled-1'
severity: 'Error'
message: 'can't load package: package .: no Go files in C:\Program Files\Microsoft VS Code
'
at: '1,1'
source: ''
code: 'undefined'
What supposes to I do? I have no clue what should I put in vs code section.

@ramya-rao-a
Copy link
Contributor

Can you run go env in a terminal and share the results?
What folder have you opened in VS Code when you got this error?

@burzum0727
Copy link
Author

These are the results in terminal.

C:\Users\varg>go env
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=E:\Users\varg\GoWorks
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config

C:\Users\varg>
C:\Users\varg>file: 'file:///Untitled-1'severity: 'Error'message: 'can't load package: package .: no Go files in C:\Program Files\Microsoft VS Code'at: '1,1'source: ''code: 'undefined'
I tried without folder just created with a new file, in documents a new workplace and the path root. None of them worked.

@ramya-rao-a
Copy link
Contributor

Can you share what's in your Output pane under the Go channel?
Press Ctrl+Shift+u to open the output pane
Select "Go" from the drop down thats on the top right corner of the output pane

@burzum0727
Copy link
Author

burzum0727 commented Jan 24, 2018

Finished running tool: C:\Go\bin\go.exe build -i -o C:\Users\varg\AppData\Local\Temp\go-code-check .
can't load package: package .: no Go files in C:\Program Files\Microsoft VS Code

Finished running tool: E:\Users\varg\GoWorks\bin\golint.exe

Finished running tool: C:\Go\bin\go.exe vet ./...

@ramya-rao-a
Copy link
Contributor

Do you see the same when opening any of the Go projects under your GOPATH?

@burzum0727
Copy link
Author

Unfortunately, I do not have any project yet. This one supposed to be mine first project but due to problems, I couldn't start yet.

@ramya-rao-a
Copy link
Contributor

You will still have the code for all the Go tools you installed as part of the Go extension.
For example, you can open E:Users\varg\GoWorks\src\github.com\ramya-rao-a\go-outline

@burzum0727
Copy link
Author

Finished running tool: E:\Users\varg\GoWorks\bin\golint.exe
e:\Users\varg\GoWorks\src\github.com\ramya-rao-a\go-outline\main.go:17: exported type Declaration should have comment or be unexported

Finished running tool: C:\Go\bin\go.exe vet ./...
e:\Users\varg\GoWorks\src\github.com\ramya-rao-a\go-outline\main.go:116: no formatting directive in Errorf call

Finished running tool: C:\Go\bin\go.exe build -i -o C:\Users\varg\AppData\Local\Temp\go-code-check github.com\ramya-rao-a\go-outline

@okandas
Copy link

okandas commented Jan 25, 2018

the updates that make everything stop working nicely are the most painful .. :(

@ramya-rao-a
Copy link
Contributor

@okandas Please elaborate on whats not working for you in a separate issue. This current issue is about the error can't load package: package .: no Go files in C:\Program Files\Microsoft VS Code showing up on build.

@burzum0727 Thanks for reporting this issue, I can repro it by opening a new untitled file when no folder is open. I have pushed a fix which should be out in the next update to this extension next week. Until then, please avoid working with untitled files.

@burzum0727
Copy link
Author

So you mean I can work now with the titled files? Because I do not understand the result from the output that I receive from your github file is an issue or a regular start up.

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Jan 25, 2018

So you mean I can work now with the titled files

Working on titled files was never a problem. The output you shared in #1481 (comment) is the output of the processes that ran build, lint and vet on the file that was opened.

Go uses the concept of packages (the folder that contains the Go files). When you work on an untitled file, there is no valid package that can be used for building which caused the issue.

@burzum0727
Copy link
Author

Thank you for the help Mrs. Rao!

@ramya-rao-a
Copy link
Contributor

Just released an update (0.6.74) that has the fix for this issue.

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

No branches or pull requests

3 participants