コード例 #1
0
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
}
コード例 #2
0
ファイル: fetcher.go プロジェクト: Yurokle/forecast-checker
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)
}