{"id":15187345,"url":"https://github.com/elliotxx/go-web-template","last_synced_at":"2025-04-26T23:31:44.876Z","repository":{"id":46247373,"uuid":"413654094","full_name":"elliotxx/go-web-template","owner":"elliotxx","description":"Template application of Domain Driven Design(DDD) in go and gin.","archived":false,"fork":false,"pushed_at":"2023-08-07T11:23:20.000Z","size":122,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-24T21:06:35.472Z","etag":null,"topics":["example","gin","go","golang","web"],"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/elliotxx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-10-05T02:55:40.000Z","updated_at":"2025-03-11T11:14:17.000Z","dependencies_parsed_at":"2023-08-12T11:38:11.352Z","dependency_job_id":null,"html_url":"https://github.com/elliotxx/go-web-template","commit_stats":null,"previous_names":["elliotxx/standard-sample-go-web","elliotxx/go-web-template","elliotxx/go-web-prototype"],"tags_count":9,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elliotxx%2Fgo-web-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elliotxx%2Fgo-web-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elliotxx%2Fgo-web-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elliotxx%2Fgo-web-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elliotxx","download_url":"https://codeload.github.com/elliotxx/go-web-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251068038,"owners_count":21531475,"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":["example","gin","go","golang","web"],"created_at":"2024-09-27T18:20:23.482Z","updated_at":"2025-04-26T23:31:44.597Z","avatar_url":"https://github.com/elliotxx.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Introduction\n\n\n[![GitHub release](https://img.shields.io/github/release/elliotxx/go-web-template.svg)](https://github.com/elliotxx/go-web-template/releases)\n[![Github All Releases](https://img.shields.io/github/downloads/elliotxx/go-web-template/total.svg)](https://github.com/elliotxx/go-web-template/releases)\n[![license](https://img.shields.io/github/license/elliotxx/go-web-template.svg)](https://github.com/elliotxx/go-web-template/blob/master/LICENSE)\n[![Coverage Status](https://coveralls.io/repos/github/elliotxx/go-web-template/badge.svg)](https://coveralls.io/github/elliotxx/go-web-template)\n\n\u003e Template application of Domain Driven Design(DDD) in go and gin.\n\n## Usage\nPrepare database:\n```shell\n$ docker pull mariadb:10.5\n$ docker run -d --env MARIADB_USER=app --env MARIADB_PASSWORD=app123 --env MARIADB_ROOT_PASSWORD=123456 -p 127.0.0.1:3306:3306 mariadb:10.5\n$ mysql -h 127.0.0.1 -u root -p123456\n    \u003e CREATE DATABASE IF NOT EXISTS appdb CHARACTER SET utf8mb4;\n    \u003e DROP USER 'app';\n    \u003e CREATE USER IF NOT EXISTS 'app' IDENTIFIED BY 'app123';\n    \u003e GRANT ALL ON appdb.* TO `app`;\n    \u003e exit\n```\n\nLocal startup:\n```\n$ go run cmd/main.go -f config/local.yaml\n```\n\nLocal verification:\n```\n➜ curl http://localhost:80/livez    \nOK\n\n➜ curl http://localhost:80/readyz\n[+] Database ok\n[+] Ping ok\nhealth check passed\n\n➜ curl http://localhost:80/endpoints\nDELETE  /api/v1/systemconfig/:id\nGET     /api/v1/systemconfig/:id\nGET     /api/v1/systemconfig/count\nGET     /api/v1/systemconfigs\nGET     /debug/pprof/\nGET     /debug/pprof/allocs\nGET     /debug/pprof/block\nGET     /debug/pprof/cmdline\nGET     /debug/pprof/goroutine\nGET     /debug/pprof/heap\nGET     /debug/pprof/mutex\nGET     /debug/pprof/profile\nGET     /debug/pprof/symbol\nGET     /debug/pprof/threadcreate\nGET     /debug/pprof/trace\nGET     /debug/statsviz/*filepath\nGET     /debug/vars\nGET     /docs/*any\nGET     /livez\nGET     /readyz\nPOST    /api/v1/systemconfig\nPOST    /debug/pprof/symbol\nPUT     /api/v1/systemconfig\n\n➜ curl http://localhost:80/debug/vars\n{\n    \"appOptions\": {\n        \"database\": {\n            \"autoMigrate\": true,\n            \"dbHost\": \"127.0.0.1\",\n            \"dbName\": \"appdb\",\n            \"dbPassword\": \"******\",\n            \"dbPort\": 3306,\n            \"dbUser\": \"app\",\n            \"migrateFile\": \"./assets/sql/app.sql\"\n        },\n        \"generic\": {\n            \"configFile\": \"config/local.yaml\",\n            \"dumpEnvs\": false,\n            \"dumpVersion\": false\n        },\n        \"logging\": {\n            \"disableText\": true,\n            \"dumpCurrentConfig\": true,\n            \"enableLoggingToFile\": true,\n            \"jsonPretty\": true,\n            \"logLevel\": \"debug\",\n            \"loggingDirectory\": \"logs\",\n            \"reportCaller\": true\n        },\n        \"network\": {\n            \"port\": 80,\n            \"requestTimeout\": 30000000000\n        }\n    },\n    \"version\": {\n        \"buildInfo\": {\n            \"GOARCH\": \"amd64\",\n            \"GOOS\": \"darwin\",\n            \"buildTime\": \"2023-08-07 17:29:54\",\n            \"compiler\": \"gc\",\n            \"goVersion\": \"go1.19.9\",\n            \"numCPU\": 8\n        },\n        \"gitInfo\": {\n            \"commit\": \"87a0dd63b10473eedf5660f6e319492647d29389\",\n            \"latestTag\": \"v0.2.0\",\n            \"treeState\": \"dirty\"\n        },\n        \"releaseVersion\": \"v0.2.0-87a0dd63\"\n    }\n}\n\n➜ curl -s http://localhost:80/api/v1/systemconfig/count | jq\n{\n  \"success\": true,\n  \"code\": \"00000\",\n  \"message\": \"OK\",\n  \"data\": {\n    \"total\": 0\n  },\n  \"traceID\": \"754a40b1-1a80-43ff-adc5-2caf65de8db8\",\n  \"startTime\": \"2023-08-07T17:59:37.74405+08:00\",\n  \"endTime\": \"2023-08-07T17:59:37.746765+08:00\",\n  \"costTime\": \"2.715053ms\"\n}\n\n➜ curl -s --request POST 'http://localhost:80/api/v1/systemconfig' \\       \n--header 'Content-Type: application/json' \\\n--data '{\n  \"tenant\": \"MAIN_SITE\",\n  \"env\": \"prod\",\n  \"type\": \"config\",\n  \"config\": \"{'\\''abc'\\'': '\\''xxx'\\''}\",\n  \"description\": \"config\",\n  \"creator\": \"elliotxx\",\n  \"modifier\": \"\"\n}' | jq\n{\n  \"success\": true,\n  \"code\": \"00000\",\n  \"message\": \"OK\",\n  \"data\": {\n    \"id\": 1400004,\n    \"tenant\": \"MAIN_SITE\",\n    \"env\": \"prod\",\n    \"type\": \"config\",\n    \"config\": \"{'abc': 'xxx'}\",\n    \"description\": \"config\",\n    \"creator\": \"elliotxx\",\n    \"createdAt\": \"2023-08-07T18:01:05.32+08:00\",\n    \"updatedAt\": \"2023-08-07T18:01:05.32+08:00\"\n  },\n  \"traceID\": \"129f98e8-cf45-4060-90b2-05b861128ff3\",\n  \"startTime\": \"2023-08-07T18:01:05.315387+08:00\",\n  \"endTime\": \"2023-08-07T18:01:05.330384+08:00\",\n  \"costTime\": \"14.996752ms\"\n}\n\n➜ curl -s --location --request GET 'http://localhost:80/api/v1/systemconfigs' \\\n--header 'Content-Type: application/json' \\\n--data '{    \n    \"page\": 1,\n    \"perPage\": 3,\n    \"keyword\": \"\"\n}' | jq\n{\n  \"success\": true,\n  \"code\": \"00000\",\n  \"message\": \"OK\",\n  \"data\": [\n    {\n      \"id\": 1400004,\n      \"tenant\": \"MAIN_SITE\",\n      \"env\": \"prod\",\n      \"type\": \"config\",\n      \"config\": \"{'abc': 'xxx'}\",\n      \"description\": \"config\",\n      \"creator\": \"elliotxx\",\n      \"createdAt\": \"2023-08-07T18:01:05.32+08:00\",\n      \"updatedAt\": \"2023-08-07T18:01:05.32+08:00\"\n    }\n  ],\n  \"traceID\": \"ba332ec3-36ff-4a18-a835-83b28f50d7fa\",\n  \"startTime\": \"2023-08-07T18:03:31.790936+08:00\",\n  \"endTime\": \"2023-08-07T18:03:31.798123+08:00\",\n  \"costTime\": \"7.18668ms\"\n}\n```\n\nLocal build:\n```\n$ make build-all\n```\n\nRun all unit tests:\n```\nmake cover\n```\n\nAll targets:\n```\n$ make help\nhelp                           This help message :)\ntest                           Run the tests\ncover                          Generates coverage report\ncover-html                     Generates coverage report and displays it in the browser\nformat                         Format source code\nlint                           Lint, will not fix but sets exit code on error\nlint-fix                       Lint, will try to fix errors and modify code\ndoc                            Start the documentation server with godoc\nclean                          Clean build bundles\nbuild-all                      Build for all platforms\nbuild-darwin                   Build for MacOS\nbuild-linux                    Build for Linux\nbuild-windows                  Build for Windows\ngen-api-docs                   Generate API documentation with OpenAPI format\ngen-version                    Generate version file\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felliotxx%2Fgo-web-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felliotxx%2Fgo-web-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felliotxx%2Fgo-web-template/lists"}