How do I make go find my package?

go

Solution

Set your GOPATH. Put your package foo source(s) in GOPATH/src/optional-whatever/foo/*.go and use it in code as

import "optional-whatever/foo"

You don't need to explicitly install foo, the go tool is a build tool, it will do that automagically for you whenever necessary.

Problem

Where should I put my package so that it can be imported by another package? ``` $ tree . ├── main.go └── src └── test.go 1 directory, 2 files $ cat src/test.go package test $ cat main.go package main import "test" $ go build main.go main.go:3:8: import "test": cannot find package ```

Original source