Skip to content
Advertisement

How to read file from disk and pass it to WebAssembly using Go?

Specifically, how to connect <input type="file"> with this function in Go? I know there is “syscall/js” package, but I didn’t find any examples with file reading.

JavaScript

Advertisement

Answer

I’ve wanted a satisfactory answer for this for years, finally figured it out the other night.

You can essentially boil the whole thing down to:

JavaScript

I wrote a little blog post about it here with the working WASM code running at the bottom

https://donatstudios.com/Read-User-Files-With-Go-WASM

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement