|
| 1 | +[](https://travis-ci.org/spatialcurrent/go-reader-writer) [](https://goreportcard.com/report/spatialcurrent/go-reader-writer) [](https://godoc.org/github.com/spatialcurrent/go-reader-writer) [](https://github.com/spatialcurrent/go-reader-writer/blob/master/LICENSE) |
| 2 | + |
| 3 | +# go-reader-writer |
| 4 | + |
| 5 | +# Description |
| 6 | + |
| 7 | +**go-reader-writer** (aka GRW) is a simple library for managing reading/writing of resources. GRW can read from `bzip2`, `gzip`, `snappy`, and `zip` resources and write to `gzip` and `snappy` resources. |
| 8 | + |
| 9 | +Using cross compilers, this library can also be called by other languages. This library is cross compiled into a Shared Object file (`*.so`). The Shared Object file can be called by `C`, `C++`, and `Python` on Linux machines. See the examples folder for patterns that you can use. This library is also compiled to pure `JavaScript` using [GopherJS](https://github.com/gopherjs/gopherjs). |
| 10 | + |
| 11 | +# Usage |
| 12 | + |
| 13 | +**CLI** |
| 14 | + |
| 15 | +You can use the command line tool to convert between formats. |
| 16 | + |
| 17 | +``` |
| 18 | +Usage: grw [-input_uri INPUT_URI] [-input_compression [bzip2|gzip|snappy|zip|none]] [-output_uri OUTPUT_URI] [-output_compression [bzip2|gzip|snappy|zip|none]] [-verbose] [-version] |
| 19 | +Options: |
| 20 | + -aws_access_key_id string |
| 21 | + Defaults to value of environment variable AWS_ACCESS_KEY_ID |
| 22 | + -aws_default_region string |
| 23 | + Defaults to value of environment variable AWS_DEFAULT_REGION. |
| 24 | + -aws_secret_access_key string |
| 25 | + Defaults to value of environment variable AWS_SECRET_ACCESS_KEY. |
| 26 | + -aws_session_token string |
| 27 | + Defaults to value of environment variable AWS_SESSION_TOKEN. |
| 28 | + -help |
| 29 | + Print help |
| 30 | + -input_buffer_size int |
| 31 | + the input reader buffer size (default 4096) |
| 32 | + -input_compression string |
| 33 | + Stream input compression algorithm for nodes, using: bzip2, gzip, snappy, zip, or none. |
| 34 | + -input_uri string |
| 35 | + "stdin" or uri to input file (default "stdin") |
| 36 | + -output_append |
| 37 | + append output to resource |
| 38 | + -output_buffer_size int |
| 39 | + the output writer buffer size (default 4096) |
| 40 | + -output_compression string |
| 41 | + Stream input compression algorithm for nodes, using: bzip2, gzip, snappy, zip, or none. |
| 42 | + -output_uri string |
| 43 | + "stdout" or uri to output resource (default "stdout") |
| 44 | + -version |
| 45 | + Prints version to stdout |
| 46 | +``` |
| 47 | + |
| 48 | +**Go** |
| 49 | + |
| 50 | +You can import **go-reader-writer** as a library with: |
| 51 | + |
| 52 | +```go |
| 53 | +import ( |
| 54 | + "github.com/spatialcurrent/go-reader-writer/grw" |
| 55 | +) |
| 56 | +... |
| 57 | +``` |
| 58 | + |
| 59 | +See [grw](https://godoc.org/github.com/spatialcurrent/go-reader-writer/grw) in GoDoc for information on how to use Go API. |
| 60 | + |
| 61 | +**JavaScript** |
| 62 | + |
| 63 | +```html |
| 64 | +<html> |
| 65 | + <head> |
| 66 | + <script src="https://...grw.js"></script> |
| 67 | + </head> |
| 68 | + <body> |
| 69 | + <script> |
| 70 | + grw.open(uri, "none", function(text){ ... }) |
| 71 | + ... |
| 72 | + </script> |
| 73 | + </body> |
| 74 | +</html> |
| 75 | +``` |
| 76 | + |
| 77 | +# Examples: |
| 78 | + |
| 79 | +TBD |
| 80 | + |
| 81 | +# Building |
| 82 | + |
| 83 | +**CLI** |
| 84 | + |
| 85 | +The command line go-reader-wrtier program can be built with the `scripts/build_cli.sh` script. |
| 86 | + |
| 87 | +**JavaScript** |
| 88 | + |
| 89 | +You can compile go-reader-writer to pure JavaScript with the `scripts/build_javascript.sh` script. |
| 90 | + |
| 91 | +**Shared Object** |
| 92 | + |
| 93 | +The `scripts/build_so.sh` script is used to build a Shared Object (`*.go`), which can be called by `C`, `C++`, and `Python` on Linux machines. |
| 94 | + |
| 95 | +**Changing Destination** |
| 96 | + |
| 97 | +The default destination for build artifacts is `go-reader/bin`, but you can change the destination with a CLI argument. For building on a Chromebook consider saving the artifacts in `/usr/local/go/bin`, e.g., `bash scripts/build_cli.sh /usr/local/go/bin` |
| 98 | + |
| 99 | +# Contributing |
| 100 | + |
| 101 | +[Spatial Current, Inc.](https://spatialcurrent.io) is currently accepting pull requests for this repository. We'd love to have your contributions! Please see [Contributing.md](https://github.com/spatialcurrent/go-reader-writer/blob/master/CONTRIBUTING.md) for how to get started. |
| 102 | + |
| 103 | +# License |
| 104 | + |
| 105 | +This work is distributed under the **MIT License**. See **LICENSE** file. |
0 commit comments