trouble installing "gorilla/mux" in golang - go

So I installed gorilla/mux to use it for my API by typing this code on terminal
go get -u github.com/gorilla/mux
And since it didn't return any errors (nor any texts) I thought the install was successful. But When I started to use "mux. "something, vscode showed that the name "mux" is not declared. Does anyone had any similar experience or know how to solve the problem? Thanks in advance.
(Using go1.18.3)

Your project doesn't have go.sum file.
Run go mod tidy and you will be good to go.

Related

Cannot see go.sum after initializing backend of project

I am trying to make a simple Chat app using Golang in order to better understand the application. The tutorial I am following asks to initialize go.sum. After running the following commands, I only see go.mod
go install golang.org/x/tools/gopls#latest
go mod init github.com/TutorialEdge/realtime-chat-go-react
How can I try to resolve this issue?
Thank you in advance!
I looked into possible version errors, but I can't really find a fix. I still can only see go.mod
The tutorial you are referring to is a bit dated in content. In current Go, go.sum is managed by the go mod tidy command.

Difficulty installing go buffalo using go mod on windows

I am very new to golang. I am trying to work with the gomod. Trying to explore the go buffalo framework. But finding a bit of difficulty in installing that.
What I have done:
I saw that go get is nomore supported for buffalo and so switched to go modules.
Created a module by go mod init github.com/webbuffalotest
Fetched go get -v github.com/gobuffalo/buffalo (on the same directory where I have go.mod file)
Fetched go get -v github.com/mattn/go-sqlite3 (on the same directory where I have go.mod file)
go install github.com/gobuffalo/buffalo
I was expecting a buffalo.exe inside %GOPATH%/bin so that I can add it to my path but didn't find one.
My question is what's wrong? Is the exe not installed or it's somewhere else because of go mod. Any help will be highly appreciated.
I am using windows 10. I am not willing to install package managers as scoop or choco to install buffalo. Thanks for your patience :)
Edited:
Also tried setting set GO111MODULE=on but of no use.
Solved:
My bad, I should have used go install github.com/gobuffalo/buffalo/buffalo instead of go install github.com/gobuffalo/buffalo
github.com/gobuffalo/buffalo is a library; the corresponding binary is (aptly-named) github.com/gobuffalo/buffalo/buffalo.
The go install command you ran should have warned you about that, but didn't because go install used to also be used to cache compiled libraries (it no longer does that in module mode).
I've filed https://golang.org/issue/46912 to add a diagnostic.

golang: go run is always running old code even after changes

I have a weird issue with golang. I run the command (like everytime):
go run main.go
Then I made some change into my code and then I run again:
go run main.go
But the executed code is the old version of the code. So I tried some stuff:
Reboot the computer
Delete all the temporary binaries into temp folder
Reinstall go
Delete and put back my code
Remove some file
But it is still running my old version of the code. I didn't find solution about this issue, and the few post about it doesn't give a solution (here and here).
About my configuration it is the following:
Raspberry pi running Raspbian (updated)
Go version 1.8.1
I hope you can help me !
Thank in advance!
Best regards,
Okay!
The problem come from the imports. In the code some imports was calling old version of the code.
I think your GOPATH is pointing to a wrong folder. Please, run go env to make sure that it is pointing to the right directory. If not set it to location where go files are. Please, take into account that go run usually does not need a file specification and if you do you have to list defacto all files of your app that main.go depends upon.
Have a look ``here

Nothing happens when running go get github.com/astaxie/beego

warning: noob question ahead :-)
I was trying to run go get github.com/astaxie/beego but it does nothing. I have been running examples I picked up from the internet and I installed gotour successfully. Any idea why?
Turns out my setup was messed up. I purged everything and installed golang using this nifty script: https://github.com/moovweb/gvm. It takes care of everything. Thanks #peterSO for the help.
If it doesn't show anything, it doesn't mean nothing works. Try doing the same with '-v' flag
go get -v github.com/astaxie/beego
Besides, all your downloads will be saved (most probably) somewhere to your '~' directory ('~/go/src' in my case), not in your current terminal directory
if on Ubuntu/Debian?, try the golang package for installing go. it seems to work for me quite well.

can't find import go-gtk

I've been playing around with Google Go, I love the power behind it and decided to try out some libraries. I tried using goinstall to install github.com/mattn/go-gtk/gtk but when I try to compile an example I'm getting:
can't find import: github.com/mattn/go-gtk/gtk
I've heard that others have problems with goinstall, is there anything I can do to fix this? I also saw that some people fixed this by putting the path as something like github.com/mattn/go-gtk/gtk/gtk.so but it's still not working for me.
Use:
go install github.com/mattn/go-gtk/gtk
and it will download and install this library in $GOPATH/src
Use following command to install necessary packages
go get github.com/mattn/go-gtk

Resources