Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

Commit

Permalink
add doc for hack tool
Browse files Browse the repository at this point in the history
  • Loading branch information
huandu committed Aug 18, 2016
1 parent eb5e1f8 commit 59145d4
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions hack/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Hack Go Runtime #

This is a hack tool to copy const and type declarations from go source and inject hacked code.
With this hack, it's possible to expose any interesting type to wild world.

## Play with it ##

Download a go src tar file from https://golang.org/dl/, extract all files to a folder and
run following command.

./hack.sh path-to-go-src

## How it works ##

The basic idea is quite simple: If we can get internal type declarations and make it public,
then we can use it easily. So what I do is to parse all interesting go source files and copy
types to a folder and inject some hacked code to make some types public.

The `generator.go` is the key file to make it happen. It loads all hacks and walk through
all AST tree nodes in a file to find out all constants and types. It works quite well with
internal package and ignored files, as these features are required for go1.6 and greater.

There is only 1 hack implemented in `runtime_hacker.go`. If we want to add more hacks, just
implement more hacker files.

0 comments on commit 59145d4

Please sign in to comment.