From 0c995c4059b8de70115ae5e7c89b1a70ec6fea41 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Tue, 13 Dec 2016 13:18:58 -0500 Subject: [PATCH] main: vet, lint, and travis Signed-off-by: Vincent Batts --- .travis.yml | 20 ++++++++++++++++++++ main.go | 7 +++++-- 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..85dcfcb --- /dev/null +++ b/.travis.yml @@ -0,0 +1,20 @@ +language: go +go: + - 1.7.4 + - 1.6.3 + +sudo: false + +before_install: + - git config --global url."https://".insteadOf git:// + - go get -u github.com/golang/lint/golint + - mkdir -p $GOPATH/src/github.com/vbatts && ln -sf $(pwd) $GOPATH/src/github.com/vbatts/emojisum + - go get -d ./... + +install: true + +script: + - go vet ./... + - golint -set_exit_status ./... + - go test -v ./... + - go build . diff --git a/main.go b/main.go index aa84487..e6f88b4 100644 --- a/main.go +++ b/main.go @@ -49,7 +49,7 @@ func run() error { fmt.Printf("%s(%s)= ", hash, name) emoji.Println(str) } - return nil + // never gets here because of the return on EOF or err } if *flParseCoreUtils { buf := bufio.NewReader(os.Stdin) @@ -71,7 +71,7 @@ func run() error { emoji.Print(str) fmt.Printf(" %s\n", name) } - return nil + // never gets here because of the return on EOF or err } // Otherwise do the checksum ourselves @@ -135,6 +135,7 @@ func parseOpenSSL(line string) (hash, filename string, sum []byte, err error) { return chunksprime[0], chunksprime[1], sum, nil } +// ErrNotOpenSSLLine when the line to parse is not formated like an OpenSSL checksum line var ErrNotOpenSSLLine = errors.New("not an openssl checksum line") /* @@ -156,8 +157,10 @@ func parseCoreUtils(line string) (filename string, sum []byte, err error) { return chunks[1], sum, nil } +// ErrNotCoreUtilsLine when the line to parse is not formated like a coreutils checksum line var ErrNotCoreUtilsLine = errors.New("not a coreutils checksum line") +// Sum is a basic wrapper around crypto/sha1 func Sum(r io.Reader) ([]byte, error) { h := sha1.New() if _, err := io.Copy(h, r); err != nil {