From 79c87ffa99809bf7651a03183552ed0adadcccfa Mon Sep 17 00:00:00 2001 From: mewmew Date: Sat, 14 Jul 2018 09:46:57 +0000 Subject: [PATCH] struc: support Custom slice types Useful for implementing e.g. NULL-terminated slices whose length is unknown and cannot be determined by a field in the struct. --- parse.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parse.go b/parse.go index 43c5875..158b62f 100644 --- a/parse.go +++ b/parse.go @@ -161,7 +161,7 @@ func parseFieldsLocked(v reflect.Value) (Fields, error) { } f.Sizefrom = source.Index } - if f.Len == -1 && f.Sizefrom == nil { + if f.Len == -1 && f.Sizefrom == nil && f.Type != CustomType { return nil, fmt.Errorf("struc: field `%s` is a slice with no length or sizeof field", field.Name) } // recurse into nested structs