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

nickoneill/go-publisher: publisher.go; 24 LoC

Open
#17,979 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 [nickoneill/go-publisher](https://www.github.com/nickoneill/go-publisher) at [publisher.go](https://github.com/nickoneill/go-publisher/blob/c76cac9f55a031d7c066d2b7f3be19d7757cc70b/publisher.go#L238-L261)

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

[Click here to see the code in its original context.](https://github.com/nickoneill/go-publisher/blob/c76cac9f55a031d7c066d2b7f3be19d7757cc70b/publisher.go#L238-L261)

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

```go
for _, item := range feed.Items {
itemdate, err := time.Parse(time.RFC3339, item.Date)
//fmt.Printf("itemdate: %v\n",itemdate.Format(time.RFC3339))
if err != nil {
fmt.Printf("error parsing item date: %v\n",err)
}
item.Sourcedate = itemdate.Format("2006-01-02 15:04")
//fmt.Printf("sourcedate: %v\n",item.Sourcedate)

// need to keep track of newest pinboard post, don't want to assume it's first
if newlast.Before(itemdate) {
newlast = itemdate
}

// fmt.Printf("compare item: %v to last: %v\n",itemdate,lasttime)
if lasttime.Before(itemdate) {
fmt.Printf("new pinboard post with name: %v\n",item.Title)
filename := slugify(item.Title)

out := mustache.Render(string(sourcetemplate), map[string]interface{}{"post": &item})
// TODO: check the path for existing file, raise a warning if a file exists at this path already
db.PutFile("source/"+filename+".md", out)
}
}

```

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

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with publisher.go lines 238-261 and trace the feed.Items loop through the pointer passed to mustache.Render. Check whether this affects the generated Markdown files, then classify the finding as Bug, Mitigated, or Desirable Behavior with supporting evidence.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.