1
0
Fork
You've already forked importgen
0
Generate static HTML sites to support custom Go package import paths.
  • Go 73.1%
  • HTML 26.2%
  • Dockerfile 0.7%
2025年10月24日 21:40:51 +02:00
.forgejo/workflows ci: update release workflow [skip ci] 2025年10月24日 21:40:51 +02:00
templates feat: mark private packages 2025年09月09日 23:23:14 +02:00
testdata feat: mark private packages 2025年09月09日 23:23:14 +02:00
.gitignore feat: generate html from package definitions 2025年09月08日 20:01:09 +02:00
Dockerfile feat: add Docker build action 2025年09月09日 13:00:40 +02:00
go.mod tests: add test cases 2025年09月09日 13:35:34 +02:00
go.sum tests: add test cases 2025年09月09日 13:35:34 +02:00
importgen.go docs: update README and Go docs [skip ci] 2025年10月19日 15:08:55 +02:00
importgen_test.go docs: update README and Go docs [skip ci] 2025年10月19日 15:08:55 +02:00
LICENSE initial commit 2025年08月25日 01:15:05 +02:00
main.go chore: initial release 2025年10月24日 21:32:59 +02:00
README.md docs: update README and Go docs [skip ci] 2025年10月19日 15:08:55 +02:00
template.go docs: update README and Go docs [skip ci] 2025年10月19日 15:08:55 +02:00

importgen

Go Reference

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) If true, 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) If true, 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.