<commit_before># go2flow

This is a simple tool that generates [Flow types](http://flowtype.org/), empty
value initializers, and JSON marshalling code from Go types.  This eliminates
some of the drudgery of keeping your frontend code consistent with an API
implemented in Go.

## Installation

```sh
go get -u github.com/shutej/go2flow/...
go install github.com/shutej/go2flow/cmd/go2flow
```

## Usage

The tool looks for a list of packages and types to convert from a YAML file, by
default looking for `go2flow.yml` in the current working directory.  This
package [includes an example](example/go2flow.yml) of just such a file.

You may consider making a synthetic package so `go generate` will compile your
Flow static assets for you:

```go
//go:generate go2flow --yml go2flow.yml --out out
```<commit_msg>added comments to readme<commit_after># go2flow

This is a simple tool that generates [Flow types](http://flowtype.org/), empty
value initializers, and JSON marshalling code from Go types.  This eliminates
some of the drudgery of keeping your frontend code consistent with an API
implemented in Go.

## Installation

```sh
go get -u github.com/shutej/go2flow/...
go install github.com/shutej/go2flow/cmd/go2flow
```

## Usage

The tool looks for a list of packages and types to convert from a YAML file, by
default looking for `go2flow.yml` in the current working directory.  This
package [includes an example](example/go2flow.yml) of just such a file.

This package has [example Go types](example/example.go) and
[the corresponding Flow-typed output](example/flow/).  Note, in particular,
[the custom time.Time implementation](example/flow/time_Time.js) which
demonstrates how Javascript can be customized for specific types using Go's
[Marshaler](http://golang.org/pkg/encoding/json/#Marshaler) and
[Unmarshaler](http://golang.org/pkg/encoding/json/#Unmarshaler).

You may consider making a synthetic package so `go generate` will compile your
Flow static assets for you:

```go
//go:generate go2flow --yml go2flow.yml --out out
```
{'fraction_non_alphanumeric': 0.09295499021526418, 'fraction_numerical': 0.007827788649706457, 'mean_word_length': 4.527027027027027, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6377485', 'n_tokens_mistral': 630, 'n_tokens_neox': 589, 'n_words': 256}