Skip to content

Commit

Permalink
golint
Browse files Browse the repository at this point in the history
  • Loading branch information
nakagami committed Feb 12, 2021
1 parent 71a8166 commit de66cf9
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 30 deletions.
2 changes: 1 addition & 1 deletion connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (fc *firebirdsqlConn) Begin() (driver.Tx, error) {
// idle connections, it shouldn't be necessary for drivers to
// do their own connection caching.
func (fc *firebirdsqlConn) Close() (err error) {
for tx, _ := range fc.transactionSet {
for tx := range fc.transactionSet {
tx.Rollback()
}

Expand Down
9 changes: 3 additions & 6 deletions decfloat.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ import (
func dpdBitToInt(dpd uint, mask uint) int {
if (dpd & mask) != 0 {
return 1
} else {
return 0
}
return 0
}

func dpdToInt(dpd uint) int64 {
Expand Down Expand Up @@ -206,15 +205,13 @@ func decimal64ToDecimal(b []byte) decimal.Decimal {
if sign == 1 {
// Is there -NaN ?
return decimal.NewFromFloat(math.NaN())
} else {
return decimal.NewFromFloat(math.NaN())
}
return decimal.NewFromFloat(math.NaN())
} else if cf == 0x1e {
if sign == 1 {
return decimal.NewFromFloat(math.Inf(-1))
} else {
return decimal.NewFromFloat(math.Inf(1))
}
return decimal.NewFromFloat(math.Inf(1))
} else if (cf & 0x18) == 0x00 {
exponent = 0x000 + exponent
prefix = int64(cf & 0x07)
Expand Down
4 changes: 2 additions & 2 deletions srp.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func pad(v *big.Int) []byte {
n = big.NewInt(0)
n = n.Add(n, v)

for i, _ := range buf {
for i := range buf {
buf[i] = byte(m.And(m.SetInt64(255), n).Int64())
n = n.Div(n, m.SetInt64(256))
}
Expand Down Expand Up @@ -140,7 +140,7 @@ func getClientSeed() (keyA *big.Int, keya *big.Int) {
func getSalt() []byte {
buf := make([]byte, SRP_SALT_SIZE)
if DEBUG_SRP == false {
for i, _ := range buf {
for i := range buf {
buf[i] = byte(rand.Intn(256))
}
}
Expand Down
4 changes: 2 additions & 2 deletions srp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ func TestSrp(t *testing.T) {
keyB, keyb := getServerSeed(v)
serverKey := getServerSession(user, password, salt, keyA, keyB, keyb)
_, clientKey := getClientProof(user, password, salt, keyA, keyB, keya, "Srp")
for i, _ := range clientKey {
for i := range clientKey {
if clientKey[i] != serverKey[i] {
t.Fatalf("Error srp key exchange")
}
}

_, clientKey = getClientProof(user, password, salt, keyA, keyB, keya, "Srp256")
for i, _ := range clientKey {
for i := range clientKey {
if clientKey[i] != serverKey[i] {
t.Fatalf("Error srp256 key exchange")
}
Expand Down
22 changes: 11 additions & 11 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,22 +311,22 @@ func calcBlr(xsqlda []xSQLVAR) []byte {
n += 2
case SQL_TYPE_DOUBLE:
blr[n] = 27
n += 1
n++
case SQL_TYPE_FLOAT:
blr[n] = 10
n += 1
n++
case SQL_TYPE_D_FLOAT:
blr[n] = 11
n += 1
n++
case SQL_TYPE_DATE:
blr[n] = 12
n += 1
n++
case SQL_TYPE_TIME:
blr[n] = 13
n += 1
n++
case SQL_TYPE_TIMESTAMP:
blr[n] = 35
n += 1
n++
case SQL_TYPE_BLOB:
blr[n] = 9
blr[n+1] = 0
Expand All @@ -337,19 +337,19 @@ func calcBlr(xsqlda []xSQLVAR) []byte {
n += 2
case SQL_TYPE_BOOLEAN:
blr[n] = 23
n += 1
n++
case SQL_TYPE_DEC64:
blr[n] = 24
n += 1
n++
case SQL_TYPE_DEC128:
blr[n] = 25
n += 1
n++
case SQL_TYPE_TIME_TZ:
blr[n] = 28
n += 1
n++
case SQL_TYPE_TIMESTAMP_TZ:
blr[n] = 29
n += 1
n++
}
// [blr_short, 0]
blr[n] = 7
Expand Down
6 changes: 3 additions & 3 deletions wireprotocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,14 +325,14 @@ func (p *wireProtocol) _parse_status_vector() (*list.List, int, string, error) {
if gds_code == 335544436 {
sql_code = num
}
num_arg += 1
num_arg++
message = strings.Replace(message, "@"+strconv.Itoa(num_arg), strconv.Itoa(num), 1)
case n == isc_arg_string:
b, err = p.recvPackets(4)
nbytes := int(bytes_to_bint32(b))
b, err = p.recvPacketsAlignment(nbytes)
s := bytes_to_str(b)
num_arg += 1
num_arg++
message = strings.Replace(message, "@"+strconv.Itoa(num_arg), s, 1)
case n == isc_arg_interpreted:
b, err = p.recvPackets(4)
Expand Down Expand Up @@ -575,7 +575,7 @@ func (p *wireProtocol) parse_xsqlda(buf []byte, stmtHandle int32) (int32, []xSQL

for i < len(buf) {
if buf[i] == byte(isc_info_sql_stmt_type) && buf[i+1] == byte(0x04) && buf[i+2] == byte(0x00) {
i += 1
i++
ln = int(bytes_to_int16(buf[i : i+2]))
i += 2
stmt_type = int32(bytes_to_int32(buf[i : i+ln]))
Expand Down
8 changes: 3 additions & 5 deletions xsqlvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,15 @@ type xSQLVAR struct {
func (x *xSQLVAR) ioLength() int {
if x.sqltype == SQL_TYPE_TEXT {
return x.sqllen
} else {
return xsqlvarTypeLength[x.sqltype]
}
return xsqlvarTypeLength[x.sqltype]
}

func (x *xSQLVAR) displayLength() int {
if x.sqltype == SQL_TYPE_TEXT {
return x.sqllen
} else {
return xsqlvarTypeDisplayLength[x.sqltype]
}
return xsqlvarTypeDisplayLength[x.sqltype]
}

func (x *xSQLVAR) hasPrecisionScale() bool {
Expand Down Expand Up @@ -243,7 +241,7 @@ func (x *xSQLVAR) _parseDate(raw_value []byte) (int, int, int) {
month += 3
} else {
month -= 9
year += 1
year++
}
return year, month, day
}
Expand Down

0 comments on commit de66cf9

Please sign in to comment.