https://github.com/y2k2mt/grouping-n-go
https://github.com/y2k2mt/grouping-n-go
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/y2k2mt/grouping-n-go
- Owner: y2k2mt
- License: bsd-3-clause
- Created: 2023-09-03T06:44:18.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-26T13:57:20.000Z (over 1 year ago)
- Last Synced: 2025-01-04T19:42:59.530Z (5 months ago)
- Language: Go
- Size: 56.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Grouping-N Go lang version
A tiny API: Just shuffles the given names.
### Setting up the project
1. Install go lang
1. Install [task](https://taskfile.dev/installation/)
1. Install [air](https://github.com/cosmtrek/air)
1. Install [migrate](https://github.com/golang-migrate/migrate/tree/master/cmd/migrate)
1. Run postgresql database server (e.g. `docker run --rm -d -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust postgres:14`)
1. Run `task migrate` to migrate local database
1. Run `task dev` to start the app
1. Request
```
curl localhost:1323/grouping -H 'Content-Type: application/json' -d '{"n": 2,"members": ["1","2","3","4","5","6","7","8"]}'
```
5. And response
```
< HTTP/1.1 200 OK
< Content-Type: application/json
< Content-Length: 126
{
"groups": [
{
"members": [
"8",
"7",
"3",
"2"
]
},
{
"members": [
"5",
"1",
"4",
"6"
]
}
],
"id": "08d6277f-89aa-4da2-b2d6-627cd91fc749"
}```