()
| 16 | ) |
| 17 | |
| 18 | func main() { |
| 19 | ctx := context.Background() |
| 20 | |
| 21 | // ====== 示例 1: 连接 MySQL ====== |
| 22 | fmt.Println("=== Example 1: Connect to MySQL 8.0+ ===") |
| 23 | service := setupMySQLService() |
| 24 | defer func() { _ = service.Close() }() |
| 25 | |
| 26 | // ====== 示例 2: 创建 Session ====== |
| 27 | fmt.Println("\n=== Example 2: Create Session ===") |
| 28 | sess := createSessionExample(ctx, service) |
| 29 | |
| 30 | // ====== 示例 3: 事件追加 ====== |
| 31 | fmt.Println("\n=== Example 3: Append Events ===") |
| 32 | appendEventsExample(ctx, service, sess.ID) |
| 33 | |
| 34 | // ====== 示例 4: JSON 列的优势 ====== |
| 35 | fmt.Println("\n=== Example 4: JSON Column Benefits ===") |
| 36 | jsonColumnExample(ctx, service, sess.ID) |
| 37 | |
| 38 | // ====== 示例 5: 查询优化 ====== |
| 39 | fmt.Println("\n=== Example 5: Query Optimization ===") |
| 40 | queryOptimizationExample(ctx, service, sess.UserID) |
| 41 | |
| 42 | fmt.Println("\n✅ All MySQL examples completed!") |
| 43 | } |
| 44 | |
| 45 | // setupMySQLService 设置 MySQL 服务 |
| 46 | func setupMySQLService() *mysql.Service { |
nothing calls this directly
no test coverage detected