From accb30de20603e2d79a3a4d267772b7431fe38f3 Mon Sep 17 00:00:00 2001 From: 0x9ef <0x9ef@tutanota.com> Date: Thu, 30 Mar 2023 19:27:36 +0300 Subject: [PATCH] fix: add backward compatibility for Go 1.17 (#7) --- go.mod | 2 +- openai.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index dfcf28f..3f3ca90 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/0x9ef/openai-go -go 1.19 +go 1.17 require github.com/go-playground/validator/v10 v10.11.1 diff --git a/openai.go b/openai.go index 7d81b5b..89e7751 100644 --- a/openai.go +++ b/openai.go @@ -99,7 +99,7 @@ func (e *Engine) doReq(req *http.Request) (*http.Response, error) { return resp, apiErr } -func unmarshal(resp *http.Response, v any) error { +func unmarshal(resp *http.Response, v interface{}) error { defer resp.Body.Close() if err := json.NewDecoder(resp.Body).Decode(&v); err != nil { return err @@ -107,7 +107,7 @@ func unmarshal(resp *http.Response, v any) error { return nil } -func marshalJson(body any) (io.Reader, error) { +func marshalJson(body interface{}) (io.Reader, error) { b, err := json.Marshal(body) if err != nil { return nil, err