gocompiler-errorsgoogle-url-shortenergoogle-api-go-client

6g: command not found error while compiling external API code in Go


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

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

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.


Solution

  • 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: