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

liut/staffio: pkg/backends/wechatwork/sync.go; 45 LoC

Open
#18,149 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 [liut/staffio](https://www.github.com/liut/staffio) at [pkg/backends/wechatwork/sync.go](https://github.com/liut/staffio/blob/2a457377d32beb6215640ac0ba9cc208a687d87a/pkg/backends/wechatwork/sync.go#L71-L115)

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/liut/staffio/blob/2a457377d32beb6215640ac0ba9cc208a687d87a/pkg/backends/wechatwork/sync.go#L71-L115)

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

```go
for i, dept := range departments {
if s.Output {
fmt.Printf("%4d %4d %14s %8d\n", dept.ID, dept.ParentID, dept.Name, dept.Order)
}

if s.DeptFn != nil {
s.DeptFn(&dept, i)
}
team := DepartmentToTeam(&dept, departments)
var staffs models.Staffs

if s.WithStaff {
lr := wxwork.ListReq{DeptID: fmt.Sprint(dept.ID)}
res, err := s.api.ListUser(lr)
if err != nil {
logger().Infow("list user fail", "err", err)
return err
}
for _, val := range res.Users() {
if !val.IsActived() || !val.IsEnabled() {
logger().Infow("user actived?", "name", val.Name, "status", val.Status, "enabled", val.Enabled)
continue
}
team.Members = append(team.Members, val.UID)
staff := UserToStaff(&val)
if val.IsLeader == 1 {
team.Leaders = append(team.Leaders, staff.UID)
}
// fmt.Println(staff)
staffs = append(staffs, *staff)
// fmt.Printf("%4s %10s %v\n", val.UID, val.Name, val.DepartmentIds)
}

}

// fmt.Printf("%2d:%2d %10s %v \n", team.ID, team.ParentID, team.Name, team.Members)
if s.WithTeam && s.BulkFn != nil {
err = s.BulkFn(svc, team, staffs)
if err != nil {
logger().Infow("call bulkFn fail", "err", err)
return err
}
}

}

```

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 {DeptFn 2} 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: 2a457377d32beb6215640ac0ba9cc208a687d87a

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.