Giter Club home page Giter Club logo

twist's Introduction

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:

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

usage

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

Using the example in this repo:

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

To set up your own configuration:

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:

github.com/bobheadxi/go
|-- CNAME (go.bobheadxi.dev)
|-- README.md
|-- gobenchdata
|    +-- index.html (go.bobheadxi.dev/gobenchdata)
|-- package1
|    +-- index.html (go.bobheadxi.dev/package1)
+-- package2
     +-- index.html (go.bobheadxi.dev/package2)

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

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:

module go.bobheadxi.dev/twist

go 1.12

require ( ... )

twist's People

Contributors

bobheadxi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

isgasho

twist's Issues

go get subdirectories

/u/earthboundkid pointed out this post:

https://npf.io/2016/10/vanity-imports-with-hugo/

It mentions a workaround for using go get on nested directories, which Twist doesn't account for right now:

โฏ go get go.bobheadxi.dev/gobenchdata/x/gobenchdata-web
package go.bobheadxi.dev/gobenchdata/x/gobenchdata-web: unrecognized import path "go.bobheadxi.dev/gobenchdata/x/gobenchdata-web" (parse https://go.bobheadxi.dev/gobenchdata/x/gobenchdata-web?go-get=1: no go-import meta tags ())

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.