diff --git a/curl.go b/curl.go index f3aa428..6f3b66a 100644 --- a/curl.go +++ b/curl.go @@ -6,7 +6,6 @@ import ( "fmt" "os/exec" - "git.milar.in/milarin/adverr" "github.com/PuerkitoBio/goquery" ) @@ -26,23 +25,11 @@ func (api *Api) GetWithCookie(ctx context.Context, url string) (*goquery.Documen if err != nil { return nil, ErrCurlRequestFailed.Wrap(err, url) } - defer stdout.Close() - - stderr, err := curl.StderrPipe() - if err != nil { - return nil, ErrCurlRequestFailed.Wrap(err, url) - } - defer stderr.Close() if err := curl.Start(); err != nil { return nil, ErrCurlRequestFailed.Wrap(err, url) } - - go func() { - if err := curl.Wait(); err != nil { - adverr.Println(ErrCurlRequestFailed.Wrap(err, url)) - } - }() + defer curl.Wait() r, err := gzip.NewReader(stdout) if err != nil { @@ -63,23 +50,11 @@ func (api *Api) Get(ctx context.Context, url string) (*goquery.Document, error) if err != nil { return nil, ErrCurlRequestFailed.Wrap(err, url) } - defer stdout.Close() - - stderr, err := curl.StderrPipe() - if err != nil { - return nil, ErrCurlRequestFailed.Wrap(err, url) - } - defer stderr.Close() if err := curl.Start(); err != nil { return nil, ErrCurlRequestFailed.Wrap(err, url) } - - go func() { - if err := curl.Wait(); err != nil { - adverr.Println(ErrCurlRequestFailed.Wrap(err, url)) - } - }() + defer curl.Wait() r, err := gzip.NewReader(stdout) if err != nil {