本文整理匯總了Golang中rter/data.TermRanking.UpdateTime方法的典型用法代碼示例。如果您正苦於以下問題:Golang TermRanking.UpdateTime方法的具體用法?Golang TermRanking.UpdateTime怎麽用?Golang TermRanking.UpdateTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rter/data.TermRanking
的用法示例。
在下文中一共展示了TermRanking.UpdateTime方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: scanTermRanking
func scanTermRanking(ranking *data.TermRanking, rows *sql.Rows) error {
var updateTimeString string
err := rows.Scan(
&ranking.Term,
&ranking.Ranking,
&updateTimeString,
)
if err != nil {
return err
}
// TODO: this is a hacky fix for null times
if updateTimeString == "0000-00-00 00:00:00" {
updateTimeString = "0001-01-01 00:00:00"
}
updateTime, err := time.Parse("2006-01-02 15:04:05", updateTimeString) // this assumes UTC as timezone
if err != nil {
log.Println("TermRanking scanner failed to parse time.")
return err
}
ranking.UpdateTime = updateTime
return nil
}
示例2: TestReadTermRanking
func TestReadTermRanking(t *testing.T) {
readRanking := new(data.TermRanking)
testRead(t, "/taxonomy/"+term.Term+"/ranking", readRanking)
readRanking.UpdateTime = ranking.UpdateTime
structJSONCompare(t, ranking, readRanking)
}
示例3: TestSelectTermRanking
func TestSelectTermRanking(t *testing.T) {
selectedRanking := new(data.TermRanking)
selectedRanking.Term = ranking.Term
err := Select(selectedRanking)
if err != nil {
t.Error(err)
}
t.Log(ranking.UpdateTime.UTC())
t.Log(selectedRanking.UpdateTime.UTC())
selectedRanking.UpdateTime = ranking.UpdateTime
structJSONCompare(t, ranking, selectedRanking)
}