MCPcopy
hub / github.com/bitfield/script / ExamplePipe_Do

Function ExamplePipe_Do

script_test.go:2303–2320  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2301}
2302
2303func ExamplePipe_Do() {
2304 ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
2305 data, err := io.ReadAll(r.Body)
2306 if err != nil {
2307 log.Fatal(err)
2308 }
2309 fmt.Fprintf(w, "You said: %s", data)
2310 }))
2311 defer ts.Close()
2312 req, err := http.NewRequest(http.MethodGet, ts.URL, strings.NewReader("hello"))
2313 if err != nil {
2314 log.Println(err)
2315 return
2316 }
2317 script.NewPipe().Do(req).Stdout()
2318 // Output:
2319 // You said: hello
2320}
2321
2322func ExamplePipe_EachLine() {
2323 script.File("testdata/test.txt").EachLine(func(line string, out *strings.Builder) {

Callers

nothing calls this directly

Calls 4

NewPipeFunction · 0.92
StdoutMethod · 0.80
DoMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…