So I am working with JSON in golang and I want to use this package in GitHub https://github.com/icza/dyno so i use the go get github.com/icza/dyno command to get the package.
but when i run my code this error show
d:\Repos\GoProjects\src\github.com\Timothy Ganoza\sbx\main.go:8:2: cannot find package "github.com/icza/dyno" in any of:
C:\Program Files\Go\src\github.com\icza\dyno (from $GOROOT)
d:\Repos\GoProjects\go\src\github.com\icza\dyno (from $GOPATH)
exit status 1
Process exiting with code: 1
I recommend going through the following path, using official documentation pages:
Read about properly installing Go for your platform
Read the getting started tutorial which also tells you how to install 3rd-party packages and use them in your code.
It should take you no more than 20 minutes to go through these steps, and it's almost certain that you'll be able to accomplish your goal by the end of the process. As a bonus, keep going through the Getting Started guide beyond the first page to learn how to create your own Go modules, use them from other modules, write tests, build your code into a binary, and more.
This is IMHO the minimal background required to even try writing Go programs; without going through these steps, you will lack crucial fundamental understanding and it will be hard to even understand SO answers.
If problems still persist, feel free to update the question but provide more details: how are your go env vars set up (output of go env), are you using modules (you should!), how does your module directory look, etc.
Related
A bit of background:
I am a pentester who is looking for new ways to get around AV detection during tests / bounties and I recently found the Go library "Coldfire" on Github. I am new to Go so I was wondering how I would structure a project with this package.
It doesn't give much instructions except the func that it uses and I am coming from Python.
https://github.com/redcode-labs/Coldfire
If anyone can give me some tips, I am trying to write an AV evasion program that will kill AV processes and possibly disable a WAF.
You don't have to give me full code or anything, I just would like some examples on how to use the package is all. Thank you so much and please excuse my lack of knowledge I love Go but am very new to it and trying to learn it respective to my profession.
Not really interested in Disruptive functions but with the recent outbreak in Go malware I would love to understand how malicious attackers use those functions too if possible.
I imported the library but it kept giving me an error saying I wasn't using the package even though I had implemented some of the functions to see what they did.
Not sure what goes in said func like..
func PkillAv()
Not sure what would go in the {} on this one or if I would even need it.
You would just need to import it at the top part of your code like:
import "github.com/redcode-labs/Coldfire"
You also need to run
go mod tidy
To download this package.
After that you can use the functions provided in the package. There is no "structure" that you need to manualy create
My goal is to use Go exclusively on Docker. In other words, I try my best not to install Go directly to my computer. And, I am writing the code on a VS Code and use the "Go" extension.
The problem is that when I create a main.go it throws an error:
Failed to find the "go" binary in either GOROOT() or PATH(/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin). Check PATH, or Install Go and reload the window. If PATH isn't what you expected, see https://github.com/golang/vscode-go/issues/971
Is there an alternative to get the code completion feature in VS Code?
This should be achievable using the Remote Development Extension pack. VSCode has good documentation on using containers as your development enviroment. This will allow you to enjoy all of the Go extension's features without needing Go to be installed directly on your machine. You can opt to install the extensions in the container as well.
See Developing inside a Container
My GOROOT path :-
C:\Go
I have set GOPATH to :-
C:\Users\kunal\go
But when I import modules (like github.com/gorilla/mux) inside VS Code. VS Code prompts me this error :-
could not import github.com/gorilla/mux (cannot find package "github.com/gorilla/mux" in any of C:\Go\src\github.com\gorilla\mux (from $GOROOT) C\src\github.com\gorilla\mux (from $GOPATH) \Users\kunal\go\src\github.com\gorilla\mux (from $GOPATH))
From above It is clear that it shows me two different GOPATH which I haven’t set. How do I fix this?
I recommend going through the following path, using official documentation pages:
Read about properly installing Go for your platform
Read the getting started tutorial which also tells you how to install 3rd-party packages and use them in your code.
It should take you no more than 20 minutes to go through these steps, and it's almost certain that you'll be able to accomplish your goal by the end of the process. As a bonus, keep going through the Getting Started guide beyond the first page to learn how to create your own Go modules, use them from other modules, write tests, build your code into a binary, and more.
This is IMHO the minimal background required to even try writing Go programs; without going through these steps, you will lack crucial fundamental understanding and it will be hard to even understand SO answers.
Specifically in your case - please remember that at this time (with Go 1.16), GOPATH is pretty much deprecated and you should be using Go modules instead. The documents linked to above will explain this in detail.
I ll give a TLDR for the solution given by #Eli Bendersky. If you don't understand GOPATH and go modules, you can look it up yourself here. Here I have assumed you are using VS Code with golang extension. I haven't tested it for other IDEs but it should work in a similiar way.
In the source directory where you have the main.go, create a file named go.mod
Name the package name to whatever you like and save the file.
go to your terminal and run go build main.go, this will download all the missing packages(if any) and will update the go.mod file and create a new file go.sum to create the checksums of the package versions.
All the package error squiggles should be gone by now in your IDE, if it doesn't try restarting your IDE once. You are good to go!
If you are stuck somewhere, let me know in the comments.
I just started to learn golang today. But it seems that I understood more from what these experts are trying to say when trying to answer this basic question.
I don't claim deep knowledge of golang. But as a 2100 rated chess player, I do claim common sense and rigorous thought process. The GOPATH environment variable is very much in use do not believe these kids. Only a kid would make such claims that GOPATH has no use.
The way I see it is that, the go.mod and go.sum plays in tandem with GOPATH.
Continue on your own journey, little tiger. I upvoted your question for moral support.
The below command is taking ages with no output or anything, is there an alternative way to download packages for go language.? I am new to golang.
go get -u github.com/gogits/gogs/
PS: my net connection is not that slow, downloading through git takes around 1 min, but i can't individually do that for all dependencies.
Edit 1: Small packages like go get github.com/tools/godep downloads and install flawlessly, i have the problem only with github.com/gogits/gogs/ . Its stuck there for an hour. Even a download progress would have been helpful.
go get command is working but its terribly slow for packages that have lots of dependencies. the -v flag(not in doc) helped me to get a verbose output of what is happening.
Took almost an hour to finish. Culprit might possibly be github or my ISP.
Verbose output should had made default by the developers.
*sorry for my English.
You can use GoDep which is a powerful Go dependency manager: https://github.com/tools/godep
GoDep also helps you to have a predictable build since it freezes dependencies in your app
Very easy to get started, just follow instruction on its Github page.
I'm developing a package for nitrous.io autoparts and wonder if there is any documentation or resources for package developers.
My main problem is that autoparts is not very verbose. It's just telling me that a command failed but not why it failed or the output of that command. Is there a way to increase the verbosity? Log files? Anything?
Additionally, it's behaviour is really strange, see that gist: https://gist.github.com/phortx/9504396
The Autoparts documentation has been updated to include package development information. Here are a couple guides to help you out.
Guidelines and contribution instructions: https://github.com/nitrous-io/autoparts/blob/master/docs/contributing.md
Example part: https://github.com/nitrous-io/autoparts/blob/master/docs/example-part.rb
You can also view the documentation within your Nitrous.IO box by running the following commands within the console. You may need to run $ parts update in the console first to pull the latest documentation.
$ cat ~/.parts/autoparts/docs/contributing.md
$ cat ~/.parts/autoparts/docs/example-part.rb
Meanwhile I still not found docs, but found solutions for my problems. Actually parts is verbose, it crashes before any output. The reason for that crash which I also showed in my gist is that it can't extract .xz files.