Creating a package
suggest changeCreate 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.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents