I preferred usage of the global lock as a synchronization technique instead of the usage of redis red-lock to prevent the installation of additional server.
I decided not to pick any framework like gin, fiber or any othermicroservice framework like go kit.
For routing I decided to make use of github.com/go-chi/chi over of the the well-known gorilla/mux.
chi supports https://en.wikipedia.org/wiki/Radix_tree which make the routes readable and has a good way of providing the versioning of the API using the same technique mentioned above.
I also used the <github.com/satori/go.uuid> for assigning the accountID value. You will find it used at CreateAccount() HandleFunc.
I know that not all cased have been covered inside the code. I think that such service has an endless validations.
I felt enough just to write the most important ones.
I hope that I have understood the task well. injesting the mock-accounts.json file has been made through normal os.Open(path) function. instead on writing an init() function. I decided to write inner-main go routine and the http server intialization kept in a seperated goroutine.
The second one is locked till the completion of the first one.
I have added a test.http file inside the project so that if you're using vscode then all you need to download rest extension
POST http://localhost:8080/api/v1/accounts/transfer Content-Type: application/json { "sender_id": "b4433e5b-af63-4aa8-9887-3dd98c2d7968", "recipient_id": "5ca7d5ea-f8ce-410c-bd82-b075d1ecb9fb", "amount": "100000" }