Source code:

Canon is a tool to add canonical import paths to Go packages.

For example, given a file located at $GOPATH/ with the following contents:

// Package foo docs here.
package foo

Canon will update this file as:

// Package foo docs here.
package foo // import ""

Canon will only modify a single go source file per package. If there are multiple source files for the package, it will try to use the file that declares the package-level documentation. If there is no package documentation, it will then try to find a source file with the same name as the package. For example, for package main, it will try main.go. If that still fails, it will print an error message.


go get