{"id":22813110,"url":"https://github.com/coderivan/go-echo-server","last_synced_at":"2026-04-30T00:02:57.035Z","repository":{"id":48669081,"uuid":"335626291","full_name":"CoderIvan/go-echo-server","owner":"CoderIvan","description":"用于收集终端通过UDP、HTTP、MQTT和TCP发送过来的报文","archived":false,"fork":false,"pushed_at":"2023-05-05T02:31:13.000Z","size":162,"stargazers_count":3,"open_issues_count":7,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-06T01:47:15.706Z","etag":null,"topics":["aliyun-sls","gin","golang","http","udp"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CoderIvan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-03T13:02:48.000Z","updated_at":"2024-05-13T16:51:14.000Z","dependencies_parsed_at":"2022-09-05T01:51:27.355Z","dependency_job_id":null,"html_url":"https://github.com/CoderIvan/go-echo-server","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoderIvan%2Fgo-echo-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoderIvan%2Fgo-echo-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoderIvan%2Fgo-echo-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoderIvan%2Fgo-echo-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CoderIvan","download_url":"https://codeload.github.com/CoderIvan/go-echo-server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246385410,"owners_count":20768668,"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":["aliyun-sls","gin","golang","http","udp"],"created_at":"2024-12-12T12:15:07.131Z","updated_at":"2026-04-30T00:02:56.941Z","avatar_url":"https://github.com/CoderIvan.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-echo-server\r\n\r\n## 客户端\r\n\r\n### HTTP\r\n  * 客户端使用HTTP协议POST方向，发送数据\r\n  * Body内容可以为`application/json`，也可以为`text/plain`，建议使用JSON格式，方便解析与统计\r\n  * tagName标记为`http-server`\r\n  * 在服务地址后可以追加`项目名(projectName)`，即`http://localhost/:projectName`\r\n    * 例如`http://localhost/ivan`，则项目名为`ivan`\r\n\r\n### UDP\r\n  * 客户端使用UDP发送数据\r\n  * 服务器接收到的二进制内容均使用`UTF-8`解码成文本，建议文本内容使用JSON格式，方便解析与统计\r\n  * tagName标记为`udp-server`\r\n  * 在UDP包前可以追加`$ + 项目名(projectName) + #`，即`${{projectName}}#{{内容}}`\r\n    * 例如`\"$ivan#{\\\"sn\\\":\\\"0000000004\\\",\\\"iccid\\\":\\\"90000000000000000004\\\",\\\"imei\\\":\\\"900000000000004\\\",\\\"random\\\":\\\"Some bytes:0.17507057398090065\\\"}\"`，则项目名为`ivan`\r\n\r\n### MQTT\r\n  * 客户端使用MQTT发送数据\r\n  * 服务器接收到的二进制内容均使用`UTF-8`解码成文本，建议文本内容使用JSON格式，方便解析与统计\r\n  * tagName标记为`mqtt-server`\r\n  * `client id`最好填sn之类的唯一标识，最终显示为`contextID`\r\n  * `username`最好填项目名之类的，最终显示为`projectName`\r\n\r\n### TCP\r\n  * 客户端使用TCP发送数据\r\n  * 报文内容，为`两字节报长度`+`报文内容`\r\n    * 如发送`48 65 6c 6c 6f 20 57 6f 72 6c 64`，则要在前面加上长度11，即`00 0b`，最终为`00 0b 48 65 6c 6c 6f 20 57 6f 72 6c 64`\r\n  * 服务器接收到的二进制内容均使用`UTF-8`解码成文本，建议文本内容使用JSON格式，方便解析与统计\r\n  * tagName标记为`tcp-server`\r\n  * 如果第一个包使用`$` + `项目名(projectName)` + `#` + `上下文ID(contextID)` + `#`\r\n    * 例如：`$BigProject#Ivan#`，则项目名为`BigProject`，上下文ID为`Ivan`\r\n  * `上下文ID`建议使用SN之类的唯一标识\r\n\r\n### GRPC\r\n  * 客户端根据指定的[proto文件](./server/message/message.proto)发送数据\r\n\r\n## 服务器\r\n\r\n### win10\r\n执行\r\n```bash\r\ngo env -w GO111MODULE=on\r\n```\r\n```bash\r\ngo env -w GOPROXY=https://goproxy.io\r\n```\r\n```bash\r\ngo build .\r\n```\r\n```bash\r\n.\\go-echo-server.exe\r\n```\r\n\r\n### 运行\r\n```bash\r\ngo run main\r\n```\r\n\r\n### 单元测试\r\n```bash\r\ngo test go-echo-server/server -v\r\ngo test go-echo-server/handler -v\r\n```\r\n\r\n### 覆盖率测试\r\n```bash\r\ngo test go-echo-server/server -cover\r\ngo test go-echo-server/handler -cover\r\n```\r\n\r\n### 基准测试\r\n```bash\r\ngo test -benchmem -run=^$ -bench . go-echo-server/server\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderivan%2Fgo-echo-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoderivan%2Fgo-echo-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderivan%2Fgo-echo-server/lists"}