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

devdirga/GoHrm: services/remote.go; 43 LoC

Open
#10,584 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 [devdirga/GoHrm](https://www.github.com/devdirga/GoHrm) at [services/remote.go](https://github.com/devdirga/GoHrm/blob/afa43a860afbffa293377313f6bc84a008784f22/services/remote.go#L846-L888)

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 remote was used in a composite literal at line 872

[Click here to see the code in its original context.](https://github.com/devdirga/GoHrm/blob/afa43a860afbffa293377313f6bc84a008784f22/services/remote.go#L846-L888)

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

```go
for _, remote := range remotes {
if remote.IsDelete {
apprRemote++
datelist = append(datelist, remote.DateLeave)
} else {
decRemote++
}

dateCreate = (remote.CreatedAt).Format("2006-01-02 15:04:05")
typeRemoteNum = remote.Type
reasons = remote.ReasonAction
usrMail = remote.Email
usrName = remote.Name

err := repoM.Save(&remote)
if err != nil {
return remotes, err
}

layout := "2006-01-02"
t, _ := time.Parse(layout, remote.DateLeave)

//log
emptyleave := new(RequestLeaveModel)
service := LogService{
emptyleave,
&remote,
"remote",
}
log := tk.M{}
if remote.IsDelete {
log.Set("Status", "Cancel")
log.Set("Desc", "Request Remote is Canceled"+" for date "+t.Format("02-Jan-2006"))
} else {
log.Set("Status", "Cancel")
log.Set("Desc", "Request Remote is Declined "+" for date "+t.Format("02-Jan-2006"))
}

err = service.CancelRequest(log)
if err != nil {
return remotes, err
}
}

```

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: afa43a860afbffa293377313f6bc84a008784f22

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.