split output code into method
This commit is contained in:
parent
1ecf16bd0a
commit
76a56879b0
28
main.go
28
main.go
|
@ -52,6 +52,22 @@ func (db *TimelineDB) closestEvent(t int64) (EventsRow, error) {
|
|||
return event, err
|
||||
}
|
||||
|
||||
func (event *EventsRow) Output() (int64, string, string) {
|
||||
timestamp, err := event.timestamp.Value()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
desc, err := event.description.Value()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
date := time.Unix(timestamp.(int64), 0)
|
||||
|
||||
return timestamp.(int64), date.String(), desc.(string)
|
||||
}
|
||||
|
||||
func main() {
|
||||
percent := flag.Float64("p", -1, "percentage")
|
||||
flag.Parse()
|
||||
|
@ -75,16 +91,6 @@ func main() {
|
|||
log.Fatal(err)
|
||||
}
|
||||
|
||||
timestamp, err := event.timestamp.Value()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
desc, err := event.description.Value()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
date := time.Unix(timestamp.(int64), 0)
|
||||
timestamp, date, desc := event.Output()
|
||||
fmt.Printf("%v\t%v\t%v\n", timestamp, date, desc)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue