move marshaller and unmarshaler into internal pkg (#304) (#325)

This commit is contained in:
渡邉祐一 / Yuichi Watanabe
2023-05-28 10:51:07 +09:00
committed by GitHub
parent 980504b47e
commit 62eb4beed2
12 changed files with 57 additions and 46 deletions

15
internal/marshaller.go Normal file
View File

@@ -0,0 +1,15 @@
package openai
import (
"encoding/json"
)
type Marshaller interface {
Marshal(value any) ([]byte, error)
}
type JSONMarshaller struct{}
func (jm *JSONMarshaller) Marshal(value any) ([]byte, error) {
return json.Marshal(value)
}

15
internal/unmarshaler.go Normal file
View File

@@ -0,0 +1,15 @@
package openai
import (
"encoding/json"
)
type Unmarshaler interface {
Unmarshal(data []byte, v any) error
}
type JSONUnmarshaler struct{}
func (jm *JSONUnmarshaler) Unmarshal(data []byte, v any) error {
return json.Unmarshal(data, v)
}