richardlehane / siegfried

signature-based file format identification
http://www.itforarchivists.com/siegfried
Apache License 2.0
217 stars 30 forks source link

Add JS/WASM platform mmap no-op implementation. #188

Closed anjackson closed 2 years ago

anjackson commented 2 years ago

This add an no-op implementation of mmap for the js platform. With this in place, Siegfried compiles under:

GOOS=js GOARCH=wasm go build -o main.wasm

NOTE THAT THIS HAS NOT YET BEEN TESTED!

Now tested and seems to work well, see https://github.com/ukwa/siegfried-js#readme

anjackson commented 2 years ago

Okay, so hacking our the dependency on user.Current (f84deffe28f45472c62434c3eb682dc516fd8e29) needs to be done with more care.

But, other than that, with these changes, I managed to successfully run a Siegfried identification process in the browser via WebAssembly. See https://github.com/ukwa/siegfried-js#readme

richardlehane commented 2 years ago

look forward to trying this out, thanks Andy!

anjackson commented 2 years ago

Thanks Richard. I just realised I could extend the existing conditional build settings for config/default.go rather than modifying the behaviour of the sf tool, so that should be an improvement.