Getting started problem: GOPATH routing problem

hey guys I am having an issue with pathing as it is right now this is my .zshrc file:

export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin

my app main.go is just a stereotypical “hello world” with fmt
when I run the command:
$ go run src/github.com/ctfrancia/firstapp/main.go
I get the expected outcome Hello! in terminal.
however, when running:
$ go build src/github.com/ctfrancia/firstapp
I get this error:

can’t load package: package src/github.com/ctfrancia/firstapp: cannot find package “src/github.com/ctfrancia/firstapp” in any of:
/usr/local/Cellar/go/1.12.6/libexec/src/src/github.com/ctfrancia/firstapp (from $GOROOT)
/Users/c.francia/go/src/src/github.com/ctfrancia/firstapp (from $GOPATH)

I installed go using Homebrew (as I found many recommendations in doing so if I should do it differently I’m up for recommendations) what I notice is that on the third line there is src/src/github.... but that second src folder doesn’t exist, which might be the issue?
Thank you for any help and I look forward to learning and growing more with this language!

go run when given a .go file, will treat the argument as a path to the file and resolve packages from there.

go build though wants a packagepath, and the package you want to build is actually github.com/ctfrancia/firstapp.

1 Like

thank you NobbZ sorry for the very dumb question

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