mmcdole / gofeed

Parse RSS, Atom and JSON feeds in Go
MIT License
2.51k stars 204 forks source link

Use `http.NewRequestWithContext` directly. #185

Closed Necoro closed 2 years ago

Necoro commented 2 years ago

Directly set the context instead of (implicitly) setting context.Background and then do a copy with the intended context.

Rationale: The implementation of http.NewRequest

func NewRequest(method, url string, body io.Reader) (*Request, error) {
    return NewRequestWithContext(context.Background(), method, url, body)
}