github-vet / github-vet/rangeloop-pointer-findings

UnnecessaryRain/ironway-core: pkg/network/client/client.go; 15 LoC

Open
#18,297 0 comments 0 reactions 0 assignees View on GitHub
fresh small
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [UnnecessaryRain/ironway-core](https://www.github.com/UnnecessaryRain/ironway-core) at [pkg/network/client/client.go](https://github.com/UnnecessaryRain/ironway-core/blob/06c6ab22bb377da7149e5e679c3a5bd89fba81a5/pkg/network/client/client.go#L86-L100)

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 99

[Click here to see the code in its original context.](https://github.com/UnnecessaryRain/ironway-core/blob/06c6ab22bb377da7149e5e679c3a5bd89fba81a5/pkg/network/client/client.go#L86-L100)

Click here to show the 15 line(s) of Go which triggered the analyzer.

```go
for i, message := range packet.ServerMessages {

// FIXME(#9): the first messaage from the client must be a one word string with no spaces
// this will be their user name for now
if len(c.Username) == 0 && i == 0 {
if len(strings.Split(strings.TrimSpace(string(message)), "")) == 0 {
log.Warningln("username expected as first message. got ", message)
return
}
c.Username = strings.TrimSpace(string(message))
c.registerOnServerChan <- c
continue
}
c.receivedChan <- Message{c, &packet.Metadata, &message}
}

```

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: 06c6ab22bb377da7149e5e679c3a5bd89fba81a5

Contributor guide

No contributing guide indexed for this repository

Research direction

Open pkg/network/client/client.go at lines 86-100 and inspect the range loop together with the analyzer's warning about the reference to message in the composite literal. Determine whether this produces incorrect behavior, then classify the finding as Bug, Mitigated, or Desirable Behavior as requested.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.