Generate static HTML sites to support custom Go package import paths.
- Go 73.1%
- HTML 26.2%
- Dockerfile 0.7%
| .forgejo/workflows | ci: update release workflow [skip ci] | |
| templates | feat: mark private packages | |
| testdata | feat: mark private packages | |
| .gitignore | feat: generate html from package definitions | |
| Dockerfile | feat: add Docker build action | |
| go.mod | tests: add test cases | |
| go.sum | tests: add test cases | |
| importgen.go | docs: update README and Go docs [skip ci] | |
| importgen_test.go | docs: update README and Go docs [skip ci] | |
| LICENSE | initial commit | |
| main.go | chore: initial release | |
| README.md | docs: update README and Go docs [skip ci] | |
| template.go | docs: update README and Go docs [skip ci] | |
importgen
importgen is a tool for generating static HTML pages that provide go-import and go-source meta tags. This allows you to use custom domains for your Go packages, while the source code is hosted on services like GitHub.
Usage
importgen [flags]
Flags:
-config <path> Path to the importgen.json configuration file. (defaults to "$CWD/importgen.json").
-out <path> Output directory of the generated HTML files. (defaults to "$CWD/public")
Configuration
The importgen.json file defines the hosts and packages to be served.
{
"hosts": {
"go.example.com": {
"index": true,
"packages": [
{
"path": "my-package",
"type": "git",
"repo": "https://github.com/user/my-package",
"source": {
"home": "https://github.com/user/my-package",
"dir": "https://github.com/user/my-package/tree/main/{dir}",
"file": "https://github.com/user/my-package/blob/main/{dir}/{file}#L{line}"
}
},
{
"path": "another-package",
"type": "git",
"repo": "https://github.com/user/another-package"
}
]
}
}
}
Configuration Fields:
hosts: A map where each key is a hostname.index: (boolean) Iftrue, an index page will be generated for the host, listing all its packages.packages: An array of package objects.path: (string) The path component of the Go import URL.type: (string) The version control system type (e.g., "git").repo: (string) The URL of the repository where the source code is hosted.subdir: (string, optional) The subdirectory within the repository where the package is located.main: (boolean, optional) Indicates if this is the main package.private: (boolean, optional) Iftrue, indicates the package is private.source: (object, optional) Provides URLs for browsing the source code.home: URL to the repository homepage.dir: URL template for directories.file: URL template for files.