Trouble installing Go

I’ve tried installing Go from source and using the package installer. However, after following the steps in the installation guide, I started noticing that my go command does not work when I try to go install my goop.go package. Has anyone encountered this trouble before? Any help would be greatly appreciated! Thanks!

Set path variables

export GOPATH=$HOME/code/gospace
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin::/path/to/elixir/bin:/usr/local/bin/erl:$GOPATH:$PATH

Workspace

.
-- bin
-- pkg
-- src
    -- github.com
        -- danielleknudson
            -- goop
                 - README.md
                 - goop.go

Other things

danielle at Danielles-MacBook-Pro in ~/code/gospace$ which go
/usr/local/go/bin/go

danielle at Danielles-MacBook-Pro in ~$ go version
fatal: Not a git repository (or any of the parent directories): .git

danielle at Danielles-MacBook-Pro in ~$ go env
fatal: Not a git repository (or any of the parent directories): .git

danielle at Danielles-MacBook-Pro in ~$ env | grep GO
GOPATH=/Users/danielleknudson/code/gospace

goop.go

package main

import (
  "fmt"
)

func main() {
  fmt.Println("Hello, World.")
}

Append $GOPATH/bin to your path, not just GOPATH.

You can also run go build to output a binary to the current directory for main packages.

Do you have a shell alias go that maps to git checkout perhaps? This all seems very confusing otherwise.

4 Likes

That does sound the most likely.

Try using type go to see what your shell thinks go is - if it’s a shell function or alias it will be displayed, and if it’s really a binary it’ll show the path as per which.

3 Likes

Ha! I do. I wrote that a while ago, never used it, and forgot I had it. As soon as I removed that alias and updated my .bash_profile I had no trouble. Thank you.

1 Like

@calmh & @jamesog were right. Had an old alias I never used in my bash_profile, doh. Thank you all!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.