Skip to content

Fix for slices version incompatibilities #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions nosqldb/internal/proto/binary/struct_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ func (sr *StructReader) DiscardMap() error {
}
for i := 0; i < size; i++ {
// field name
key, err := sr.reader.ReadString()
_, err := sr.reader.ReadString()
if err != nil {
return err
}
fmt.Fprintf(os.Stdout, "Disacrding field '%s'\n", *key)
//fmt.Fprintf(os.Stdout, "Discarding field '%s'\n", *key)
err = sr.ReadFieldValue(reflect.Value{})
if err != nil {
return err
Expand Down Expand Up @@ -121,7 +121,7 @@ func (sr *StructReader) ReadMap(v reflect.Value) error {
if err != nil {
return err
}
fmt.Fprintf(os.Stdout, "Handling field '%s'\n", *key)
//fmt.Fprintf(os.Stdout, "Handling field '%s'\n", *key)

// Figure out field corresponding to key.
var subv reflect.Value
Expand Down
5 changes: 2 additions & 3 deletions nosqldb/internal/proto/binary/struct_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"encoding/binary"
"fmt"
"reflect"
"slices"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -524,8 +523,8 @@ func (me mapEncoder) encode(e *encodeState, v reflect.Value, opts encOpts) {
}
sv[i].v = mi.Value()
}
slices.SortFunc(sv, func(i, j reflectWithString) int {
return strings.Compare(i.ks, j.ks)
sort.Slice(sv, func(i, j int) bool {
return sv[i].ks < sv[j].ks
})

if _, err := e.writeOneByte(byte(types.Map)); err != nil {
Expand Down