summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordemo <demo@antix1>2026-05-10 21:58:52 -0400
committerdemo <demo@antix1>2026-05-10 21:58:52 -0400
commit7961e3e8bc258a837b95d1dfc5b2d47130099195 (patch)
treea9cfcb70c596412523baaa19ec165ac63b4298c7
parent916e778dfccc2aa5ce95056b97e11f134bc941f7 (diff)
style: rename fetch to Fetch + add doc comment
-rw-r--r--internal/fetch/fetch.go6
-rw-r--r--internal/fetch/fetch_test.go2
2 files changed, 6 insertions, 2 deletions
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)
}