~adnano/go-gemini-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
4 2

[PATCH] Only use fs.go when fs.FS is available

Details
Message ID
<20210224075223.174802-1-belak@coded.io>
DKIM signature
pass
Download raw message
Patch: +6 -3
---
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.15

require 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
Details
Message ID
<C9HRPWMQVGGE.3GZR4Y47HGBON@nitro>
In-Reply-To
<20210224075223.174802-1-belak@coded.io> (view parent)
DKIM signature
pass
Download raw message
Thanks!

To git.sr.ht:~adnano/go-gemini
   3660698..2c2d74b  master -> master
Details
Message ID
<C9HVXJWJCT5U.2T5GRR1VE77RY@nitro>
In-Reply-To
<C9HRPWMQVGGE.3GZR4Y47HGBON@nitro> (view parent)
DKIM signature
pass
Download raw message
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.
Details
Message ID
<355b1ffc-f81a-4b00-ab7d-9dc8e1810e73@www.fastmail.com>
In-Reply-To
<C9HVXJWJCT5U.2T5GRR1VE77RY@nitro> (view parent)
DKIM signature
pass
Download raw message
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.

On Wed, Feb 24, 2021, at 8:01 AM, Adnan Maolood wrote:
> 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.
Details
Message ID
<C9I0DAWDY63X.2LDZ8W9EOU4LG@nitro>
In-Reply-To
<355b1ffc-f81a-4b00-ab7d-9dc8e1810e73@www.fastmail.com> (view parent)
DKIM signature
pass
Download raw message
On Wed Feb 24, 2021 at 12:58 PM EST, Kaleb Elwert wrote:
> 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
Reply to thread Export thread (mbox)