Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

Commit

Permalink
improve rand.Read error message
Browse files Browse the repository at this point in the history
  • Loading branch information
zensh committed May 2, 2017
1 parent 2b9acce commit 2c8a3a1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ sudo: false
language: go
go:
- 1.8
- 1.8.1
before_install:
- go get -t -v ./...
- go get github.com/mattn/goveralls
Expand Down
8 changes: 4 additions & 4 deletions crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func Equal(a, b []byte) bool {
func RandN(size int) []byte {
b := make([]byte, size)
if _, err := rand.Read(b); err != nil {
panic(err)
panic("rand.Read() failed: " + err.Error())
}
return b
}
Expand Down Expand Up @@ -249,7 +249,7 @@ func VerifyState(key []byte, uid, state string, expire time.Duration) bool {
//
type Rotating []interface{}

// Verify verify with fn and keys, if Verify failure, it return -1, other the index of key.
// Verify verify with fn and keys, if Verify failure, it return -1, otherwise the index of key.
func (r Rotating) Verify(fn func(interface{}) bool) (index int) {
for i, key := range r {
if fn(key) {
Expand All @@ -262,7 +262,7 @@ func (r Rotating) Verify(fn func(interface{}) bool) (index int) {
// RotatingStr is similar to Rotating.
type RotatingStr []string

// Verify verify with fn and keys, if Verify failure, it return -1, other the index of key.
// Verify verify with fn and keys, if Verify failure, it return -1, otherwise the index of key.
func (r RotatingStr) Verify(fn func(string) bool) (index int) {
for i, key := range r {
if fn(key) {
Expand All @@ -275,7 +275,7 @@ func (r RotatingStr) Verify(fn func(string) bool) (index int) {
// RotatingBytes is similar to Rotating.
type RotatingBytes [][]byte

// Verify verify with fn and keys, if Verify failure, it return -1, other the index of key.
// Verify verify with fn and keys, if Verify failure, it return -1, otherwise the index of key.
func (r RotatingBytes) Verify(fn func([]byte) bool) (index int) {
for i, key := range r {
if fn(key) {
Expand Down

0 comments on commit 2c8a3a1

Please sign in to comment.