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

Traeric/MicroBlog: views/views.go; 27 LoC

Open
#13,541 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 [Traeric/MicroBlog](https://www.github.com/Traeric/MicroBlog) at [views/views.go](https://github.com/Traeric/MicroBlog/blob/d769266e6181b2182d41dd8447e0ce05683e352b/views/views.go#L148-L174)

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/Traeric/MicroBlog/blob/d769266e6181b2182d41dd8447e0ce05683e352b/views/views.go#L148-L174)

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

```go
for index, value := range blog_data {
item := map[string]interface{}{
"id": value.ID,
"content": value.Content,
"ThumbUpNum": value.ThumbUpNum,
"CommentNum": value.CommentNum,
"createAt": value.CreatedAt.Format("2006年01月02日 15:05"),
"index": index,
}
// 查询发布微博的用户信息
var user models.UserProfile
DB.First(&user, value.UserId)
item["user"] = user
// 查询微博的照片
DB.Model(&value).Related(&value.Photos)
item["Photos"] = value.Photos
// 查询评论
DB.Model(&value).Related(&value.Comments)
item["Comments"] = value.Comments
// 布局评论
// 将所有的评论从父级往下一级一级排好
var comments []models.Comment
DB.Find(&comments, "blog_id = ?", value.ID)
comment_list := LoadComment(comments)
item["comments"] = template.HTML(LoadCommentToString(comment_list))
blogs = append(blogs, item)
}

```

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 {Model 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: d769266e6181b2182d41dd8447e0ce05683e352b

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.