()
| 14 | ) |
| 15 | |
| 16 | func main() { |
| 17 | ctx := context.Background() |
| 18 | |
| 19 | // ====== 示例 1: 基础异步执行 ====== |
| 20 | fmt.Println("=== Example 1: Basic Async Execution ===") |
| 21 | basicAsyncExample(ctx) |
| 22 | |
| 23 | // ====== 示例 2: 进度跟踪 ====== |
| 24 | fmt.Println("\n=== Example 2: Progress Tracking ===") |
| 25 | progressTrackingExample(ctx) |
| 26 | |
| 27 | // ====== 示例 3: 任务取消 ====== |
| 28 | fmt.Println("\n=== Example 3: Task Cancellation ===") |
| 29 | cancellationExample(ctx) |
| 30 | |
| 31 | // ====== 示例 4: 并发多任务 ====== |
| 32 | fmt.Println("\n=== Example 4: Concurrent Tasks ===") |
| 33 | concurrentTasksExample(ctx) |
| 34 | |
| 35 | // ====== 示例 5: 任务清理 ====== |
| 36 | fmt.Println("\n=== Example 5: Task Cleanup ===") |
| 37 | cleanupExample(ctx) |
| 38 | |
| 39 | fmt.Println("\n✅ All examples completed!") |
| 40 | } |
| 41 | |
| 42 | // basicAsyncExample 基础异步执行示例 |
| 43 | func basicAsyncExample(ctx context.Context) { |
nothing calls this directly
no test coverage detected