Hello go bridgers, I have a problem with importing packages to golang workspace.
I am trying to import a package from within the same project directory but it’s not loading. Here’s the folder structure:
$GOPATH/src/github.com/microworlds/myapp
When I try to load load the demo package in main, it shows an error like: [go] cannot find package "mypackage/demo" in any of: /usr/local/go/src/mypackage/demo (from $GOROOT) /home/me/work/src/mypackage/demo (from $GOPATH)
My import in main.go goes like this:
import (
“fmt”
“mypackage/demo”
“log”
“strings”
"github.com/PuerkitoBio/goquery"
)
Why am I getting this kind of error and how do I fix that
Ubuntu 18.04
Sorry for unformated text, I’m new here, Thank you.
I did so. I’m using vscode. After specifying the full path, when I save the file, the import statement disappears. I was wondering, must I run a go get on that package to be able to use it? (But I’m not committing the project to github yet)
Depending on how you configured vscode it will remove packages on save it thinks you do not use. This is a setting of the formatter IIRC… I consider this really annoying…
And you only need to go get if you haven’t the package available already.