Selaa lähdekoodia

snappy: error rename gofix.

R=bradfitz
CC=golang-dev
http://codereview.appspot.com/5320072
Nigel Tao 14 vuotta sitten
vanhempi
commit
aa4590f451
3 muutettua tiedostoa jossa 10 lisäystä ja 13 poistoa
  1. 8 8
      snappy/decode.go
  2. 1 3
      snappy/encode.go
  3. 1 2
      snappy/snappy_test.go

+ 8 - 8
snappy/decode.go

@@ -5,29 +5,29 @@
 package snappy
 
 import (
-	"os"
+	"errors"
 
 	"snappy-go.googlecode.com/hg/varint"
 )
 
 // ErrCorrupt reports that the input is invalid.
-var ErrCorrupt = os.NewError("snappy: corrupt input")
+var ErrCorrupt = errors.New("snappy: corrupt input")
 
 // DecodedLen returns the length of the decoded block.
-func DecodedLen(src []byte) (int, os.Error) {
+func DecodedLen(src []byte) (int, error) {
 	v, _, err := decodedLen(src)
 	return v, err
 }
 
 // decodedLen returns the length of the decoded block and the number of bytes
 // that the length header occupied.
-func decodedLen(src []byte) (blockLen, headerLen int, err os.Error) {
+func decodedLen(src []byte) (blockLen, headerLen int, err error) {
 	v, n := varint.Decode(src)
 	if n == 0 {
 		return 0, 0, ErrCorrupt
 	}
 	if uint64(int(v)) != v {
-		return 0, 0, os.NewError("snappy: decoded block is too large")
+		return 0, 0, errors.New("snappy: decoded block is too large")
 	}
 	return int(v), n, nil
 }
@@ -36,7 +36,7 @@ func decodedLen(src []byte) (blockLen, headerLen int, err os.Error) {
 // slice of dst if dst was large enough to hold the entire decoded block.
 // Otherwise, a newly allocated slice will be returned.
 // It is valid to pass a nil dst.
-func Decode(dst, src []byte) ([]byte, os.Error) {
+func Decode(dst, src []byte) ([]byte, error) {
 	dLen, s, err := decodedLen(src)
 	if err != nil {
 		return nil, err
@@ -80,7 +80,7 @@ func Decode(dst, src []byte) ([]byte, os.Error) {
 			}
 			length = int(x + 1)
 			if length <= 0 {
-				return nil, os.NewError("snappy: unsupported literal length")
+				return nil, errors.New("snappy: unsupported literal length")
 			}
 			if length > len(dst)-d || length > len(src)-s {
 				return nil, ErrCorrupt
@@ -107,7 +107,7 @@ func Decode(dst, src []byte) ([]byte, os.Error) {
 			offset = int(src[s-2]) | int(src[s-1])<<8
 
 		case tagCopy4:
-			return nil, os.NewError("snappy: unsupported COPY_4 tag")
+			return nil, errors.New("snappy: unsupported COPY_4 tag")
 		}
 
 		end := d + length

+ 1 - 3
snappy/encode.go

@@ -5,8 +5,6 @@
 package snappy
 
 import (
-	"os"
-
 	"snappy-go.googlecode.com/hg/varint"
 )
 
@@ -88,7 +86,7 @@ func emitCopy(dst []byte, offset, length int) int {
 // slice of dst if dst was large enough to hold the entire encoded block.
 // Otherwise, a newly allocated slice will be returned.
 // It is valid to pass a nil dst.
-func Encode(dst, src []byte) ([]byte, os.Error) {
+func Encode(dst, src []byte) ([]byte, error) {
 	if n := MaxEncodedLen(len(src)); len(dst) < n {
 		dst = make([]byte, n)
 	}

+ 1 - 2
snappy/snappy_test.go

@@ -8,13 +8,12 @@ import (
 	"bytes"
 	"fmt"
 	"io/ioutil"
-	"os"
 	"rand"
 	"strings"
 	"testing"
 )
 
-func roundtrip(b []byte) os.Error {
+func roundtrip(b []byte) error {
 	e, err := Encode(nil, b)
 	if err != nil {
 		return fmt.Errorf("encoding error: %v", err)