VS Code–GoLang

VSCode: Could not import Golang package

You may get a warning in VSCode as follows

image

 

Let us see how to resolve this warning. Take a look at the directory structure.

image

 

You can see , there is root folder called “GOSamples” and inside we have folder called workspace and its structure as follows

image

 

You can see, there is warning showing on main.go , but the program works without any issue, that you can see in the output.

image

 

image

 

This is just a warning and VS Code does not understand the latest go Modules changes. We can resolve, by opening the VS Code IDE from the workspace folder as shown here

image

 

Now you can see there is no red mark or any warning on the import statement.