{"id":36584872,"url":"https://github.com/dmitry-kostin/go-rest","last_synced_at":"2026-01-12T08:02:13.617Z","repository":{"id":56855656,"uuid":"397879110","full_name":"dmitry-kostin/go-rest","owner":"dmitry-kostin","description":"A starting point and a template for a RESTful application written in golang","archived":false,"fork":false,"pushed_at":"2023-09-15T14:48:28.000Z","size":4451,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-20T08:17:52.568Z","etag":null,"topics":["go","go-app","go-template","golang","rest-api","tutorial"],"latest_commit_sha":null,"homepage":"https://github.com/dmitry-kostin/go-rest","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/dmitry-kostin.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-19T08:57:03.000Z","updated_at":"2023-07-28T15:26:36.000Z","dependencies_parsed_at":"2024-06-20T07:18:31.135Z","dependency_job_id":"5cecc933-e6e4-4db4-b724-d06b865fe07a","html_url":"https://github.com/dmitry-kostin/go-rest","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dmitry-kostin/go-rest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmitry-kostin%2Fgo-rest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmitry-kostin%2Fgo-rest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmitry-kostin%2Fgo-rest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmitry-kostin%2Fgo-rest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dmitry-kostin","download_url":"https://codeload.github.com/dmitry-kostin/go-rest/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmitry-kostin%2Fgo-rest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28336965,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T06:09:07.588Z","status":"ssl_error","status_checked_at":"2026-01-12T06:05:18.301Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["go","go-app","go-template","golang","rest-api","tutorial"],"created_at":"2026-01-12T08:01:31.326Z","updated_at":"2026-01-12T08:02:13.611Z","avatar_url":"https://github.com/dmitry-kostin.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- PROJECT LOGO --\u003e\n\u003cbr /\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://repository-images.githubusercontent.com/397879110/ca96c957-860d-4ec9-a37c-f3274b15d997\" alt=\"Logo\" width=\"640\"\u003e\n\n\u003ch3 align=\"center\"\u003eGo Rest API Starter Template\u003c/h3\u003e\n  \u003cp align=\"center\"\u003e\n    A template for a fast start to building REST Web Services in Go. This project provides basic skeleton along with\n    some of the best practices and tools for building RESTful APIs in Go.\n    \u003cbr /\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"#some-of-the-features-included-in-this-template\"\u003eFeatures\u003c/a\u003e\n    ·\n    \u003ca href=\"#getting-started\"\u003eGetting Started\u003c/a\u003e\n    ·\n    \u003ca href=\"#authentication\"\u003eAuthentication\u003c/a\u003e\n    ·\n    \u003ca href=\"#error-handling\"\u003eError handling\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/p\u003e\n\n## Brief introduction notes\n\nSometimes you just need to start a new project, but you don't want to spend time on setting up the project structure,\nconfiguring the database, and do other things that are not strictly related to the business logic of your application\nor idea you want to validate. \n\nThis project aims to provide a good starting point for that purpose. It's not a framework, it's just a template where \nyou can quickly remove the parts you don't need and add the ones you need.\n\n### Some of the features included in this template:\n- The project is configured to use basic manual dependency injection, which is a good fit for small to medium size projects\n- PostgreSQL database with migrations, it's up to you on devops side how to run it on production\n- Authentication with API keys, simple and yet effective\n- Error handling, I really like idea of customizing error messages for clients\n- Logging\n- Configuration, while `.env` file is present in project root, it's up to you how to load it \n- Service layer, can serve as an excellent starting point for DDD services or basic CRUD operations\n- Struct validations using govalidator as a fast and replaceble solution especially if you in favor of other methods\n\n\n## Getting Started\n\n### Prepare environment variables\n* Create and fill the `.env` file according to the example `.example.env`\n* Export environment variables from `.env` in any suitable way for you\n  * eg.: `export $(grep -v '^#' .env | xargs)`\n  * eg.: or set an alias for zshrc / bashrc `alias loadenv=\"export \\$(grep -v '^#' .env | xargs)\"`\n  * eg.: utilities like [direnv](https://direnv.net/) also could be helpful\n\n### Setup a database\n* Install [docker](https://docs.docker.com/desktop/mac/install/)\n* Run database image `docker compose up -d`\n* Run migrations (refer to a section below)\n\n### Migrations\n\nMigrations are based on [golang-migrate](https://github.com/golang-migrate/migrate).\n\nTo install: `brew install golang-migrate`\n\nCreate a new migration:\n```\nmigrate create -ext sql -dir db/migrations -seq create_users\n```\n\nRun migrations all the way up or down\n```\nmigrate -database ${DB_URI} -path src/db/migrations up\nmigrate -database ${DB_URI} -path src/db/migrations down\n```\n\n### Run application in development mode\n\nI use air for live-reloading during development\n\n* Install [air](https://github.com/cosmtrek/air) for live reloading\n* Run `air`\n\nOr build and run the application directly `go build -o ./tmp ./cmd/api-service \u0026\u0026 ./tmp/api-service`\n\n### Tests\n\n```bash\n go test -coverprofile=coverage.out ./... \u0026\u0026 go tool cover -html=coverage.out\n```\n\n### Authentication\n\nThe application uses API keys for authentication, which are typically passed in the `Authorization` header using Bearer \nauthentication scheme.\n\nWhile this basic authentication may appear straightforward to implement, it's crucial to remain cognizant of potential\nthreats and attacks that could occur, particularly given the extensive privileges often associated with these keys.\n\nApplication middleware is focused on security preventing the most common attacks vectors: such as timing attacks and\nkey provisioning.\n\nTo generate API keys, you can use the following command:\n\n`$ openssl rand -base64 32`\n\nThis command will generate a 32-byte random string, which is a good enough length for secrets.\n\nTo be able to use that key in the application, you need to create a sha256 hash from it:\n\n`$ echo -n \"\u003cyou_key\u003e\" | sha256sum`\n\nThis command will generate a 32-byte hash, which you can put into the config `.env` file\n\n`APP_API_KEYS` supports multiple keys, separated by comma, eg.: `key1,key2,key3`; This might be useful for keys \nrotation or when you want to provide granular access to different clients or revoke one.\n\n### Error handling\n\nThe application uses [cockroachdb/errors](https://github.com/cockroachdb/errors) for error handling. This package \nprovides enhanced error handling capabilities, such as wrapping errors, attaching stack traces, and adding context to\nerrors.\n\nThis allows us to provide more detailed human readable error messages to clients, while still maintaining the ability \nto log the original error internally.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmitry-kostin%2Fgo-rest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdmitry-kostin%2Fgo-rest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmitry-kostin%2Fgo-rest/lists"}