github-vet / github-vet/rangeloop-pointer-findings
seol-gang/NaverCafeMonitoring: naver_cafe_monitoring.go; 91 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [seol-gang/NaverCafeMonitoring](https://www.github.com/seol-gang/NaverCafeMonitoring) at [naver_cafe_monitoring.go](https://github.com/seol-gang/NaverCafeMonitoring/blob/8140a71ede7cce4ed2cbcfa40f3f19ca97aad7d1/naver_cafe_monitoring.go#L210-L300)
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.
> range-loop variable data used in defer or goroutine at line 218
[Click here to see the code in its original context.](https://github.com/seol-gang/NaverCafeMonitoring/blob/8140a71ede7cce4ed2cbcfa40f3f19ca97aad7d1/naver_cafe_monitoring.go#L210-L300)
Click here to show the 91 line(s) of Go which triggered the analyzer.
```go
for _, data := range article {
articleInfo := ArticleInfo{}
var wait sync.WaitGroup
wait.Add(4)
go func() {
defer wait.Done()
//게시판 목록
li, err := data.FindElement(selenium.ByClassName, "inner_name")
if err != nil {
fmt.Println(err)
}
noticeType, err := li.Text()
if err != nil {
fmt.Println(err)
}
articleInfo.noticeType = noticeType
}()
go func() {
defer wait.Done()
//게시판 링크
li, err := data.FindElement(selenium.ByClassName, "article")
if err != nil {
fmt.Println(err)
}
noticeLink, err := li.GetAttribute("href")
if err != nil {
fmt.Println(err)
}
//게시글 고유 번호
r, _ := regexp.Compile("articleid=[0-9]+")
tempID := r.FindString(noticeLink)
noticeIDNum := strings.Split(tempID, "=")[1]
articleInfo.noticeIDNum, _ = strconv.ParseInt(noticeIDNum, 10, 64)
//게시글 제목
noticeTitle, err := li.Text()
if err != nil {
fmt.Println(err)
}
articleInfo.noticeTitle = noticeTitle
articleInfo.noticeLink = noticeLink
}()
go func() {
defer wait.Done()
//작성자 닉네임 및 아이디
li, err := data.FindElement(selenium.ByClassName, "m-tcol-c")
if err != nil {
fmt.Println(err)
}
nickname, err := li.Text()
if err != nil {
fmt.Println(err)
}
tempIdStr, err := li.GetAttribute("onclick")
id := strings.Trim(strings.TrimSpace(strings.Split(tempIdStr, ",")[1]), "'")
articleInfo.nickname = nickname
articleInfo.id = id
}()
go func() {
defer wait.Done()
//작성 시간
li, err := data.FindElement(selenium.ByClassName, "td_date")
if err != nil {
fmt.Println(err)
}
tempTime, err := li.Text()
if err != nil {
fmt.Println(err)
}
loc, _ := time.LoadLocation("Asia/Seoul")
dateTime := strings.Split(time.Now().In(loc).String(), " ")[0] + " " + tempTime + ":00"
articleInfo.dateTime = dateTime
}()
wait.Wait()
if noticeNumChk >= articleInfo.noticeIDNum {
break
}
var filterNoticeType []string
filterNoticeType = []string{"NAVER CAFE BOARD LIST FOR MONITORING"}
for _, val := range filterNoticeType {
if val == articleInfo.noticeType {
articleList = append(articleList, articleInfo)
}
}
}
```
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: 8140a71ede7cce4ed2cbcfa40f3f19ca97aad7d1
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.