go-yara
go-yara copied to clipboard
There's no way to return an error from MemoryBlockIterator
In C, a YR_MEMORY_BLOCK_ITERATOR
can set last_error
from its iteration functions in order to return an error, but this doesn't seem to be accessible from go.
Guilty as charged. ;-) I think this was added to YARA for 4.1.0, after I had done the iterator code. Just like file_size
.
I have added another interface, MemoryBlockIterator
in the iterator-last-error branch. Would you like to have a look if this works for you – and maybe contribute a test case for this? Thanks!
thanks for responding! What you've got would work, but I think returning an error directly from First()
and Next()
would be more go-like and easier to use. What do you think?
Making First, Next return an error would break the API. Perhaps for version 5.0.
doesn't adding a new method to the interface also break the API?
doesn't adding a new method to the interface also break the API?
No. For code using go-yara, implementing the extra interface is optional.
Even though this is not the most (Golang-)idiomatic way to signal an error, I can't think of a better alternative. Would you like to contirbute a test case?