本文整理匯總了Golang中carpcomm/db.StationDB.Store方法的典型用法代碼示例。如果您正苦於以下問題:Golang StationDB.Store方法的具體用法?Golang StationDB.Store怎麽用?Golang StationDB.Store使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類carpcomm/db.StationDB
的用法示例。
在下文中一共展示了StationDB.Store方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: RestoreStationsTable
func RestoreStationsTable(input *db.RecordReader, output *db.StationDB) error {
for {
rec, err := input.ReadRecord()
if err == io.EOF {
break
} else if err != nil {
log.Printf("Error reading record: %s", err.Error())
return err
}
s := &pb.Station{}
err = proto.Unmarshal(rec, s)
if err != nil {
log.Printf("Error parsing record: %s", err.Error())
return err
}
err = output.Store(s)
if err != nil {
log.Printf("Error writing record: %s", err.Error())
return err
}
fmt.Printf(".")
}
fmt.Printf("\n")
log.Printf("Stations table restored.")
return nil
}
示例2: addStationHandler
func addStationHandler(sdb *db.StationDB,
w http.ResponseWriter, r *http.Request, user userView) {
station, err := db.NewStation(user.Id)
if err != nil {
log.Printf("Station DB NewStation error: %s", err.Error())
http.Error(w, "", http.StatusInternalServerError)
return
}
if err = sdb.Store(station); err != nil {
log.Printf("Station DB Store error: %s", err.Error())
http.Error(w, "", http.StatusInternalServerError)
return
}
redirect := stationUrl("/station/edit", *station.Id)
http.Redirect(w, r, redirect, http.StatusFound)
}
示例3: editStationPOST
func editStationPOST(sdb *db.StationDB, s *pb.Station,
w http.ResponseWriter, r *http.Request, user userView) {
if err := r.ParseForm(); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
log.Print(r.Form)
s.Name = proto.String(r.Form.Get("name"))
s.Notes = proto.String(r.Form.Get("notes"))
setOptionalFloat(r.Form.Get("latitude"), &s.Lat)
setOptionalFloat(r.Form.Get("longitude"), &s.Lng)
setOptionalFloat(r.Form.Get("elevation"), &s.Elevation)
if r.Form["has_vhf"] == nil {
s.Capabilities.VhfLimits = nil
} else {
vhf := &pb.AzElLimits{}
s.Capabilities.VhfLimits = vhf
setOptionalFloat(r.Form.Get("vhf_min_azimuth"),
&vhf.MinAzimuthDegrees)
setOptionalFloat(r.Form.Get("vhf_max_azimuth"),
&vhf.MaxAzimuthDegrees)
setOptionalFloat(r.Form.Get("vhf_min_elevation"),
&vhf.MinElevationDegrees)
setOptionalFloat(r.Form.Get("vhf_max_elevation"),
&vhf.MaxElevationDegrees)
}
if r.Form["has_uhf"] == nil {
s.Capabilities.UhfLimits = nil
} else {
uhf := &pb.AzElLimits{}
s.Capabilities.UhfLimits = uhf
setOptionalFloat(r.Form.Get("uhf_min_azimuth"),
&uhf.MinAzimuthDegrees)
setOptionalFloat(r.Form.Get("uhf_max_azimuth"),
&uhf.MaxAzimuthDegrees)
setOptionalFloat(r.Form.Get("uhf_min_elevation"),
&uhf.MinElevationDegrees)
setOptionalFloat(r.Form.Get("uhf_max_elevation"),
&uhf.MaxElevationDegrees)
}
if r.Form["scheduler_enabled"] == nil {
s.SchedulerEnabled = nil
} else {
s.SchedulerEnabled = proto.Bool(true)
}
err := sdb.Store(s)
if err != nil {
log.Printf("Station DB store error: %s", err.Error())
http.Error(w, "", http.StatusInternalServerError)
return
}
redirect := stationUrl("/station", *s.Id)
http.Redirect(w, r, redirect, http.StatusFound)
}