func openDB() *sql.DB {
	pg_db_uri := fmt.Sprintf(
		"dbname=%s user=%s password=%s sslmode=disable",
		config.GetConfigKey("db_name"),
		config.GetConfigKey("db_user"),
		config.GetConfigKey("db_pass"),
	)

	db, _ := sql.Open("postgres", pg_db_uri)
	if err := db.Ping(); err != nil {
		fmt.Println("Error!")
		fmt.Println(err)
		return nil
	}
	return db
}
Exemplo n.º 2
0
func conditionsURL(zip string) string {
	key := config.GetConfigKey("wunderground_key")
	return fmt.Sprintf("http://api.wunderground.com/api/%s/conditions/q/%s.json", key, zip)
}