Migrate to Go 1.18 (#45)

* Migrate to Go 1.18 and add linters
This commit is contained in:
Jonas Plum
2022-03-20 03:17:18 +01:00
committed by GitHub
parent 03a4806d45
commit 2bad1f5f28
88 changed files with 1430 additions and 868 deletions

View File

@@ -2,18 +2,18 @@ package busdb
import "encoding/json"
type Keyed struct {
type Keyed[T any] struct {
Key string
Doc interface{}
Doc *T
}
func (p Keyed) MarshalJSON() ([]byte, error) {
func (p *Keyed[T]) MarshalJSON() ([]byte, error) {
b, err := json.Marshal(p.Doc)
if err != nil {
panic(err)
}
var m map[string]interface{}
var m map[string]any
err = json.Unmarshal(b, &m)
if err != nil {
panic(err)