Creating a package

suggest change

Create a repository for the package. This example uses the module path github.com/kjk/foo.

Clone the repository in any convenient directory and initialize a module:

git clone https://github.com/kjk/foo
cd foo
go mod init github.com/kjk/foo

Create a file named foo.go:

package foo

func Bar() string {
    return "bar"
}

This minimal package defines the exported function Bar. A package name usually matches its directory name, although Go does not require that.

Feedback about page:

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



Table Of Contents