项目作者: bobheadxi

项目描述 :
📡 Static and serverless canonical imports for your Go packages
高级语言: Go
项目地址: git://github.com/bobheadxi/twist.git
创建时间: 2019-05-06T17:56:31Z
项目社区:https://github.com/bobheadxi/twist

开源协议:MIT License

下载


twist

Twist generates canonical imports for your Go packages. Since it does not require
a running server (ie in existing tools like uber-go/sally
and rsc/go-import-redirector),
Twist is particularly useful in conjunction with GitHub Pages.

A canonical import path allows you to make your package import a little fancier
with a custom domain, for example:

  1. - import "github.com/bobheadxi/zapx"
  2. + import "go.bobheadxi.dev/zapx"

usage

  1. go get -u go.bobheadxi.dev/twist
  2. # [ source ] [ canonical ]
  3. twist -o x github.com/bobheadxi/zapx go.bobheadxi.dev/zapx

Using the example in this repo:

  1. twist -c twist.example.yml -o x -readme

To set up your own configuration:

  1. twist config

You’ll want to commit the generated files to the GitHub Page repository of the
domain you want to use for your custom import path. For example, I used Twist to
set up my go.bobheadxi.dev/... import paths using
GitHub Pages. The repository is here, and has
the following layout:

  1. github.com/bobheadxi/go
  2. |-- CNAME (go.bobheadxi.dev)
  3. |-- README.md
  4. |-- gobenchdata
  5. | +-- index.html (go.bobheadxi.dev/gobenchdata)
  6. |-- package1
  7. | +-- index.html (go.bobheadxi.dev/package1)
  8. +-- package2
  9. +-- index.html (go.bobheadxi.dev/package2)

GitHub Pages serves up the contents of the repository, allowing packages to
be served with my custom domain:

  1. go get go.bobheadxi.dev/gobenchdata

In your Go package, you’ll need to update all import paths to use the new name.

When using Go Modules, you’ll also
need to update the module directive in your go.mod:

  1. module go.bobheadxi.dev/twist
  2. go 1.12
  3. require ( ... )