{"id":13697250,"url":"https://github.com/ybkuroki/go-webapp-sample","last_synced_at":"2026-01-12T02:55:17.047Z","repository":{"id":37200602,"uuid":"255028857","full_name":"ybkuroki/go-webapp-sample","owner":"ybkuroki","description":"golang, echo, gorm","archived":false,"fork":false,"pushed_at":"2025-03-12T08:36:06.000Z","size":2055,"stargazers_count":456,"open_issues_count":6,"forks_count":1514,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-12T09:35:29.669Z","etag":null,"topics":["echo","golang","gorm","webapp"],"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/ybkuroki.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2020-04-12T07:13:44.000Z","updated_at":"2025-03-12T08:36:12.000Z","dependencies_parsed_at":"2024-01-05T09:29:57.789Z","dependency_job_id":"3a6992d9-5416-4137-9e36-4b4257459cde","html_url":"https://github.com/ybkuroki/go-webapp-sample","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ybkuroki%2Fgo-webapp-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ybkuroki%2Fgo-webapp-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ybkuroki%2Fgo-webapp-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ybkuroki%2Fgo-webapp-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ybkuroki","download_url":"https://codeload.github.com/ybkuroki/go-webapp-sample/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252242264,"owners_count":21717130,"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":["echo","golang","gorm","webapp"],"created_at":"2024-08-02T18:00:54.497Z","updated_at":"2026-01-12T02:55:17.039Z","avatar_url":"https://github.com/ybkuroki.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# go-webapp-sample\n\n[![license](https://img.shields.io/github/license/ybkuroki/go-webapp-sample?style=for-the-badge)](https://github.com/ybkuroki/go-webapp-sample/blob/master/LICENSE)\n[![report](https://goreportcard.com/badge/github.com/ybkuroki/go-webapp-sample?style=for-the-badge)](https://goreportcard.com/report/github.com/ybkuroki/go-webapp-sample)\n[![workflow](https://img.shields.io/github/actions/workflow/status/ybkuroki/go-webapp-sample/check.yml?label=check\u0026logo=github\u0026style=for-the-badge)](https://github.com/ybkuroki/go-webapp-sample/actions?query=workflow%3Acheck)\n[![release](https://img.shields.io/github/release/ybkuroki/go-webapp-sample?style=for-the-badge\u0026logo=github)](https://github.com/ybkuroki/go-webapp-sample/releases)\n\n## Preface\nThis repository is the sample of web application using golang.\nThis sample uses [Echo](https://echo.labstack.com/) as web application framework, [Gorm](https://gorm.io/) as OR mapper and [Zap logger](https://pkg.go.dev/go.uber.org/zap) as logger.\nThis sample application provides only several functions as Web APIs.\nPlease refer to the 'Service' section about the detail of those functions.\n\nAlso, this application contains the static contents such as html file, css file and javascript file which built [vuejs-webapp-sample](https://github.com/ybkuroki/vuejs-webapp-sample) project to easily check the behavior of those functions.\nSo, you can check this application without starting a web server for front end.\nPlease refer to the 'Starting Server' section about checking the behavior of this application.\n\nIf you would like to develop a web application using golang, please feel free to use this sample.\n\n## Install\nPerform the following steps:\n1. Download and install [Visual Studio Code(VS Code)](https://code.visualstudio.com/).\n1. Download and install [Golang](https://golang.org/).\n1. Get the source code of this repository by the following command.\n    ```bash\n    go install github.com/ybkuroki/go-webapp-sample@latest\n    ```\n\n## Starting Server\nThere are 2 methods for starting server.\n\n### Without Web Server\n1. Starting this web application by the following command.\n    ```bash\n    go run main.go\n    ```\n1. When startup is complete, the console shows the following message:\n    ```\n    http server started on [::]:8080\n    ```\n1. Access [http://localhost:8080](http://localhost:8080) in your browser.\n1. Login with the following username and password.\n    - username : ``test``\n    - password : ``test``\n\n### With Web Server\n#### Starting Application Server\n1. Starting this web application by the following command.\n    ```bash\n    go run main.go\n    ```\n1. When startup is complete, the console shows the following message:\n    ```\n    http server started on [::]:8080\n    ```\n1. Access [http://localhost:8080/api/health](http://localhost:8080/api/health) in your browser and confirm that this application has started.\n    ```\n    healthy\n    ```\n#### Starting Web Server\n1. Clone [vuejs-webapp-sample](https://github.com/ybkuroki/vuejs-webapp-sample) project and install some tools.\n1. Start by the following command.\n    ```bash\n    npm run dev\n    ```\n1. When startup is complete, the console shows the following message:\n    ```\n    \u003e vuejs-webapp-sample@*.*.* dev\n    \u003e vite --mode development\n    \n    \n    VITE v*.*.*  ready in 1362 ms\n    \n    ➜  Local:   http://localhost:3000/\n    ➜  press h to show help\n    ```\n1. Access [http://localhost:3000](http://localhost:3000) in your browser.\n1. Login with the following username and password.\n    - username : ``test``\n    - password : ``test``\n\n### With Docker\n#### building Docker image\n1. Run the below following commands:\n    ```bash\n    docker build -t go-webapp-sample .\n    ```\n2. command to start the container at port 8080\n    ```bash\n    docker run --name app -p 8080:8080 go-webapp-sample\n    ``` \n3. Access [http://localhost:8000](http://localhost:8080) in your browser.\n4. Login with the following username and password.\n    - username : ``test``\n    - password : ``test`` \n\n## Using Swagger\nIn this sample, Swagger is enabled only when executed this application on the development environment.\nSwagger isn't enabled on the another environments in default.\n\n### Accessing to Swagger\n1. Start this application according to the 'Starting Application Server' section.\n2. Access [http://localhost:8080/swagger/index.html](http://localhost:8080/swagger/index.html) in your browser.\n\n### Updating the existing Swagger document\n1. Update some comments of some controllers.\n2. Download Swag library. (Only first time)\n    ```bash\n    go install github.com/swaggo/swag/cmd/swag@latest\n    ```\n3. Update ``docs/docs.go``.\n    ```bash\n    swag init\n    ```\n\n## Build executable file\nBuild this source code by the following command.\n```bash\ngo build main.go\n```\n\n## Project Map\nThe following figure is the map of this sample project.\n\n```\n- go-webapp-sample\n  + config                  … Define configurations of this system.\n  + logger                  … Provide loggers.\n  + middleware              … Define custom middleware.\n  + migration               … Provide database migration service for development.\n  + router                  … Define routing.\n  + controller              … Define controllers.\n  + model                   … Define models.\n  + repository              … Provide a service of database access.\n  + service                 … Provide a service of book management.\n  + session                 … Provide session management.\n  + test                    … for unit test\n  - main.go                 … Entry Point.\n```\n\n## Services\nThis sample provides 3 services: book management, account management, and master management.\nRegarding the detail of the API specification, please refer to the 'Using Swagger' section.\n\n### Book Management\nThere are the following services in the book management.\n\n|Service Name|HTTP Method|URL|Parameter|Summary|\n|:---|:---:|:---|:---|:---|\n|Get Service|GET|``/api/books/[BOOK_ID]``|Book ID|Get a book data.|\n|List/Search Service|GET|``/api/books?query=[KEYWORD]\u0026page=[PAGE_NUMBER]\u0026size=[PAGE_SIZE]``|Page, Keyword(Optional)|Get a list of books.|\n|Regist Service|POST|``/api/books``|Book|Regist a book data.|\n|Edit Service|PUT|``/api/books``|Book|Edit a book data.|\n|Delete Service|DELETE|``/api/books``|Book|Delete a book data.|\n\n### Account Management\nThere are the following services in the Account management.\n\n|Service Name|HTTP Method|URL|Parameter|Summary|\n|:---|:---:|:---|:---|:---|\n|Login Service|POST|``/api/auth/login``|Session ID, User Name, Password|Session authentication with username and password.|\n|Logout Service|POST|``/api/auth/logout``|Session ID|Logout a user.|\n|Login Status Check Service|GET|``/api/auth/loginStatus``|Session ID|Check if the user is logged in.|\n|Login Username Service|GET|``/api/auth/loginAccount``|Session ID|Get the login user's username.|\n\n### Master Management\nThere are the following services in the Master management.\n\n|Service Name|HTTP Method|URL|Parameter|Summary|\n|:---|:---:|:---|:---|:---|\n|Category List Service|GET|``/api/categories``|Nothing|Get a list of categories.|\n|Format List Service|GET|``/api/formats``|Nothing|Get a list of formats.|\n\n## Tests\nCreate the unit tests only for the packages such as controller, service, model/dto and util. The test cases is included the regular cases and irregular cases. Please refer to the source code in each packages for more detail.\n\nThe command for testing is the following:\n```bash\ngo test ./... -v\n```\n\n## Libraries\nThis sample uses the following libraries.\n\n|Library Name|Version|\n|:---|:---:|\n|echo|4.11.4|\n|gorm|1.25.9|\n|go-playground/validator.v9|9.31.0|\n|zap|1.26.0|\n\n## Contribution\nPlease read [CONTRIBUTING.md](https://github.com/ybkuroki/go-webapp-sample/blob/master/CONTRIBUTING.md) for proposing new functions, reporting bugs and submitting pull requests before contributing to this repository.\n\n## License\nThe License of this sample is *MIT License*.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fybkuroki%2Fgo-webapp-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fybkuroki%2Fgo-webapp-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fybkuroki%2Fgo-webapp-sample/lists"}