{"id":16270867,"url":"https://github.com/mgrdich/testgoapi","last_synced_at":"2026-01-20T19:32:57.514Z","repository":{"id":228059886,"uuid":"773053461","full_name":"Mgrdich/testGoApi","owner":"Mgrdich","description":"Creating Api with Golang","archived":false,"fork":false,"pushed_at":"2024-06-30T19:29:47.000Z","size":3535,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-07T21:16:31.690Z","etag":null,"topics":["chi","go","golang-server","postrgresql","sql","sqlc"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Mgrdich.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-03-16T16:05:26.000Z","updated_at":"2024-06-30T19:29:50.000Z","dependencies_parsed_at":"2024-03-29T11:25:00.583Z","dependency_job_id":"d92cd95d-358d-451c-87d5-8a92ca4ce5d7","html_url":"https://github.com/Mgrdich/testGoApi","commit_stats":null,"previous_names":["mgrdich/testgoapi"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Mgrdich/testGoApi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mgrdich%2FtestGoApi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mgrdich%2FtestGoApi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mgrdich%2FtestGoApi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mgrdich%2FtestGoApi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mgrdich","download_url":"https://codeload.github.com/Mgrdich/testGoApi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mgrdich%2FtestGoApi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28610632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T18:56:40.769Z","status":"ssl_error","status_checked_at":"2026-01-20T18:54:26.653Z","response_time":117,"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":["chi","go","golang-server","postrgresql","sql","sqlc"],"created_at":"2024-10-10T18:11:50.355Z","updated_at":"2026-01-20T19:32:57.490Z","avatar_url":"https://github.com/Mgrdich.png","language":"Go","readme":"# Minor API project for Golang\n\n* In order to run the project you need to have `sqlc` please check https://github.com/sqlc-dev/sqlc\n* Goose to handle Database migrations https://github.com/pressly/goose\n\nProject demonstrates how to create Go Backend project using\n* `chi` for Router\n* `sqlc` for compiling `sql` into type safe code\n* `goose` to handle the database migrations\n\n## Start the application\n\ncreate `.env` file at root\n```shell\nPORT=8080\nPOSTGRESQL=postgres://username:password@localhost:5433/testGoApi\nGOOSE_DRIVER=postgres\nGOOSE_DBSTRING=${POSTGRESQL}\nGOOSE_MIGRATION_DIR=./internal/db/migrations\nENVIRONMENT=dev\nJWT_SECRET_KEY=SomeSecretKeyHere\nTOKEN_EXPIRE=10 # in minutes\n```\n\n```shell\nmake run\n```\n\n## Before Opening PR \n* make sure to run `make lint` to check for linter bugs\n\n## For Migrations\n* if you want to create new migration run `make migrate-create n=name-of-migration` it will create new file in `internal/db/migrations` with the correct name edit the up and down statements.\n* make you database up to date `make migrate-up`.\n* with `make migrate-down` please remove the associated file with it as well.\n* Make migrations file for `atomic` operations.\n\n\n## For Linting on the local machine\nInstall `golangci-lint` [Link](https://golangci-lint.run/welcome/install/) recommended way is to put it in the golang binary directory\n\n## Testing \nEverything should have corresponding test suites except the repository for now\n\n```shell \ncurl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin VERSION_NUMBER_HERE\n```\n\nadd the `$(go env GOPATH)` to `PATH`\n\n## For Swagger \n\nTo generate Swagger documentation for the API, first, you need to install swaggo CLI:\n```bash\ngo install github.com/swaggo/swag/cmd/swag@v1.16.3\n```\nAdd annotations to the controllers. Here's an example:\n```\n// HandleCreateUser creates a new user.\n// @Summary Create a new user\n// @Description Creates a new user with the provided details.\n// @Tags user\n// @Param username query string true \"Username of the new user\"\n// @Param email query string true \"Email address of the new user\"\n// @Param password query string true \"Password of the new user\"\n// @Success 201 {object} UserDTO \"User created successfully\"\n// @Failure 400 {object} ErrorResponse \"Invalid request format\"\n// @Failure 500 {object} ErrorResponse \"Internal server error\"\n// @Router /api/v1/users [post]\nfunc HandleCreateUser(w http.ResponseWriter, r *http.Request) {\n    // Handler logic to create a new user\n}\n```\nOnce the annotations are added, you can generate Swagger documentation by running:\n```bash\nmake gen-swagger\n```\nAfter running the command, you can access the documentation of your API by running the project and visiting:\nhttp://localhost:8080/swagger/index.html\n* Make sure you have ENVIRONMENT=dev added in .env  \n\n### For VsCode users\n```json\n\"go.lintTool\" : \"golangci-lint\",\n\"go.lintFlags\": [\n\"--fast\"\n]\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmgrdich%2Ftestgoapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmgrdich%2Ftestgoapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmgrdich%2Ftestgoapi/lists"}