func main() { flag.Parse() os.Remove(dbPath) db, err := db.NewDB(dbPath) if err != nil { log.Fatalf("Could not open database: %v", err) } if err := db.SetUp(); err != nil { log.Fatalf("Could not set up database: %v", err) } if err := db.SeedData(); err != nil { log.Fatalf("Could not seed database: %v", err) } var timestamps []timestamp.Timestamp if err := db.AllTimestamps(×tamps); err != nil { log.Fatalf("Could not fetch timestamps: %v", err) } fmt.Println("Found timestamps:") for _, t := range timestamps { fmt.Printf(" %v\n", time.Unix(t.SecondsSinceEpoch, 0).Format(time.UnixDate)) } }
// SetUp initializes the database func SetUp(path string) error { innerdb, err := db.NewDB(path) if err != nil { return err } globalDB = &dbWrapper{innerdb} return nil }