ipld-eth-server/vendor/github.com/golang/snappy/cmd/snappytool/main.go
Rob Mulholand 560305f601 Update dependencies
- uses newer version of go-ethereum required for go1.11
2018-09-13 16:14:35 -05:00

47 lines
682 B
Go

package main
import (
"errors"
"flag"
"io/ioutil"
"os"
"github.com/golang/snappy"
)
var (
decode = flag.Bool("d", false, "decode")
encode = flag.Bool("e", false, "encode")
)
func run() error {
flag.Parse()
if *decode == *encode {
return errors.New("exactly one of -d or -e must be given")
}
in, err := ioutil.ReadAll(os.Stdin)
if err != nil {
return err
}
out := []byte(nil)
if *decode {
out, err = snappy.Decode(nil, in)
if err != nil {
return err
}
} else {
out = snappy.Encode(nil, in)
}
_, err = os.Stdout.Write(out)
return err
}
func main() {
if err := run(); err != nil {
os.Stderr.WriteString(err.Error() + "\n")
os.Exit(1)
}
}