Fix slice out of bounds error
Fixes following error: panic: runtime error: slice bounds out of range [:80] with length 53
This commit is contained in:
parent
bd4c8fb4a9
commit
c7e368ed2e
7
sn.go
7
sn.go
|
@ -38,7 +38,12 @@ func PostStoryToStackerNews(story *Story, options PostStoryOptions) (int, error)
|
|||
}
|
||||
}
|
||||
|
||||
parentId, err := sn.PostLink(url, story.Title[0:80], "tech")
|
||||
title := story.Title
|
||||
if len(title) > 80 {
|
||||
title = title[0:80]
|
||||
}
|
||||
|
||||
parentId, err := sn.PostLink(url, title, "tech")
|
||||
if err != nil {
|
||||
return -1, fmt.Errorf("error posting link: %w", err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue