Skip to content

Commit c2cbeca

Browse files
authored
GODRIVER-2156 Enable nakedret linter. (#798)
1 parent 49fed90 commit c2cbeca

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ linters:
1313
- govet
1414
- ineffassign
1515
# - misspell
16-
# - nakedret
16+
- nakedret
1717
- revive
1818
- staticcheck
1919
# - structcheck

bson/primitive/decimal.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ Loop:
133133
}
134134

135135
// BigInt returns significand as big.Int and exponent, bi * 10 ^ exp.
136-
func (d Decimal128) BigInt() (bi *big.Int, exp int, err error) {
136+
func (d Decimal128) BigInt() (*big.Int, int, error) {
137137
high, low := d.GetBytes()
138138
posSign := high>>63&1 == 0 // positive sign
139139

@@ -147,6 +147,7 @@ func (d Decimal128) BigInt() (bi *big.Int, exp int, err error) {
147147
return nil, 0, ErrParseNegInf
148148
}
149149

150+
var exp int
150151
if high>>61&3 == 3 {
151152
// Bits: 1*sign 2*ignored 14*exponent 111*significand.
152153
// Implicit 0b100 prefix in significand.
@@ -169,7 +170,7 @@ func (d Decimal128) BigInt() (bi *big.Int, exp int, err error) {
169170
return new(big.Int), 0, nil
170171
}
171172

172-
bi = big.NewInt(0)
173+
bi := big.NewInt(0)
173174
const host32bit = ^uint(0)>>32 == 0
174175
if host32bit {
175176
bi.SetBits([]big.Word{big.Word(low), big.Word(low >> 32), big.Word(high), big.Word(high >> 32)})
@@ -180,7 +181,7 @@ func (d Decimal128) BigInt() (bi *big.Int, exp int, err error) {
180181
if !posSign {
181182
return bi.Neg(bi), exp, nil
182183
}
183-
return
184+
return bi, exp, nil
184185
}
185186

186187
// IsNaN returns whether d is NaN.

0 commit comments

Comments
 (0)