29 lines
476 B
Go
Raw Permalink Normal View History

2022-02-12 00:22:02 +01:00
package main
import (
"fmt"
2022-02-13 22:43:45 +01:00
"io"
2022-02-12 00:22:02 +01:00
"net/http"
"os"
)
2022-02-13 22:43:45 +01:00
type logWriter struct{}
2022-02-12 00:22:02 +01:00
func main() {
resp, err := http.Get("https://google.com")
if err != nil {
fmt.Println("Error!")
os.Exit(1)
}
2022-02-13 22:43:45 +01:00
// bs := make([]byte, 99999) // necessary because Read() only fills a fix amount
// resp.Body.Read(bs)
// fmt.Println(string(bs))
lw := logWriter{}
io.Copy(lw, resp.Body)
}
func (l logWriter) Write(bs []byte) (int, error) {
fmt.Println(string(bs))
return len(bs), nil
2022-02-12 00:22:02 +01:00
}