Creating a package

suggest change

So you want to create a Go package.

You can use any source code hosting service. For this tutorial let’s assume that you’re using, your account is kjk and you want to create package foo.

Create a repository foo on GitHub.

Create a directory $GOPATH/src/ and checkout repository foo there:

$ mkdir -p $GOPATH/src/
$ cd $GOPATH/src/
$ git clone

Create a file main.go:

package foo

func Bar() string {
    return "bar"

This is a simplest package that defines function Bar.

Notice that package name foo matches directory name foo. It’s not required but recommended.

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents