I'm new to golang and I'm trying to write a program using this tutorial.
However I'm getting this error thrown while compiling it.
6g: command not found
Here's what I've tried:
$ go version
go version go1.4.1 darwin/amd64
Here's how my .bashrc looks like:
$ tail ~/.bashrc
export GOBIN=/Users/abhijeet/code/golang/go/bin
export GOROOT=/Users/abhijeet/code/golang/go
export GOPATH=/Users/abhijeet/code/golang/gopath
export GOOS="darwin"
export GOARCH="amd64"
export PATH="$GOBIN:$PATH"
Here's how it looks:
[ -r $HOME/.bashrc ] && source $HOME/.bashrc
If I quit the terminal, launch it again and echo any of the variables, they work.
I have gcc installed.
Here's what I get when I run "gcc --version" command:
$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.1.0
Thread model: posix
If I write any other go program and run it, it works. For instance, all the programs from section 1 through 5 from here, and till the "Go Templates - Part 3 - Template Sets" work just fine even now. Only this particular tutorial is troubling me.
None of the other programs I just gave link to, required me to run the "6g" command. But they still run on my machine.
About the line where I get error, I am using the right one to reflect folder names in my machine.
What they've asked to run:
6g -I $GOPATH/pkg/linux_amd64 urlshortener.go
What I'm running:
6g -I $GOPATH/pkg/darwin_amd64 urlshortener.go
All I can find is
darwin_amd64
├───code.google.com
│ ├───p
│ │ └───google-api-go-client
│ │ └───googleapi
│ │ │ └─── <more folders and files here>
│ │ └───urlshortener
│ │ │ └───v1.a
│ │ └───googleapi.a
│ │
So I know there's some problem there, but I also know that this probably isn't what is causing the error I'm seeing, otherwise I would have seen the error like "file not found". I just wanted to mention it as an additional data.
So I appreciate any help on this. Please let me know if I should provide any additional data as well.
It's an internal command, you can run it with go tool 6g
.
That being said, that guide is extremely outdated and not relevant anymore.
- To compile I used: 6g -I $GOPATH/pkg/linux_amd64 urlshortener.go
- To link I used: 6l -L $GOPATH/pkg/linux_amd64 urlshortener.6
Is replaced with simply running go build urlshortner.go
or even go run urlshortner.go
Few resources to check: