{"id":16112989,"url":"https://github.com/guilospanck/go-web-template","last_synced_at":"2025-10-07T23:06:49.090Z","repository":{"id":103567004,"uuid":"572083633","full_name":"Guilospanck/go-web-template","owner":"Guilospanck","description":"Template to use when building for the web with Go.","archived":false,"fork":false,"pushed_at":"2022-12-15T17:47:30.000Z","size":32,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-27T15:05:54.148Z","etag":null,"topics":["clean-code","golang","web-template"],"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/Guilospanck.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":"2022-11-29T14:17:52.000Z","updated_at":"2022-12-10T20:58:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"95853996-09ca-47cb-8bdf-02dc2ad88f94","html_url":"https://github.com/Guilospanck/go-web-template","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/Guilospanck/go-web-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Guilospanck%2Fgo-web-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Guilospanck%2Fgo-web-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Guilospanck%2Fgo-web-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Guilospanck%2Fgo-web-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Guilospanck","download_url":"https://codeload.github.com/Guilospanck/go-web-template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Guilospanck%2Fgo-web-template/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262279106,"owners_count":23286548,"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","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":["clean-code","golang","web-template"],"created_at":"2024-10-09T20:09:55.584Z","updated_at":"2025-10-07T23:06:44.058Z","avatar_url":"https://github.com/Guilospanck.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go Web Template\nThis is a template to be used when writing Go for the web.\n\nIt covers concepts of Clean Code, unit testing, GitHub actions and other practices and, for those, it uses:\n- [Gin](https://github.com/gin-gonic/gin) to handle HTTP requests;\n- [Zap](https://github.com/uber-go/zap) for logging;\n- [GoDotEnv](https://github.com/joho/godotenv) for managing environments; and\n- [Testify](https://github.com/stretchr/testify) for unit testings.\n\n## Installation\n### Local\nBe sure to have [Go](https://go.dev/doc/install) installed. \n\nThen, clone this repository:\n```bash\ngit clone https://github.com/Guilospanck/go-web-template.git\ncd go-web-template/\n```\nAnd then install dependencies:\n```bash\ngo mod download\n```\n\n### Docker\nBuild the image:\n```bash\ndocker build -t guilospanck/go-web-template .\n```\n\nRun the container:\n```bash\ndocker run -d -p 4444:4444 guilospanck/go-web-template\n```\n\n## How to use\nIf you wanna dive into the \"project\" and play with it, you can just run:\n```bash\nmake run-local\n```\n\nBut, on the other hand, if you wanna use it as a template for your next Go project, just click in `Use this template`.\n\n## Playing with the application\n### Endpoints\nThere's only one endpoint for this sample application. It will listen at `http://localhost:4444/ping` for a POST request and will return the following JSON:\n```json\n{\n\t\"Pong\": 1\n}\n```\n\n### Curl\nYou can also make the requests using `curl`:\n```bash\ncurl --request POST \\\n  --url http://localhost:4444/ping \\\n  --header 'Content-Type: application/json' \\\n  --data '{}'\n```\n\n## Understanding the format of the application\nEvery package tries to follow the pattern of Clean Code architecture.\n\nThe entry point of the program is the `main.go` file as usual. It'll execute the commands that are inside `cmd/root.go` and panic if something goes wrong.\n\nThe `cmd/root.go` file is responsible for instantiating all the packages necessaries for running the application (the \"container\" that resides inside the `cmd/iot.go` file) and start the HTTP server.\n\nAs everything inside the `pkg` folder follows the concept of Clean Code, the packages only communicate with each other via `interfaces`. Therefore `cmd/iot.go` is where the concrete implementations of those interfaces are instantiated.\n\nFinally, the `pkg` folder contains the following structure:\n```\n.\n├── application\n│   ├── errors\n│   ├── interfaces\n│   └── usecases\n│       └── ping\n├── domain\n│   ├── dtos\n│   └── usecases\n├── infrastructure\n│   ├── adapters\n│   ├── environments\n│   ├── http_server\n│   └── logger\n└── interface\n    └── http\n        ├── factories\n        ├── handlers\n        └── presenters\n```\nAnd the flux happens like this:\n```\ninterface \u003c-\u003e applications \u003c-\u003e infrastructure/domain\n```\n- `interface`: defines the ways that our application can interface with the outside world. In this case, there's only `http`, but there may exist `graphql`, `gRPC` or any other type of communication.\n    - `presenters`: here we define our routes (endpoints)\n    - `handlers`: they act like controllers, changing the traffic from outside the application to the right path inside it.\n- `application`: here lies our \"use cases\". They describe what the application does in a higher level. The point is that the use cases should explain to an outsider, just by looking at their names, what is the flux and functions that the application have.\n- `infrastructure`: here usually lies the libraries/frameworks/ORMs that we inject in our application. This is the \"external layer\" of the architecture. They should allow easy replacement without compromising the whole application. We should not depend on them.\n- `domain`: everything related to our business cases. DTOS, Enums, the interfaces that represent our use cases.\n\n## Running tests\nTo run tests, you can run the commands:\n```bash\nmake test\n# or\nmake test-cov\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguilospanck%2Fgo-web-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguilospanck%2Fgo-web-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguilospanck%2Fgo-web-template/lists"}