github-vet / github-vet/rangeloop-pointer-findings
rohanthewiz/go_notes: note.go; 91 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [rohanthewiz/go_notes](https://www.github.com/rohanthewiz/go_notes) at [note.go](https://github.com/rohanthewiz/go_notes/blob/cf2d913b7de4c9812598f61be58c4f93eca17fdc/note.go#L98-L188)
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.
>
[Click here to see the code in its original context.](https://github.com/rohanthewiz/go_notes/blob/cf2d913b7de4c9812598f61be58c4f93eca17fdc/note.go#L98-L188)
Click here to show the 91 line(s) of Go which triggered the analyzer.
```go
for _, n := range notes {
curr_note[0] = n
listNotes(curr_note[0:1], false) //pass a slice of the array
print("Update this note? (y/N) ")
var input string
fmt.Scanln(&input) // Get keyboard input
if input == "y" || input == "Y" {
reader := bufio.NewReader(os.Stdin)
var nf NoteFragment = NoteFragment{}
fpl("\nTitle-->" + n.Title)
fmt.Println("Enter new Title (or '+ blah' to append, or for no change)")
tit, _ := reader.ReadString('\n')
tit = strings.TrimRight(tit, " \r\n")
orig_title := n.Title
if len(tit) > 1 && tit[0:1] == "+" {
n.Title += tit[1:]
} else if len(tit) > 0 {
n.Title = tit
}
if orig_title != n.Title { //Build NoteFragment
nf.Title = n.Title
nf.Bitmask |= 8
}
fpl("Description-->" + n.Description)
fmt.Println("Enter new Description (or '-' to blank, '+ blah' to append, or for no change)")
desc, _ := reader.ReadString('\n')
desc = strings.TrimRight(desc, " \r\n")
orig_desc := n.Description
if desc == "-" {
n.Description = ""
} else if len(desc) > 1 && desc[0:1] == "+" {
n.Description += desc[1:]
} else if len(desc) > 0 {
n.Description = desc
}
if orig_desc != n.Description { //Build NoteFragment
nf.Description = n.Description
nf.Bitmask |= 4
}
fpl("Body-->" + n.Body)
fmt.Println("Enter new Body (or '-' to blank, '+ blah' to append, or for no change)")
body, _ := reader.ReadString('\n')
body = strings.TrimRight(body, " \r\n ")
orig_body := n.Body
if body == "-" {
n.Body = ""
} else if len(body) > 1 && body[0:1] == "+" {
n.Body += body[1:]
} else if len(body) > 0 {
n.Body = body
}
if orig_body != n.Body { //Build NoteFragment
nf.Body = n.Body
nf.Bitmask |= 2
}
fpl("Tags-->" + n.Tag)
fmt.Println("Enter new Tags (or '-' to blank, '+ blah' to append, or for no change)")
tag, _ := reader.ReadString('\n')
tag = strings.TrimRight(tag, " \r\n ")
orig_tag := n.Tag
if tag == "-" {
n.Tag = ""
} else if len(tag) > 1 && tag[0:1] == "+" {
n.Tag += tag[1:]
} else if len(tag) > 0 {
n.Tag = tag
}
if orig_tag != n.Tag { //Build NoteFragment
nf.Tag = n.Tag
nf.Bitmask |= 1
}
db.Save(&n)
nc := NoteChange{Guid: generate_sha1(), NoteGuid: n.Guid, Operation: op_update, NoteFragment: nf}
db.Save(&nc)
if nc.Id > 0 {
pf("NoteChange (%s) created successfully\n", short_sha(nc.Guid))
}
curr_note[0] = n
listNotes(curr_note[:], false) // [:] means all of the slice
}
}
```
Click here to show extra information the analyzer produced.
```
No path was found through the callgraph that could lead to a function which writes a pointer argument.
No path was found through the callgraph that could lead to a function which passes a pointer to third-party code.
root signature {Save 1} was not found in the callgraph; reference was passed directly to third-party code
```
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: cf2d913b7de4c9812598f61be58c4f93eca17fdc
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.