github-vet / github-vet/rangeloop-pointer-findings
yitume/shop-api: router/api/buy/buy.go; 31 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [yitume/shop-api](https://www.github.com/yitume/shop-api) at [router/api/buy/buy.go](https://github.com/yitume/shop-api/blob/41417f0169aad02482d80bf0212c004a14900fae/router/api/buy/buy.go#L278-L308)
Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first
issue it finds, so please do not limit your consideration to the contents of the below message.
> reference to value is reassigned at line 283
[Click here to see the code in its original context.](https://github.com/yitume/shop-api/blob/41417f0169aad02482d80bf0212c004a14900fae/router/api/buy/buy.go#L278-L308)
Click here to show the 31 line(s) of Go which triggered the analyzer.
```go
for _, value := range list {
if value.GoodsNum > value.GoodsStock {
err = errors.New("库存不够")
return
}
valuePointer := &value
var cost float64
cost, err = valuePointer.FreightFeeByAddress(addressInfo)
if err != nil {
err = errors.New("数据异常")
return
}
freightWay := valuePointer.GetFreightWay()
freightList = append(freightList, view.Freight{
GoodsSkuId: valuePointer.GoodsSkuId,
FreightFee: cost,
FreightWay: freightWay,
})
if freightWay == "goods_freight_unified" {
// todo 为什么是=
freightUnifiedFee = valuePointer.GoodsFreightFee
} else {
freightTemplateFee += valuePointer.GoodsFreightFee
}
goodsAmount += valuePointer.GoodsPrice * float64(valuePointer.GoodsNum)
goodsNum += valuePointer.GoodsNum
}
```
Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.
commit ID: 41417f0169aad02482d80bf0212c004a14900fae
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.