Why Go is not being detected? - go

I'm trying to install Go, gRPC and Protobuf but I cant even install Go in the first place.
I followed steps mentioned in this site:
https://tecadmin.net/install-go-on-centos/
My bash_profile file looks like this now:
http://prntscr.com/nf2bm9
And when I try to test go installation by typing "go version" in the console I get this error:
-bash: go: command not found
Where did I go wrong?
Note: I navigated to /usr/local/ to see if there is any go folder with files or not to confirm the files has been downloaded and moved at the right place.

Changes to your .bash_profile file only take effect after you relaunch the terminal.
source ~/.bash_profile will reload it in your current session, if you'd rather take that approach.

Related

Cocoapods sudo-less installation

Hi I follow this guideline for sudo-less installation https://guides.cocoapods.org/using/getting-started.html and I stuck on /Users/eloy/.gem/ruby/2.0.0/bin/pod install
Terminal says [!] No Podfile found in the project directory.
Command gem which cocoapods correctly shows path to cocoapds so I guess installation succeed. I tried changing paths in .profile file but it's not a problem. Please give me some ideas.
I followed the same guidelines for sudo-less installation, and I had the same results and issues. I'm very new to all of this, so take this answer with a healthy dose of skepticism unless someone more experienced confirms it.
After some poking around on google, I stumbled upon this article.
Following these instructions resolved my issues, so I hope they help you as well.
EDIT: This temporarily adds CocoaPods to your path. I am using a Mac that uses a zsh shell for the terminal.app. I'm not sure what shell you have, but for Macs you'll need to edit your .zshrc file (or create one because you will not have a .zshrc file on your Mac if you have not created one yourself already). I found this answer that shows how to create the .zshrc file through the terminal. You can find the .zshrc file you have created by navigating to Macintosh HD > Users > [INSERT_USERNAME] and pressing "cmd + shift + ." to show hidden files. Scroll down until you see the .zshrc file, open it with a text editor, and input the code from the first page I linked. Save it and exit. Now you should always have CocoaPods in your path every time you open up the terminal!
Probably an easier way to do this, but it worked for me.

After installing go and setting my path, I am still getting an error

After installing golang according to the instructions on the golang website, I set the path as it said to by using export PATH=$PATH:/usr/local/go/bin and whenever I use the command $HOME/go it says bash: /home/ken/go: No such file or directory
I can verify go is installed and I even reset my computer to make sure the changes took place. Does anybody know what I can do to resolve this issue? Am I missing something?
As per the instructions on the Go installation page, you do need to manually create the go folder:
cd $HOME
mkdir go
cd go
Then create your first go program: https://gobyexample.com/hello-world
And run with go run hello-world.go. Should be good ;)

Issues installing a go program

Im new to go and I have been unable to find any thing online for my issue.
I have downloaded this code https://github.com/hashicorp/http-echo and I would like to set it up so I can run this command.
$ http-echo -listen=:8080 -text="hello world"
I have been getting quite a few different path issues.
Currently I have the code sitting in this directory.
/Users/jon/go/src/github.com/hashicorp
When I try and install it I get this error
$ go install http-echo
can't load package: /usr/local/go/src/http-echo/handlers.go:9:2: non-standard import "github.com/hashicorp/http-echo/version" in standard package "http-echo"
Where should I keep go projects on an OSX computer, and how do I get this to install or compile?
The code currently seems to be in /usr/local/go/src/http-echo. Packages should always reside in the directory $GOPATH/src/package-name, e.g.: $GOPATH/src/github.com/hashicorp/http-echo. (unless you're using go modules).
It should work if you move the source to the correct path (/Users/jon/go/src/github.com/hashicorp/http-echo). Then execute:
go install github.com/hashicorp/http-echo
Even easier would be to use go get to download the package in the first place. Simply run the following command from any directory:
go get github.com/hashicorp/http-echo
And http-echo is automagically installed.
If you still get an error after this, make sure $GOPATH/bin is in your $PATH.

go 1.5 : Is "go install" behaviour changed? Removing stale executables?

Till Go 1.4.2 when i run go install after running go build, i could find binary file in my current folder. Hence following Linux command was working
$ go build && go install && ./executable
But after installing go 1.5, when i run same command i get,
-bash: ./executable: No such file or directory
and when i checked, there is no executable to find. Did go install behavior changed in Go 1.5?
Yes, the behaviour has changed in Go 1.5:
If 'go install' (with no arguments, meaning the current directory) succeeds, remove the executable written by 'go build', if present. This avoids leaving a stale binary behind during a sequence like:
go build
<test, mostly works, make small change>
go install
Before this CL, the current directory still has the stale binary from 'go build'. If $PATH contains dot, running the name of the program will find this stale binary instead of the new, installed one.
I can't find anything mentioning that in the release notes though. Might be a documentation issue.
It seems like the solution is to use the binary that go install has produced.
EDIT: Here is the issue on the Go issue tracker if you want to follow on updates. Should be fixed by 1.5.1.

package download fails , "GOPATH not set." why?

OS: Ubuntu 12.04
Go version reporting: 1.1.1
Action:
I have configured the .profile to contain the following lines:
export GOPATH="$HOME/workspace"
export PATH=$PATH:$GOPATH/bin
I have ensured that they are set in the go configuration by running "go env". However when I try to run the command, the screen reports as shown in the image below:
Possible constraining issues:
1) The box originally had Go v1.0 on it and I upgraded it to go version1.1.1, not sure that should mean anything...but if there is some twin configuration madness at work that may explain the fact it's not working despite the path being set.
2) I had the export commands in the .profile file but I see some threads indicate to put it in .bashrc, trying in either still gives the same problem.
Do I need to uninstall go 1.0 ? I just assumed version 1.1.1 would over ride it but that could be wrong. Ideally I wanted to uninstall go entirely and then install version 1.1.2 but I couldn't find anything at golang.org on uninstalling assuming that does solve the problem.
Thanks in advance for any assistance.
As the commenter above stated, you should not use sudo with go get. When you do, you have the root user's environment (which doesn't have your GOPATH) and any files or directories it creates won't be editable by your user. In the past, the go get command would not warn about not having a $GOPATH and so it was easier to get tripped up by this.
To fix your permissions, run the following command to change ownership back to your user:
sudo chown -R "$USER:" "$GOPATH"
You should only ever need to run a plain go get because you can (and should) set your $GOPATH to be a directory you can control. Be sure to read the How To Write Go Code and in particular its discusson on GOPATH.

Resources