Skip to content

Commit

Permalink
chore: support (u)int(8|16) fields ans slices, fix map issues,
Browse files Browse the repository at this point in the history
This commit does several things:
- Adds support for (u)int(8|16) fields and slices. Any such type (except for []uint8 and [n]uint8) will be encoded as protobuf fixed32
- Refactor unmarshal.go
- Disallow encoding of maps with complex keys
- Disallow encoding of maps with repeated values
- Check pointer to slices in slices elements
- Support empty structs
- Arrays of complex types cannot be decoded for now
- Other small fixes

Signed-off-by: Dmitriy Matrenichev <dmitry.matrenichev@siderolabs.com>
  • Loading branch information
DmitriyMV committed Aug 9, 2022
1 parent d618d0d commit bf5e39b
Show file tree
Hide file tree
Showing 17 changed files with 1,307 additions and 735 deletions.
5 changes: 3 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2022-08-04T13:22:07Z by kres latest.
# Generated on 2022-08-09T01:20:13Z by kres latest.

**
!messages
!array_test.go
!benchmarks_test.go
!example_test.go
!field_test.go
Expand All @@ -17,6 +16,8 @@
!person_test.go
!predefined_types.go
!protobuf_test.go
!scanner.go
!slice_test.go
!type_cache.go
!unmarshal.go
!unmarshal_fastpath.go
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2022-08-04T13:22:07Z by kres latest.
# Generated on 2022-08-09T01:20:13Z by kres latest.

ARG TOOLCHAIN

Expand Down Expand Up @@ -49,7 +49,6 @@ COPY ./go.sum .
RUN --mount=type=cache,target=/go/pkg go mod download
RUN --mount=type=cache,target=/go/pkg go mod verify
COPY ./messages ./messages
COPY ./array_test.go ./array_test.go
COPY ./benchmarks_test.go ./benchmarks_test.go
COPY ./example_test.go ./example_test.go
COPY ./field_test.go ./field_test.go
Expand All @@ -62,6 +61,8 @@ COPY ./marshal_test.go ./marshal_test.go
COPY ./person_test.go ./person_test.go
COPY ./predefined_types.go ./predefined_types.go
COPY ./protobuf_test.go ./protobuf_test.go
COPY ./scanner.go ./scanner.go
COPY ./slice_test.go ./slice_test.go
COPY ./type_cache.go ./type_cache.go
COPY ./unmarshal.go ./unmarshal.go
COPY ./unmarshal_fastpath.go ./unmarshal_fastpath.go
Expand Down
316 changes: 0 additions & 316 deletions array_test.go

This file was deleted.

4 changes: 2 additions & 2 deletions field_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/siderolabs/protoenc"
)

func TestEncodeNested(t *testing.T) {
func TestStructFields_EmbedStruct(t *testing.T) {
t.Parallel()

s := &StructWithEmbed{
Expand Down Expand Up @@ -65,7 +65,7 @@ type EmbedStruct struct {
C int32 `protobuf:"11"`
}

func TestDuplicateIDNotAllowed(t *testing.T) {
func TestStructFields_DuplicateIDNotAllowed(t *testing.T) {
t.Parallel()

v := reflect.TypeOf(&StructWithDuplicates{})
Expand Down
Loading

0 comments on commit bf5e39b

Please sign in to comment.