Skip to content

Commit 6af3c98

Browse files
fix: Use err instead of error as a variable name for errors (#746) (#748)
fix #745 (cherry picked from commit f6c5753) Co-authored-by: Suhaib Mujahid <[email protected]>
1 parent a8763ea commit 6af3c98

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

git.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,9 @@ func NewOid(s string) (*Oid, error) {
200200

201201
o := new(Oid)
202202

203-
slice, error := hex.DecodeString(s)
204-
if error != nil {
205-
return nil, error
203+
slice, err := hex.DecodeString(s)
204+
if err != nil {
205+
return nil, err
206206
}
207207

208208
if len(slice) != 20 {

odb_test.go

+19-19
Original file line numberDiff line numberDiff line change
@@ -61,31 +61,31 @@ func TestOdbStream(t *testing.T) {
6161

6262
_, _ = seedTestRepo(t, repo)
6363

64-
odb, error := repo.Odb()
65-
checkFatal(t, error)
64+
odb, err := repo.Odb()
65+
checkFatal(t, err)
6666

6767
str := "hello, world!"
6868

69-
writeStream, error := odb.NewWriteStream(int64(len(str)), ObjectBlob)
70-
checkFatal(t, error)
71-
n, error := io.WriteString(writeStream, str)
72-
checkFatal(t, error)
69+
writeStream, err := odb.NewWriteStream(int64(len(str)), ObjectBlob)
70+
checkFatal(t, err)
71+
n, err := io.WriteString(writeStream, str)
72+
checkFatal(t, err)
7373
if n != len(str) {
7474
t.Fatalf("Bad write length %v != %v", n, len(str))
7575
}
7676

77-
error = writeStream.Close()
78-
checkFatal(t, error)
77+
err = writeStream.Close()
78+
checkFatal(t, err)
7979

80-
expectedId, error := NewOid("30f51a3fba5274d53522d0f19748456974647b4f")
81-
checkFatal(t, error)
80+
expectedId, err := NewOid("30f51a3fba5274d53522d0f19748456974647b4f")
81+
checkFatal(t, err)
8282
if writeStream.Id.Cmp(expectedId) != 0 {
8383
t.Fatal("Wrong data written")
8484
}
8585

86-
readStream, error := odb.NewReadStream(&writeStream.Id)
87-
checkFatal(t, error)
88-
data, error := ioutil.ReadAll(readStream)
86+
readStream, err := odb.NewReadStream(&writeStream.Id)
87+
checkFatal(t, err)
88+
data, err := ioutil.ReadAll(readStream)
8989
if str != string(data) {
9090
t.Fatalf("Wrong data read %v != %v", str, string(data))
9191
}
@@ -98,8 +98,8 @@ func TestOdbHash(t *testing.T) {
9898

9999
_, _ = seedTestRepo(t, repo)
100100

101-
odb, error := repo.Odb()
102-
checkFatal(t, error)
101+
odb, err := repo.Odb()
102+
checkFatal(t, err)
103103

104104
str := `tree 115fcae49287c82eb55bb275cbbd4556fbed72b7
105105
parent 66e1c476199ebcd3e304659992233132c5a52c6c
@@ -109,11 +109,11 @@ committer John Doe <[email protected]> 1390682018 +0000
109109
Initial commit.`
110110

111111
for _, data := range [][]byte{[]byte(str), doublePointerBytes()} {
112-
oid, error := odb.Hash(data, ObjectCommit)
113-
checkFatal(t, error)
112+
oid, err := odb.Hash(data, ObjectCommit)
113+
checkFatal(t, err)
114114

115-
coid, error := odb.Write(data, ObjectCommit)
116-
checkFatal(t, error)
115+
coid, err := odb.Write(data, ObjectCommit)
116+
checkFatal(t, err)
117117

118118
if oid.Cmp(coid) != 0 {
119119
t.Fatal("Hash and write Oids are different")

0 commit comments

Comments
 (0)