diff --git a/collections/genesis.go b/collections/genesis.go index 454ba496e1..0c593e4adf 100644 --- a/collections/genesis.go +++ b/collections/genesis.go @@ -32,7 +32,7 @@ func (m Map[K, V]) importGenesis(ctx context.Context, reader io.Reader) error { } func (m Map[K, V]) exportGenesis(ctx context.Context, writer io.Writer) error { - _, err := writer.Write([]byte("[")) + _, err := io.WriteString(writer, "[") if err != nil { return err } @@ -48,7 +48,7 @@ func (m Map[K, V]) exportGenesis(ctx context.Context, writer io.Writer) error { // add a comma before encoding the object // for all objects besides the first one. if !first { - _, err = writer.Write([]byte(",")) + _, err = io.WriteString(writer, ",") if err != nil { return err } @@ -91,7 +91,7 @@ func (m Map[K, V]) exportGenesis(ctx context.Context, writer io.Writer) error { } } - _, err = writer.Write([]byte("]")) + _, err = io.WriteString(writer, "]") return err } @@ -148,6 +148,6 @@ func (m Map[K, V]) doDecodeJSON(reader io.Reader, onEntry func(key K, value V) e } func (m Map[K, V]) defaultGenesis(writer io.Writer) error { - _, err := writer.Write([]byte(`[]`)) + _, err := io.WriteString(writer, `[]`) return err } diff --git a/orm/encoding/ormfield/string.go b/orm/encoding/ormfield/string.go index e052efab31..6139277f12 100644 --- a/orm/encoding/ormfield/string.go +++ b/orm/encoding/ormfield/string.go @@ -87,7 +87,7 @@ func (s NonTerminalStringCodec) Encode(value protoreflect.Value, w io.Writer) er return fmt.Errorf("illegal null terminator found in index string: %s", str) } } - _, err := w.Write([]byte(str)) + _, err := w.Write(bz) if err != nil { return err }