()
| 2492 | } |
| 2493 | |
| 2494 | func ExamplePipe_Post() { |
| 2495 | ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 2496 | data, err := io.ReadAll(r.Body) |
| 2497 | if err != nil { |
| 2498 | log.Fatal(err) |
| 2499 | } |
| 2500 | fmt.Fprintf(w, "You said: %s", data) |
| 2501 | })) |
| 2502 | defer ts.Close() |
| 2503 | script.Echo("hello").Post(ts.URL).Stdout() |
| 2504 | // Output: |
| 2505 | // You said: hello |
| 2506 | } |
| 2507 | |
| 2508 | func ExamplePipe_Read() { |
| 2509 | buf := make([]byte, 12) |