github-vet / github-vet/rangeloop-pointer-findings
psh686868/psh-mosn: pkg/router/virtualhostimpl.go; 39 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [psh686868/psh-mosn](https://www.github.com/psh686868/psh-mosn) at [pkg/router/virtualhostimpl.go](https://github.com/psh686868/psh-mosn/blob/76721eb06194665aa5318c667d8a36e6c188abe6/pkg/router/virtualhostimpl.go#L42-L80)
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 route was used in a composite literal at line 47
[Click here to see the code in its original context.](https://github.com/psh686868/psh-mosn/blob/76721eb06194665aa5318c667d8a36e6c188abe6/pkg/router/virtualhostimpl.go#L42-L80)
Click here to show the 39 line(s) of Go which triggered the analyzer.
```go
for _, route := range virtualHost.Routers {
if route.Match.Prefix != "" {
virtualHostImpl.routes = append(virtualHostImpl.routes, &PrefixRouteRuleImpl{
NewRouteRuleImplBase(virtualHostImpl, &route),
route.Match.Prefix,
})
} else if route.Match.Path != "" {
virtualHostImpl.routes = append(virtualHostImpl.routes, &PathRouteRuleImpl{
NewRouteRuleImplBase(virtualHostImpl, &route),
route.Match.Path,
})
} else if route.Match.Regex != "" {
if regPattern, err := regexp.Compile(route.Match.Regex); err == nil {
virtualHostImpl.routes = append(virtualHostImpl.routes, &RegexRouteRuleImpl{
NewRouteRuleImplBase(virtualHostImpl, &route),
route.Match.Regex,
*regPattern,
})
} else {
log.DefaultLogger.Errorf("Compile Regex Error")
}
} else {
// todo delete hack
// hack here to do sofa's routing policy
for _, header := range route.Match.Headers {
if header.Name == types.SofaRouteMatchKey {
virtualHostImpl.routes = append(virtualHostImpl.routes, &SofaRouteRuleImpl{
RouteRuleImplBase: NewRouteRuleImplBase(virtualHostImpl, &route),
matchValue: header.Value,
})
}
}
}
}
```
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: 76721eb06194665aa5318c667d8a36e6c188abe6
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.