Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed last month.
Improve this question
I want to install go-fastping, but when I try using
go get -u github.com/tatsushid/go-fastping, this error gets displayed:
go: go.mod file not found in current directory or any parent directory.
'go get' is no longer supported outside a module.
To build and install a command, use 'go install' with a version,
like 'go install example.com/cmd#latest'
For more information, see https://golang.org/doc/go-get-install-deprecation
or run 'go help get' or 'go help install'.
so I changed to install:
go install github.com/tatsushid/go-fastping
Try 'go install github.com/tatsushid/go-fastping#latest' to install the latest version
and after I did changed to: go install github.com/tatsushid/go-fastping#latest
it worked but when I try to add it in the code it says that the module is not installed.
Your project most likely doesn't have a go.mod file.
Inside the root of your project run go mod init <module-name> to create a module and then you can run go get -u github.com/tatsushid/go-fastping to add this dependency to your project.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 1 year ago.
Improve this question
I ran
go get -u github.com/ipfs/ipfs-update
and got in the end of what it looks like an installation going on the following
go get: installing executables with 'go get' in module mode is deprecated.
Use 'go install pkg#version' instead.
For more information, see https://golang.org/doc/go-get-install-deprecation or run 'go help get' or 'go help install'.
github.com/ipfs/ipfs-update
go/pkg/mod/github.com/ipfs/ipfs-update#v1.7.1/main.go:318:21: cannot use lib.NewIpfsFetcher(distPath, 0) (type *lib.IpfsFetcher) as type migrations.Fetcher in argument to migrations.NewMultiFetcher:
*lib.IpfsFetcher does not implement migrations.Fetcher (missing Close method)
Then, used
ipfs-update versions
but didn't see the latest version.
To get that working I've used instead
go install github.com/ipfs/ipfs-update#latest
Then once running
ipfs-update versions
I got
Then could simply run
ipfs-update install v0.11.0
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
i have tried to run a new project of golang i've installed everything but I faced the following problem
$ go get github.com/paulsmith/gogeos/geos
#### #github.com/paulsmith/gogeos/geos
In file included from ..\..\go\pkg\mod\github.com\paulsmith\gogeos#v0.1.2\geos\coordseq.go:4:
./geos.h:1:10: fatal error: geos_c.h: No such file or directory
1 | #include <geos_c.h>
| ^~~~~~~~~~
compilation terminated.
Looking at the installation instructions on the project's page, it seems like you have to install GEOS first; see this part: https://github.com/paulsmith/gogeos#requirements
It can be as easy as $ apt-get install libgeos-dev on Ubuntu, but the link above has instructions for a from-source installation as well.
What happens in your case is that the Go package likely uses cgo to load C code from GEOS, and it fails immediately because GEOS is not installed, and cgo cannot find the headers files.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I did go get github.com/nanobox-io/golang-scribble, but when i try to run the main.go i get the error
[jerome#thearch beer-server]$ go run main.go
../../pkg/storage/json/repository.go:14:2: cannot find package "github.com/nanobox.io/golang-scribble" in any of:
/usr/lib/go/src/github.com/nanobox.io/golang-scribble (from $GOROOT)
/home/jerome/Documents/code/go/domainhex/src/github.com/nanobox.io/golang-scribble (from $GOPATH)
so i searched it:
[jerome#thearch nanobox-io]$ find /home/jerome/Documents/code/go/domainhex/src/github.com/nanobox.io -name golang-scribble
find: ‘/home/jerome/Documents/code/go/domainhex/src/github.com/nanobox.io’: No such file or directory
There is the thing completly weird, i cd follow the link and the package golang-scribble is present at the right place. So i pwd to get the path and use it to run the same cmd as previously
[jerome#thearch nanobox-io]$ pwd
/home/jerome/Documents/code/go/domainhex/src/github.com/nanobox-io
[jerome#thearch nanobox-io]$ ls
golang-scribble
[jerome#thearch nanobox-io]$ find /home/jerome/Documents/code/go/domainhex/src/github.com/nanobox-io -name golang-scribble
/home/jerome/Documents/code/go/domainhex/src/github.com/nanobox-io/golang-scribble
I don t know what's wrong ?
If i add some other package like github.com/google/uuid or julienschmidt/httprouter, it works perfectly.
extra-info
go version go1.16.2 linux/amd64
GO111MODULE="auto"
GOPATH="/home/jerome/Documents/code/go/domainhex"
Operating System: Arch Linux
Kernel: Linux 5.11.6-arch1-1
Architecture: x86-64
You are doing go get on github.com/nanobox-io/golang-scribble but you're importing github.com/nanobox.io/golang-scribble, the difference being nanobox-io vs nanobox.io. Try changing your import statement to github.com/nanobox-io/golang-scribble.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I was trying not to use the default go workspace, but to create a separate workspace location. So I did the following:
Created a folder, say "/Users/user_name/some_path/go_files/"
Created 3 directories in that folder - src, pkg and bin
Created a go file called "hello_world.go" inside "/Users/user_name/some_path/go_files/src"
Exported the GOPATH variable to "/Users/user_name/some_path/go_files"
Built the executable in 2 ways: go build src/hello_world.go and cd src go build hello_word.go
The above generated 2 executables - 1 in go_files/src and the other in go_files
However, running either of them gives an error saying: package hello_world is not in GOROOT (/usr/local/go/src/hello_world)
I tried to run the executable using go run hello_world. How do I resolve this? How do I run an executable?
Please note that I can do a go run hello_world.go from inside src or a go run src/hello_world.go, but I want to know how to run the executable.
However, running either of them gives an error saying: package hello_world is not in GOROOT (/usr/local/go/src/hello_world)
You haven't actually said what you're doing to provoke this error, but it sounds like you're almost certainly running go run hello_world. Once you've build an executable, Go (the language) and go (the command) are no longer involved. Binaries run independently of their compiler, which may be surprising to you if you're coming from an interpreted language background.
You run any given executable by typing its name (if it's in your path) or by typing the path to it (ie ./hello_world) and then pressing "return".
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Original close reason(s) were not resolved
Improve this question
When I install a package using go get, in the golang module mode, these are installed in the go root folder.
I would like to be able to install the modules in the same way that npm or yarn does for node.js, global or local.
what would be the right way to achieve this behavior.
Thanks.
As others have mentioned, you can create your module files like this:
go mod init [import path]
After that you can run this command any time to move all dependencies into the vendor directory:
go mod vendor
This is very similar to the behaviour of the node_modules directory.
To build using the dependencies in this directory, you can add -mod vendor to your build command:
go build -mod vendor
This way you can copy your project to any machine without go-getting anything on that other machine.
According to the docs, the -mod=vendor flag is set automatically if the Go version in the go.mod file is 1.14 or higher and a vendor directory exists.
To clean unused dependencies from the vendor directory, you can run
go mod tidy
There is little bit different approach. Go lock versions based on github (gitlab, etc) current commit. When you want to use specific versions of packages and not master all the time you want to use go modules (this is official way to do it, but there are some other tools). You init module in you project
go mod init [possible custom package name]
And everytime you call "go get somepackage" it writes versions it uses to a file called go.mod.
You can read more here