shopspring / decimal

Arbitrary-precision fixed-point decimal numbers in Go
Other
6.3k stars 620 forks source link

help: lint tool suggestion #294

Open ppd0705 opened 2 years ago

ppd0705 commented 2 years ago

I make a same stupid error many times. the error is like the code below

a := decimal.NewFromString("123")
b := decimal.NewFromString("345")
a.Sub(b)
// wanted:  a = a.Sub(b)

I often forget a =. is there any lint tool for this situation ?

xiegeo commented 1 year ago

govet has an unusedresult check. https://golangci-lint.run/usage/linters#govet

ppd0705 commented 1 year ago

govet has an unusedresult check. https://golangci-lint.run/usage/linters#govet

thanks for your reply. the document is to simple to understand, do your have a config template ? I tried the conf below, it doesn‘t work

lint:
  govet:
    settings:
      unusedresult:
        stringmethods:
          - (github.com/shopspring/decimal.Decimal).Sub
xiegeo commented 1 year ago

@ppd0705 that looks like the funcs formate, stringmethods should just be Sub

lint:
  govet:
    settings:
      unusedresult:
        funcs:
          - (github.com/shopspring/decimal.Decimal).Sub
        stringmethods:
          - Sub
ppd0705 commented 1 year ago

@xiegeo it doesn't work either