From 7961e3e8bc258a837b95d1dfc5b2d47130099195 Mon Sep 17 00:00:00 2001 From: demo Date: Sun, 10 May 2026 21:58:52 -0400 Subject: style: rename fetch to Fetch + add doc comment --- internal/fetch/fetch.go | 6 +++++- internal/fetch/fetch_test.go | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'internal/fetch') diff --git a/internal/fetch/fetch.go b/internal/fetch/fetch.go index f508922..f22139d 100644 --- a/internal/fetch/fetch.go +++ b/internal/fetch/fetch.go @@ -8,7 +8,11 @@ import ( "time" ) -func fetch(rawURL string, timeoutSecs int) (io.Reader, error) { +// Fetch makes a GET request to rawURL, returning the HTML contents of +// that webpage in the form of an [io.Reader]. An error is also +// returned. The parameter timeoutSecs is passed directly to the +// [http.Client.Timeout] field of the client making the request. +func Fetch(rawURL string, timeoutSecs int) (io.Reader, error) { client := http.Client{ Timeout: time.Duration(timeoutSecs) * time.Second, } diff --git a/internal/fetch/fetch_test.go b/internal/fetch/fetch_test.go index 427406d..227ba0d 100644 --- a/internal/fetch/fetch_test.go +++ b/internal/fetch/fetch_test.go @@ -3,7 +3,7 @@ package fetch import "testing" func TestFetch(t *testing.T) { - _, err := fetch("http://example.com", 2) + _, err := Fetch("http://example.com", 2) if err != nil { t.Error(err) } -- cgit v1.2.3