I decided to undo this change because the documentation for ServeFile
and FileSystem no longer shows up on godocs.io, and because with this
change the Gemini mime types will not be registered on Go 1.15.
Oof, that's unfortunate. I wonder if godocs.io is running on Go 1.15. The
mime registration could always be moved to another file if you want to
keep the bulk of this patch.
In any sense, this isn't a huge deal for me (it's pretty easy to install Go
1.16 directly) , but I thought it would be nice for people on Go 1.15 and below.
Alright, I've dropped the Go 1.16 requirement. I've moved the mime
registration to another file. Those who need to support Go 1.15 can do:
go get git.sr.ht/~adnano/go-gemini@cbfbeb6c2223
---
This patch isn't strictly necessary, but it addresses some of the feedback in
the thread about v0.1.15. It makes the tests run again on Go 1.15 and only
enables ServeFile (and FileServer) when fs.FS is available (Go 1.16 and above).
This will allow people who want to keep using the core of the library with Go
1.15 and below to do that while using the cleaner fs.FS for the actual
FileSystem implementation.
fs.go | 2 ++go.mod | 2 +-response_test.go | 5 +++--
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/fs.go b/fs.go
index 4ef515c..a3e7f96 100644
--- a/fs.go+++ b/fs.go
@@ -1,3 +1,5 @@
+//+build 1.16+package gemini
import (
diff --git a/go.mod b/go.mod
index 3b7df0a..2eb6847 100644
--- a/go.mod+++ b/go.mod
@@ -1,5 +1,5 @@
module git.sr.ht/~adnano/go-gemini
-go 1.16+go 1.15require golang.org/x/net v0.0.0-20210119194325-5f4716e94777
diff --git a/response_test.go b/response_test.go
index a63ea5e..c27efc0 100644
--- a/response_test.go+++ b/response_test.go
@@ -2,6 +2,7 @@ package gemini
import (
"io"
+ "io/ioutil" "strings"
"testing"
)
@@ -82,7 +83,7 @@ func TestReadWriteResponse(t *testing.T) {
for _, test := range tests {
t.Logf("%#v", test.Raw)
- resp, err := ReadResponse(io.NopCloser(strings.NewReader(test.Raw)))+ resp, err := ReadResponse(ioutil.NopCloser(strings.NewReader(test.Raw))) if err != test.Err {
t.Errorf("expected err = %v, got %v", test.Err, err)
}
@@ -96,7 +97,7 @@ func TestReadWriteResponse(t *testing.T) {
if resp.Meta != test.Meta {
t.Errorf("expected meta = %s, got %s", test.Meta, resp.Meta)
}
- b, _ := io.ReadAll(resp.body)+ b, _ := ioutil.ReadAll(resp.body) body := string(b)
if body != test.Body {
t.Errorf("expected body = %#v, got %#v", test.Body, body)
--
2.30.1