{"id":44072842,"url":"https://github.com/dstroot/postgres-api","last_synced_at":"2026-02-08T05:45:12.021Z","repository":{"id":57553088,"uuid":"82241919","full_name":"dstroot/postgres-api","owner":"dstroot","description":"simple golang go API application illustrating how to build a go API against a Postgres database","archived":false,"fork":false,"pushed_at":"2017-02-26T14:37:40.000Z","size":15124,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-19T19:42:25.805Z","etag":null,"topics":["example-project","go","golang","postgresql"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dstroot.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-17T01:04:24.000Z","updated_at":"2020-05-29T05:55:46.000Z","dependencies_parsed_at":"2022-09-15T19:00:41.185Z","dependency_job_id":null,"html_url":"https://github.com/dstroot/postgres-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dstroot/postgres-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dstroot%2Fpostgres-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dstroot%2Fpostgres-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dstroot%2Fpostgres-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dstroot%2Fpostgres-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dstroot","download_url":"https://codeload.github.com/dstroot/postgres-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dstroot%2Fpostgres-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29222216,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-08T05:41:10.886Z","status":"ssl_error","status_checked_at":"2026-02-08T05:40:31.827Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["example-project","go","golang","postgresql"],"created_at":"2026-02-08T05:45:11.357Z","updated_at":"2026-02-08T05:45:12.007Z","avatar_url":"https://github.com/dstroot.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# postgres-api : a very simple example of a golang API on top of a Postgres table\n\n[![GoDoc](https://godoc.org/github.com/dstroot/postgres-api?status.svg)](https://godoc.org/github.com/dstroot/postgres-api)\n[![Go Report Card](https://goreportcard.com/badge/github.com/dstroot/postgres-api)](https://goreportcard.com/report/github.com/dstroot/postgres-api)\n\n## Overview \n\nThis API uses:\n* Julien Schmidt's httprouter [package](https://github.com/julienschmidt/httprouter).  In contrast to the default mux of Go's net/http package, this router supports variables in the routing pattern and matches against the request method. The router is optimized for high performance and a small memory footprint.\n* Negroni middleware [package](https://github.com/urfave/negroni).  Negroni is an idiomatic approach to web middleware in Go. It is tiny, non-intrusive, and encourages use of net/http Handlers.\n* Godotenv [package](https://github.com/joho/godotenv) loads env vars from a .env file. Storing configuration in the environment is one of the tenets of a twelve-factor app. But it is not always practical to set environment variables on development machines or continuous integration servers where multiple projects are run. Godotenv load variables from a .env file into ENV when the environment is bootstrapped.\n* Envdecode [package](https://github.com/joeshaw/envdecode). Envdecode uses struct tags to map environment variables to fields, allowing you you use any names you want for environment variables. In this way you load the environment variables into a config struct once and can then use them throughout your program.\n* Errors [package](https://github.com/pkg/errors).  The errors package allows you to add context to the failure path of your code in a way that does not destroy the original value of the error.\n\nThis program is written for go 1.8 and takes advantage of the ability to drain connections and do a graceful shutdown.  \n\n\n## Install\n\n```\n❯ go get github.com/dstroot/postgres-api\n❯ cd $GOPATH/src/github.com/dstroot/postgres-api\n❯ dep ensure -update\n❯ go test -v\n❯ go build \u0026\u0026 ./postgres-api\n```\n\n## License\n\nMIT.\n\n### Operating\n\nYou need a postgres database and a database created to use.  Set the .env parameters to point to your postgres installation.  Run `go test` to initialize the table. After that you should be able to build and run the program.\n\nRun psql cli:\n\n`$ docker run -it --rm --link postgres:postgres postgres psql -h postgres -U postgres`\n\n\nHere's how you create a database in Postgres:\n\n```\npsql (9.6.2)\nType \"help\" for help.\n\npostgres=# CREATE DATABASE products;\nCREATE DATABASE\npostgres=# \\q\n```\n\nHow to build the program:\n\n```\n$ go build -ldflags \"-X main.buildstamp=`date -u '+%Y-%m-%d_%I:%M:%S%p'` -X main.commit=`git rev-parse HEAD` -w -s\" \u0026\u0026 ./postgres-api\n```\n\nOr, just (without build flags)\n\n```\n$ go build \u0026\u0026 ./postgres-api\n```\n\n### References\n\n* https://tylerchr.blog/golang-18-whats-coming/\n* https://dave.cheney.net/2016/06/12/stack-traces-and-the-errors-package\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdstroot%2Fpostgres-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdstroot%2Fpostgres-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdstroot%2Fpostgres-api/lists"}