diff --git a/base83/error.go b/base83/error.go index 3f1e663..54174f7 100644 --- a/base83/error.go +++ b/base83/error.go @@ -1,13 +1,10 @@ -// +build !go1.13 - package base83 import "errors" +// ErrInvalidInput is returned when the given input to decode is not valid base83. var ErrInvalidInput = errors.New("base83: invalid input") -var ErrInvalidLength = errors.New("base83: invalid length") -// invalidError returns ErrInvalidInput for the given rune and index func invalidError(r rune, i int) error { // No stdlib support for wrapped errors, so return as-is pre-1.13 return ErrInvalidInput diff --git a/base83/error_go1.13.go b/base83/error_go1.13.go deleted file mode 100644 index 3f0a04c..0000000 --- a/base83/error_go1.13.go +++ /dev/null @@ -1,9 +0,0 @@ -// +build go1.13 - -package base83 - -import "fmt" - -func invalidError(c rune, i int) error { - return fmt.Errorf("illegal rune %v at index %d: %w", c, i, ErrInvalidInput) -} diff --git a/decode.go b/decode.go index 847704a..ad18f54 100644 --- a/decode.go +++ b/decode.go @@ -27,6 +27,7 @@ func Components(hash string) (x, y int, err error) { return x, y, nil } +// Decode returns an image of the given hash with the given size. func Decode(hash string, width, height int, punch int) (img image.Image, err error) { numX, numY, err := Components(hash) if err != nil { diff --git a/error.go b/error.go index b18c410..528858c 100644 --- a/error.go +++ b/error.go @@ -1,5 +1,3 @@ -// +build !go1.13 - package blurhash import "errors" diff --git a/error_go1.13.go b/error_go1.13.go deleted file mode 100644 index 0c408ea..0000000 --- a/error_go1.13.go +++ /dev/null @@ -1,9 +0,0 @@ -// +build go1.13 - -package blurhash - -import "fmt" - -func lengthError(expectedLength, actualLength int) error { - return fmt.Errorf("expected hash length %d but got %d: %w", expectedLength, actualLength, ErrInvalidHash) -} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..500c810 --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module github.com/bbrks/go-blurhash + +go 1.12 + +require github.com/matryer/is v1.2.0 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..6378c9b --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A= +github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA=