本文整理匯總了Golang中carpcomm/db.StationDB.NumStations方法的典型用法代碼示例。如果您正苦於以下問題:Golang StationDB.NumStations方法的具體用法?Golang StationDB.NumStations怎麽用?Golang StationDB.NumStations使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類carpcomm/db.StationDB
的用法示例。
在下文中一共展示了StationDB.NumStations方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: homeHandler
func homeHandler(stationdb *db.StationDB, m *rpc.Client,
w http.ResponseWriter, r *http.Request, user userView) {
log.Printf("userid: %s", user.Id)
hc := homeContext{}
n, err := stationdb.NumStations()
if err != nil {
n = -1
}
hc.NumStations = n
hc.Stations, err = stationdb.UserStations(user.Id)
if err != nil {
log.Printf("Error getting user stations: %s", err.Error())
// Continue rendering since it's not a critial error.
}
var args mux.StationCountArgs
var count mux.StationCountResult
err = m.Call("Coordinator.StationCount", args, &count)
if err != nil {
count.Count = -1
}
hc.NumOnlineStations = count.Count
c := NewRenderContext(user, hc)
err = homeTemplate.Get().ExecuteTemplate(w, "home.html", c)
if err != nil {
log.Printf("Error rendering home page: %s", err.Error())
http.Error(w, "", http.StatusInternalServerError)
return
}
}