{"id":23709272,"url":"https://github.com/kecci/goscription","last_synced_at":"2025-08-11T05:12:43.759Z","repository":{"id":111445731,"uuid":"247631954","full_name":"kecci/goscription","owner":"kecci","description":"Goscription is skeleton project with simple design \u0026 clean code with Go","archived":false,"fork":false,"pushed_at":"2022-09-30T20:42:54.000Z","size":280,"stargazers_count":43,"open_issues_count":0,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-04T17:04:17.855Z","etag":null,"topics":["swag","swagger","swagger-docs","swagger-ui","viper"],"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/kecci.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2020-03-16T06:56:02.000Z","updated_at":"2024-04-25T12:55:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"bfeb9263-7f02-4a69-b550-0531ec6fdfef","html_url":"https://github.com/kecci/goscription","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/kecci/goscription","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kecci%2Fgoscription","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kecci%2Fgoscription/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kecci%2Fgoscription/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kecci%2Fgoscription/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kecci","download_url":"https://codeload.github.com/kecci/goscription/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kecci%2Fgoscription/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269832939,"owners_count":24482341,"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-11T02:00:10.019Z","response_time":75,"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":["swag","swagger","swagger-docs","swagger-ui","viper"],"created_at":"2024-12-30T18:06:01.872Z","updated_at":"2025-08-11T05:12:43.738Z","avatar_url":"https://github.com/kecci.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Go Report Card](https://goreportcard.com/badge/github.com/kecci/goscription)](https://goreportcard.com/report/github.com/kecci/goscription)\n# Goscription\n\nGoscription is a sample of template RESTful API Project\n\n## Features\n\nSome features \u0026 libraries used on this template:\n1. REST API (**labstack/echo**)\n2. Dependency Injection (**uber-go/fx**)\n3. NSQ Messaging (**segmentio/nsq-go**)\n4. Custom CLI (**spf13/cobra**)\n5. Custom Config File (**spf13/viper**)\n6. SQL Generator (**squirrel**)\n7. Migrations (**go-migrate**)\n8. Swagger API Docs Generator (**swaggo/swag**)\n9. Mock Generator (**vektra/mockery**)\n10. Custom Logger (**sirupsen/logrus**)\n11. Dockerize an Application (**docker**)\n12. Circuit Breaker (**hystrix-go/hystrix** \u0026\u0026 **eapache/go-resiliency**)\n13. Message Streams: Pub/Sub, Kafka, RabbitMQ, etc (**ThreeDotsLabs/watermill**) [Soon]\n\n## Installation\n\n* Clone the Repos\n```bash\n$ git clone https://github.com/kecci/goscription.git\n```\n\n## Command\nThis command is provided in Makefile. You can see all command with make:\n```bash\n$ make\n\n Choose a command run in goscription:\n\n  mockery-prepare    install mockery before generate\n  mockery-generate   generate all mock\n  test-docker        test docker integration\n  test-unit          run all unit test\n  go-build           build to compile the project \u0026 swagger docs\n  go-run             run project\n  docker-build       dockerize the project\n  docker-up          run docker compose up\n  docker-down        run docker compose down\n  swagger-init       initialize swagger to folder ./docs\n  swagger-validate   validate swagger.yaml in folder ./docs\n  migrate-prepare    prepare migrate the schema with mysql\n  migrate-up         run migration up to latest version\n  migrate-down       run migration down to oldest version\n```\n\n## Project Structure\n\n```bash\n.\n├── app\n│   ├── cmd\n│   └── main.go\n├── internal\n│   ├── controller\n│   ├── database\n│   │   └── mysql\n│   │       └── migrations\n│   ├── middleware\n│   ├── outbound\n│   └── service\n├── mocks\n├── models\n└── util\n```\n\n## Dependency Injection\nI found this library is very useful and you no need to generate anything. Just code. Very modular and clear layer.\n\n### uber-go/fx\nA dependency injection based application framework for Go.\n\n```go\nfunc main() {\n\tfx.New(opts()).Run()\n}\n\nfunc opts() fx.Option {\n\treturn fx.Options(\n\t\tfx.Provide( \n\t\t\tNewTimeOutContext, \n\t\t\tNewDbConn, \n\t\t),\n\t\trepository.Module, // Provide All Repository Module\n\t\tservice.Module, // Provide All Service Module\n\t\toutbound.Module, // Provide All Outbound Module\n\t\tserver.Module, // Provide Runner/Stopper Server\n\t\tfx.Invoke( // Invoke List of Controller\n      controller.InitFooController, \n      controller.InitBarController,\n\t\t),\n\t)\n}\n```\nFor more information about uber-go/fx: https://github.com/uber-go/fx\n\n## Config Properties\n### spf13/viper\nViper is a complete configuration solution for Go applications. viper can reading from: \n* JSON, \n* TOML, \n* YAML, \n* HCL, \n* INI,\n* envfile, and \n* Java properties config files\n\nReading Config Files:\n```go\nviper.SetConfigName(\"config\") // name of config file (without extension)\nviper.SetConfigType(\"yaml\") // REQUIRED if the config file does not have the extension in the name\nviper.AddConfigPath(\"/etc/appname/\")   // path to look for the config file in\nviper.AddConfigPath(\"$HOME/.appname\")  // call multiple times to add many search paths\nviper.AddConfigPath(\".\")               // optionally look for config in the working directory\nerr := viper.ReadInConfig() // Find and read the config file\nif err != nil { // Handle errors reading the config file\n\tpanic(fmt.Errorf(\"Fatal error config file: %s \\n\", err))\n}\n```\n\nUse Value from Config:\n```go\nviper.Get(\"name\") // this would be \"steve\"\n```\n\nYou can do a lot more with viper, see more the documetation: https://github.com/spf13/viper\n\n### TOML\nWe are using toml in this sample project, for example:\n```toml\ntitle=\"Configuration File for Goscription\"\ndebug=true\ncontextTimeout=\"5\"\n[server]\n  address= \":9090\"\n[database]\n  host=\"mysql\"\n  port=\"3306\"\n  user=\"root\"\n  pass=\"root\"\n  name=\"article\"\n```\n\n## Swagger\n\n### swag UI\nBecause our project setup the path of swagger in: `/swagger/*`. You can access swagger UI in here: http://localhost:9090/swagger/index.html\n\n### swaggo/swag\nSwag converts Go annotations to Swagger Documentation 2.0. We've created a variety of plugins for popular Go web frameworks. This allows you to quickly integrate with an existing Go project (using Swagger UI).\n\nSupported Web Frameworks:\n* gin\n* echo\n* buffalo\n* net/http\n\n### swag annotation\nSwag has handled your swagger docs. So you no longer need to write `swagger.yml` or `swagger.json`. What you need to do is just write annotations. This is an example:\n\n```go\n// @title Blueprint Swagger API\n// @version 1.0\n// @description Swagger API for Golang Project Blueprint.\n// @termsOfService http://swagger.io/terms/\n\n// @contact.name API Support\n// @contact.email martin7.heinz@gmail.com\n\n// @license.name MIT\n// @license.url https://github.com/MartinHeinz/go-project-blueprint/blob/master/LICENSE\n\n// @BasePath /api/v1\nfunc main() {\n    ...\n    r.GET(\"/swagger/*any\", ginSwagger.WrapHandler(swaggerFiles.Handler))\n    ...\n}\n```\n\nYou can see more about swag annotation in here: https://github.com/swaggo/swag.\n\n## Benchmark\nUsing https://github.com/wg/wrk\n\nScript:\n```sh\nwrk -t8 -c256 -d30s http://localhost:9090/health\n```\n\nOutput:\n```sh\nRunning 30s test @ http://localhost:9090/health\n  8 threads and 256 connections\n  Thread Stats   Avg      Stdev     Max   +/- Stdev\n    Latency    13.17ms   11.67ms 153.74ms   71.04%\n    Req/Sec     2.82k   660.71     6.40k    69.88%\n  675770 requests in 30.08s, 150.16MB read\n  Socket errors: connect 0, read 121, write 0, timeout 0\nRequests/sec:  22464.24\nTransfer/sec:      4.99MB\n```\n\n## Sources\nThis template is inspired \u0026 modified from https://github.com/golangid/menekel\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkecci%2Fgoscription","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkecci%2Fgoscription","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkecci%2Fgoscription/lists"}