FAQ
Hi All,

It is likely I am having GOPATH issues here but I am unable to comprehend
in what way I have failed to set Go up. NUTS!

So I have Go version go1.0.3
Installed via the package installer for Mac OS X (go.1.0.3darwin-amd64.pkg)
GOROOT is /usr/local/go

I have my GOPATH set to /Users/pgonia/Development/projects/go

There I have a src and pkg directory.

I am attempting to install the example sqrt.go source
from http://golang.org/doc/code.html.

This source is located in the path $GOPATH/src/ptgSoft/examples/newmath

Running go install from the sources root ./ I get the following message:
go install: no install location for
_/Users/pgonia/Development/projects/go/src/ptgSoft/examples/newmath

Running it from $GOPATH/src with go install ptgSoft/examples/newmath yields:
can't load package: package ptgSoft/examples/newmath: import
"ptgSoft/examples/newmath": cannot find package

Again from $GOPATH/src/ptgSoft I get:
can't load package: package examples/newmath: import "examples/newmath":
cannot find package

Clearly I am not understanding the package concept for Go nor the build
process. I have read and re read the documentation I believe is most likely
to provide clarity but I am still missing the concept with go builds.

Thank you in advance.


--

Search Discussions

  • Andrew Gerrand at Oct 8, 2012 at 2:13 am

    On 6 October 2012 08:34, wrote:
    Hi All,

    It is likely I am having GOPATH issues here but I am unable to comprehend in
    what way I have failed to set Go up. NUTS!

    So I have Go version go1.0.3
    Installed via the package installer for Mac OS X (go.1.0.3darwin-amd64.pkg)
    GOROOT is /usr/local/go

    I have my GOPATH set to /Users/pgonia/Development/projects/go

    There I have a src and pkg directory.

    I am attempting to install the example sqrt.go source from
    http://golang.org/doc/code.html.

    This source is located in the path $GOPATH/src/ptgSoft/examples/newmath

    Running go install from the sources root ./ I get the following message:
    go install: no install location for
    _/Users/pgonia/Development/projects/go/src/ptgSoft/examples/newmath

    Running it from $GOPATH/src with go install ptgSoft/examples/newmath yields:
    can't load package: package ptgSoft/examples/newmath: import
    "ptgSoft/examples/newmath": cannot find package

    Again from $GOPATH/src/ptgSoft I get:
    can't load package: package examples/newmath: import "examples/newmath":
    cannot find package

    Clearly I am not understanding the package concept for Go nor the build
    process. I have read and re read the documentation I believe is most likely
    to provide clarity but I am still missing the concept with go builds.

    Thank you in advance.
    What's the output for "go env" ?

    --
  • Andrew Gerrand at Oct 8, 2012 at 9:19 pm
    Try putting "export" before GOPATH in .bash_profile

    export GOPATH=/path/to/workspace

    That'll give subprocesses of your shell access to that variable.

    Andrew
    On 9 Oct 2012 05:27, "Philip Gonia" wrote:

    Very interesting output:

    GOARCH="amd64"
    GOBIN=""
    GOCHAR="6"
    GOEXE=""
    GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread -fno-common"
    GOHOSTARCH="amd64"
    GOHOSTOS="darwin"
    GOOS="darwin"
    GOPATH=""
    GOROOT="/usr/local/go"
    GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
    CGO_ENABLED="1"

    I note that GOPATH here is empty while in terminal using the 'set' command
    I get

    GOPATH=/Users/pgonia/Development/projects/go

    I set GOPATH up in my local .bash_profile file. This works for terminal
    but not for go which I find odd.

    Phil


    On Oct 7, 2012, at 10:12 PM, Andrew Gerrand wrote:
    On 6 October 2012 08:34, wrote:
    Hi All,

    It is likely I am having GOPATH issues here but I am unable to
    comprehend in
    what way I have failed to set Go up. NUTS!

    So I have Go version go1.0.3
    Installed via the package installer for Mac OS X
    (go.1.0.3darwin-amd64.pkg)
    GOROOT is /usr/local/go

    I have my GOPATH set to /Users/pgonia/Development/projects/go

    There I have a src and pkg directory.

    I am attempting to install the example sqrt.go source from
    http://golang.org/doc/code.html.

    This source is located in the path $GOPATH/src/ptgSoft/examples/newmath

    Running go install from the sources root ./ I get the following message:
    go install: no install location for
    _/Users/pgonia/Development/projects/go/src/ptgSoft/examples/newmath

    Running it from $GOPATH/src with go install ptgSoft/examples/newmath
    yields:
    can't load package: package ptgSoft/examples/newmath: import
    "ptgSoft/examples/newmath": cannot find package

    Again from $GOPATH/src/ptgSoft I get:
    can't load package: package examples/newmath: import "examples/newmath":
    cannot find package

    Clearly I am not understanding the package concept for Go nor the build
    process. I have read and re read the documentation I believe is most
    likely
    to provide clarity but I am still missing the concept with go builds.

    Thank you in advance.
    What's the output for "go env" ?
    --

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedOct 5, '12 at 11:02p
activeOct 8, '12 at 9:19p
posts3
users2
websitegolang.org

2 users in discussion

Andrew Gerrand: 2 posts Phil Gonia: 1 post

People

Translate

site design / logo © 2021 Grokbase