github-vet / github-vet/rangeloop-pointer-findings
mpapi/hutbot: hutbot.go; 47 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [mpapi/hutbot](https://www.github.com/mpapi/hutbot) at [hutbot.go](https://github.com/mpapi/hutbot/blob/fd033d2ef3dcad7920680ff4e84a6a9783411aa4/hutbot.go#L455-L501)
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 message was used in a composite literal at line 494
[Click here to see the code in its original context.](https://github.com/mpapi/hutbot/blob/fd033d2ef3dcad7920680ff4e84a6a9783411aa4/hutbot.go#L455-L501)
Click here to show the 47 line(s) of Go which triggered the analyzer.
```go
for message := range messages {
var command, args string
commandFound := false
match := pattern.FindStringSubmatch(message.Contents)
if match != nil && len(match) == 4 {
commandFound = true
command = match[1]
args = match[3]
}
wd, _ := os.Getwd()
env := []string{
"HUTBOT_EVENT=command",
fmt.Sprintf("HUTBOT_SENDER=%s", message.Sender),
fmt.Sprintf("HUTBOT_CHANNEL=%s", message.Channel),
fmt.Sprintf("HUTBOT_CREATED=%d", message.Created.Unix()),
fmt.Sprintf("HUTBOT_BOT=%s", *botName),
fmt.Sprintf("HUTBOT_DIR=%s", wd),
fmt.Sprintf("HUTBOT_COMMAND=%s", command),
fmt.Sprintf("HUTBOT_ARGS=%s", args),
fmt.Sprintf("HUTBOT_MESSAGE=%s", message.Contents),
}
var pts []PathAndTarget
if commandFound {
pts = appendPaths(pts, paths(command), "")
pts = appendPaths(pts, paths("private/"+command), message.Sender)
if len(pts) == 0 {
pts = appendPaths(pts, paths(".missing"), "")
}
}
pts = appendPaths(pts, paths(".all"), "")
for _, pt := range pts {
target := pt.Target
executable := pt.Path
pool.Run(pt.Path, args, env, func(stdout []byte, stderr []byte, err error) {
if err == nil {
contents := strings.TrimRight(string(stdout), " \t\r\n")
responses <- Response{c, &message, contents, target, time.Now()}
} else {
contents := fmt.Sprintf("error: %s %s: %s", executable, err, string(stderr))
responses <- Response{c, &message, contents, "", time.Now()}
}
})
}
}
```
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: fd033d2ef3dcad7920680ff4e84a6a9783411aa4
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.