Reputation: 2884
I am new to Go, and I have prepared my work space according to the How to write go code
But now I am confused how go
tool gets the path of packages like fmt
, strings
or my own packages.
As in C language we provide the path of header file by -I
and linker path by -L
but in Go we have given two paths GOHOME
and GOPATH
and both paths are of bin directories none of them specify the package path.
Upvotes: 0
Views: 182
Reputation: 774
$GOPATH
is a colon (or semicolon on Windows) separated list of paths to Go workspaces (with the {bin,pkg,src} structure). The go tools will automatically look for packages and source files in those paths when compiling and linking your programs.
Upvotes: 0
Reputation: 6545
As is explained in the article you linked, GOPATH
(and other go locations) should be layed out with a "pkg" directory for compiled libraries, and a "src" directory for library sources. They are not just bin directories.
Upvotes: 2