I created several compound structures to return via the dbus.
type GetFileResponse struct {
Response
File
}
type Response struct {
Status int32
Message string
}
type File struct {
Fileid int64
Path string
Name string
HashSimple string
HashSHA1 string
HashMD5 string
Filecreationdate int64
Filemodificationdate int64
Creationdate int64
Modificationdate int64
Size int64
Isdir bool
Deleted bool
Metadata []byte
}
I created it this way for readability and it seemed like it should work based on the documentation, however I found an interesting bug. It seems that when dealing with a compound struct such as GetFileResponse, if a sub-struct has an array in it then go panics with the following stack trace:
I dug into the reflect package trying to find why this was happening, because it seems to only be in this very complex implementation that it happens, but I was unable to come up with a reason. I figured I would post here to see if anyone else found this issue and could shed some light on it.
I am working around it using simpler structs and more return values, but the readability of this method was pretty fantastic and I would prefer to use it if this issue can be easily corrected.
In the meanwhile, if I happen to figure out what's causing it then I'll submit a PR.
Thanks!
I created several compound structures to return via the dbus.
I created it this way for readability and it seemed like it should work based on the documentation, however I found an interesting bug. It seems that when dealing with a compound
struct
such asGetFileResponse
, if a sub-struct has an array in it then go panics with the following stack trace:I dug into the reflect package trying to find why this was happening, because it seems to only be in this very complex implementation that it happens, but I was unable to come up with a reason. I figured I would post here to see if anyone else found this issue and could shed some light on it. I am working around it using simpler structs and more return values, but the readability of this method was pretty fantastic and I would prefer to use it if this issue can be easily corrected.
In the meanwhile, if I happen to figure out what's causing it then I'll submit a PR. Thanks!