{"id":19429190,"url":"https://github.com/ehsaniara/go-crash","last_synced_at":"2026-04-02T18:52:09.891Z","repository":{"id":103638399,"uuid":"374478069","full_name":"ehsaniara/go-crash","owner":"ehsaniara","description":"go-crash is my Go Lang practices ","archived":false,"fork":false,"pushed_at":"2021-12-12T01:44:55.000Z","size":85,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-25T05:30:58.266Z","etag":null,"topics":["docker","gin-gonic","golang","postgres","redis","viper","zap"],"latest_commit_sha":null,"homepage":"","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/ehsaniara.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-06-06T22:41:05.000Z","updated_at":"2021-12-12T01:44:58.000Z","dependencies_parsed_at":"2023-05-24T04:00:25.463Z","dependency_job_id":null,"html_url":"https://github.com/ehsaniara/go-crash","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ehsaniara/go-crash","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehsaniara%2Fgo-crash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehsaniara%2Fgo-crash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehsaniara%2Fgo-crash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehsaniara%2Fgo-crash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ehsaniara","download_url":"https://codeload.github.com/ehsaniara/go-crash/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehsaniara%2Fgo-crash/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268291397,"owners_count":24226857,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["docker","gin-gonic","golang","postgres","redis","viper","zap"],"created_at":"2024-11-10T14:18:22.399Z","updated_at":"2025-12-30T21:38:30.504Z","avatar_url":"https://github.com/ehsaniara.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n[![Go Report Card](https://goreportcard.com/badge/github.com/ehsaniara/go-crash)](https://goreportcard.com/report/ehsaniara/go-crash)\n# go-crash\n\nProject **go-crash** is just my go lang practices\n\n### Stacks\n- GoLang (with: [gin-gonic](https://github.com/gin-gonic/gin), [viper](https://github.com/spf13/viper), [zap](https://github.com/uber-go/zap), [swaggo](https://github.com/swaggo/swag))\n- Postgres DB\n- Redis\n- Docker\n\n### Quick Start\n\nIf you already have Postgres and Redis running in your machine, just configure the `config/config.yml` file for credentials follow the steps:\n\n- Clone this repository\n- Then Run: `go mod tidy \u0026\u0026 go mod vendor`\n- Then Run: `go run main.go`\n- Or Run: `export PROFILE=Default \u0026\u0026 go run main.go` with selected profile\n- Open your browser on http://localhost:8080\n\n\u003e Note: The `dev`, `docker` and `prod` profiles (environments)'s credentials are get passes from OS env-vars. Let say you want to run this project in kubernetes then, you should pass the environment variables in your deployment manifest. for example:\n```yaml\n      image: path-to-image-of-this-project-in-repo\n      env:\n        - name: PROFILE\n          value: \"dev\"\n        - name: DATABASE_USER\n          value: \"postgres\"\n        - name: DATABASE_PASSWORD\n          value: \"postgres\"\n        - name: DATABASE_DB\n          value: \"go_crash\"\n        - name: REDIS_PASSWORD\n          value: \"secret\"\n```\n_the values can be later replaced into kube-secret or any other third party vault applications_\n\n\ncheck if server is working:\n\n```shell\ncurl --location --request GET 'http://localhost:8080/ping'\n```\n\nApi Documentations are in http://localhost:8080/swagger/index.html\n\n# Docker Run\n\nrun the project in docker, It also has images for:\n\n- Redis\n- Postgres\n\n## Start the docker compose\n\n```shell\ndocker-compose up -d\n```\n\n## clean the docker compose\n\n```shell\ndocker-compose down -v\n```\n\n# Quick Start\n\nlogin to postgres and create a record in `auths` table to create authentication user for token\n\n```sql\ninsert into public.auths (id, username, password)\nvalues (1, 'test', 'test');\n```\n\nbasically eny api under `/api/v1` is protected by `Token` header and needs to be authenticated.\n\nto authenticate call the following command:\n\n```shell\ncurl --location --request POST 'http://localhost:8080/auth' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{\n    \"username\": \"test\",\n    \"password\": \"test\"\n}'\n```\n\nnow you have your token, you should use it in every call under `/api/v1` as header `Token`\n\n### Create User\n\n```shell\ncurl --location --request POST 'http://localhost:8080/api/v1/customers' \\\n--header 'token: eyJhbGciOiJI...GSqQhG8' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{\n    \"firstName\": \"Jay\",\n    \"lastName\": \"Ehsaniara\",\n    \"title\": \"Software Engineer\"\n}'\n```\n\nAnd the response from the following call will be:\n\n```json\n{\n  \"ID\": 1,\n  \"FirstName\": \"Jay\",\n  \"LastName\": \"Ehsaniara\",\n  \"Title\": \"Software Engineer\",\n  \"CreatedBy\": \"test\",\n  \"CreatedOn\": 1623276844,\n  \"ModifiedOn\": 1623276844\n}\n```\n\n### Get User\n\n```shell\ncurl --location --request GET 'http://localhost:8080/api/v1/customers/1' \\\n--header 'token: eyJhbGciOiJI...GSqQhG8'\n```\n\nThe first call gets the data from postgres and store it in your Redis cache ans show it as:\n\n```json\n{\n  \"ID\": 1,\n  \"FirstName\": \"Jay\",\n  \"LastName\": \"Ehsaniara\",\n  \"Title\": \"Engineer\",\n  \"CreatedBy\": \"test\",\n  \"CreatedOn\": 1623276844,\n  \"ModifiedOn\": 1623276844\n}\n```\n\nLatter calls for the same customer id will be much faster because it's calling the redis from now on\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fehsaniara%2Fgo-crash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fehsaniara%2Fgo-crash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fehsaniara%2Fgo-crash/lists"}