While setting up my new Go with Sublime I wanted to install Oracle tools with the following command
go get golang.org/x/tools/cmd/oracle
package golang.org/x/tools/cmd/oracle: cannot find package "golang.org/x/tools/cmd/oracle" in any of:
C:\Go\src\golang.org\x\tools\cmd\oracle (from $GOROOT)
C:\Users\User\Go\src\golang.org\x\tools\cmd\oracle (from $GOPATH)
What am I doing wrong here?
If you check the package link you'll see it throws NOT FOUND (package link here)
Based on this, it seems that the package was renamed to guru, this is the correct installation:
go get golang.org/x/tools/cmd/guru
The command that works for me is:
go get golang.org/x/tools/cmd/guru
(the same as before, just with the new name of the tool - guru, instead of oracle)
if %GOBIN% // $GOBIN is in your path, This command will be magic:
go get golang.org/x/tools/...
Related
C:\Users\Administrator\Documents\code\projects\weatherly>go get -u github.com/gofiber/fiber/v2
cannot find package "github.com/gofiber/fiber/v2" in any of:
c:\go\src\github.com\gofiber\fiber\v2 (from $GOROOT)
C:\Users\Administrator\go\src\github.com\gofiber\fiber\v2 (from $GOPATH)
How do I download the package? I believe that it is trying to check what is cached on my computer and I don't know how to download it first.
Its because you haven't initiated your module, you should use go mod init YourModuleName, then its pretty simple to do. also remove -f from go get command.
I'm trying to follow the Writing an intepreter in Go book, by Thorsten Ball, and in the first chapter he establish this simple scheme
file /Users/myuser/projects/monkey/token/token.go
file /Users/myuser/projects/monkey/lexer/lexer.go
file /Users/myuser/projects/monkey/lexer/lexer_test.go
In lexer/lexer.go and lexer/lexer_test.g the files start as
package lexer
And in lexer_test.go the imports are
import (
"testing"
"monkey/token"
)
Then he says that for running the test, I have to run (from /Users/myuser/projects/monkey directory):
go test lexer/lexer_test.go
But when I do this, I receive the error:
lexer/lexer_test.go:6:2: cannot find package "monkey/token" in any of:
/usr/local/opt/go/libexec/src/monkey/token (from $GOROOT)
/Users/myuser/golang/src/monkey/token (from $GOPATH)
FAIL command-line-arguments [setup failed]
FAIL
I've been trying to understand how to configure the packages in go, but I found a lot of very complicated documentation about GOPATH, GOROOT and go.mod. I've been trying all this approach without get rid of the issue.
Can someone help me please? I'm sure is a simple fix but I cannot figure it out :(
As the error message says, the compiler couldn't find the package locally.
Are you sure you have installed the package?
You may need to do go get [packagename]
For e.g., go get golang.org/x/tools/cmd/goimports
For Golang, It will find package first from go root then go path then import from outside. So basically, you should have that package monkey/token in your go root or go path.
I don't think it is about goimport because monkey/token didn't seem to be official lib that can be import.
When I first try Golang I have the same problem. I solve by create that package in go path (your working dir) or create that package from your book.
I was migrating my Golang programs from windows to Centos 7
It worked perfectly in Windows
but when I tried to compile on centos I get errors like
main.go:20:3: cannot find package "github.com/BurntSushi/toml" in any of:
/usr/local/go/src/github.com/BurntSushi/toml (from $GOROOT)
/root/work/src/github.com/BurntSushi/toml (from $GOPATH)
main.go:15:3: cannot find package "github.com/dgrijalva/jwt-go" in any of:
/usr/local/go/src/github.com/dgrijalva/jwt-go (from $GOROOT)
/root/work/src/github.com/dgrijalva/jwt-go (from $GOPATH)
main.go:16:3: cannot find package "github.com/gwlkm_service/config" in any of:
/usr/local/go/src/github.com/gwlkm_service/config (from $GOROOT)
/root/work/src/github.com/gwlkm_service/config (from $GOPATH)
kinda new to centos so idk what to do
looks like you have configured your GOPATH, without Go Module, you can use go get [package path] to download imported packages.
go get github.com/BurntSushi/toml
go get github.com/dgrijalva/jwt-go
go get github.com/gwlkm_service/config
Precisely
your go installation on server seems in /usr/local/go and
your project is in /root/work
so all your dependencies should be either in /root/work/src or /usr/local/go/src
now coming to action check your GOPATH with running echo $GOPATH
assuming it is automatically set to /usr/local/go/src
If not then follow - How do I SET the GOPATH environment variable on Ubuntu? What file must I edit?
If everything is ok then in your folder run go mod init
this will create mod file which will help you in further installations
look into - https://blog.golang.org/using-go-modules
then run go get commands as above #beiping96 said
go get github.com/BurntSushi/toml
go get github.com/dgrijalva/jwt-go
go get github.com/gwlkm_service/config
NOTE - after completing above process you will generate go modules file(same as package.json) and in future you won't need to care about dependencies
I am trying to import a package in my golang code. But it is showing me this error:
cannot find package "github.com/mattbaird/jsonpatch" in any of:
/opt/go/src/github.com/mattbaird/jsonpatch (from $GOROOT)
/chaincode/input/src/github.com/mattbaird/jsonpatch (from $GOPATH)
/opt/gopath/src/github.com/mattbaird/jsonpatch "
Can somebody help me fix this?
Thanks.
Recheck your environment variables($GOPATH, $GOROOT).
The problem you are facing is that, your code is searching for the package github.com/mattbaird/jsonpatch in /opt/go/src/github.com/, /chaincode/input/src/github.com/ and /opt/gopath/src/github.com/ directories. But you have installed the package in C:\Users\xyz\go\src\github.com directory.
Ensure your $GOPATH environment variable is set up correctly.
Then double check the packages are installed, if not you need to install the package which you can do with.
go get github.com/mattbaird/jsonpatch
go:5:2: cannot find package "github.com/googollee/go-socket.io" in any of:
/usr/local/go/src/github.com/googollee/go-socket.io (from $GOROOT)
/Users/YoungHoonKim/Documents/chat/src/github.com/googollee/go-socket.io (from $GOPATH)
I'm getting this error while trying to compile my chat.go file with LiteIDE. I'm following a guide to build a chatserver, so I don't know where this package should be. any help?
Double-check your actual go work directory with echo $GOPATH in your terminal.
This will be your starting point to identify if you have this package at all, for example you should be able to see this package doing cd $GOPATH/src/github.com/googollee/go-socket.io.
For more details on correct directory location (workspace in general) please check https://golang.org/doc/code.html