This question already has an answer here:
OK, Go's major selling point is its ease of compilation and wonderful toolchain, but as a go newbie I'm really lost there and can't understand the documentation on that point.
I have a stack toy example within two files (one for the type definition and methods, called stack.go
, one for the main program, called main.go
), both are in my GOPATH/src/stacker
directory.
stacker
?main.go
, how should I use the import
directive to import stack.go
?I have tried many combinations, none working until now.
</div>
_test
and _<arch>
(_darwin
, _unix
, etc.). Also note that files prefixed with .
or _
won't be compiled into the package!package mypkg
stack.go
is in the same folder/package as main.go
, you don't need to import. Everything delcared in stack.go
is already available in main.go
, because it is in the same package.If stacker
should compile into an executable, you should use package main
.