Grouping-N Go lang version
A tiny API: Just shuffles the given names.
Setting up the project
- Install go lang
- Install task
- Install air
- Install migrate
- Run postgresql database server (e.g.
docker run --rm -d -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust postgres:14
)
- Run
task migrate
to migrate local database
- Run
task dev
to start the app
- Request
curl localhost:1323/grouping -H 'Content-Type: application/json' -d '{"n": 2,"members": ["1","2","3","4","5","6","7","8"]}'
- 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"
}