很高興有個機會製作面試前的測試作業,也就趁這個機會做個筆記以及學習紀錄。
前置作業 先點列一下項目需求:
基本需求 based on golnag The API interface you provide can be any of the following:RESTful、json rpc、gRPC At least two sources When a source is unavailable, the result of its last successful ask is returned Use git to manage source code Write readme.md and describe what features, features, and TODO which have been implemented 額外可選 Traffic limits, including the number of times your server queries the source, and the number of times the user queries you Good testing, annotations, and git commit An additional websocket interface is provided to automatically send the latest information whenever the market changes Users can choose to use an automatic source determination, the latest data source, or manually specify the source of the data Package it as a Dockerfile, docker-compose file, or kubernetes yaml There is a simple front-end or cli program that displays the results The API you provide has a corresponding file, such as a swagger, or simply a markdown file Other features not listed but that you thought would be cool to implement 這邊就必須要先打預防針了,這篇僅為學習筆記,並非正式教學。且,我只是 Golang 初學者,所以這篇內也不會出現什麼高等級的解法,甚至也是第一次實作介接 API 呢 (笑)。而 DB 以及 redis 都是直接以方便使用去寫 dbi 而已並無用抽象曾去封裝,也進而導致 unit test 十分困難先擱置了,有空才會再針對性重構,而此次就先將目標專注在 API 介接。...