# go-server-tutorial **Repository Path**: jesson-deng/go-server-tutorial ## Basic Information - **Project Name**: go-server-tutorial - **Description**: No description available - **Primary Language**: Go - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-03-05 - **Last Updated**: 2026-03-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # go-server-tutorial 面向新手的 Go 服务器编程教程:以“期货行情服务(模拟数据)”为例,从 `net/http` 的 Hello API 到 REST + WebSocket 的完整小项目。 ## 快速开始 运行最小示例(Hello API): ```bash go run ./cmd/helloapi ``` 运行完整行情服务: ```bash go run ./cmd/quoteserver ``` 常用接口: ```bash curl http://localhost:8080/healthz curl http://localhost:8080/symbols curl "http://localhost:8080/quote?symbol=rb2405" curl -H "X-API-Key: dev-key" "http://localhost:8080/candles?symbol=rb2405&tf=1m&limit=10" ``` ## 配置(环境变量) - `PORT`:默认 `8080` - `API_KEY`:默认 `dev-key`(用于 `GET /candles`) - `ALLOWED_ORIGINS`:默认 `*`(CORS) - `REQUEST_TIMEOUT`:默认 `3s` ## 文档 - `docs/README.md`:按讲解大纲的阅读顺序 - `docs/run-by-chapter.md`:按章节运行(`cmd/chXX`) - `go-server-tutorial-outline.md`:原始讲解大纲