Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bf82d36

Browse files
committed
bugfix
1 parent 9c2db0f commit bf82d36

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

websites/code/studygolang/src/service/article.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,11 @@ func ParseArticle(articleUrl string, auto bool) (*model.Article, error) {
156156
// YYYYY-MM-dd HH:mm
157157
if len(pubDate) == 16 && auto {
158158
// 三个月之前不入库
159-
pubTime := time.ParseInLocation("2006-01-02 15:04", pubDate, time.Local)
160-
if pubTime.Add(3 * 30 * 86400 * time.Second).Before(time.Now()) {
161-
return nil, errors.New("article is old!")
159+
pubTime, err := time.ParseInLocation("2006-01-02 15:04", pubDate, time.Local)
160+
if err == nil {
161+
if pubTime.Add(3 * 30 * 86400 * time.Second).Before(time.Now()) {
162+
return nil, errors.New("article is old!")
163+
}
162164
}
163165
}
164166
}

0 commit comments

Comments
 (0)