Space Cat, Prince Among Thieves

Read Browser File Inputs with Go WebAssembly

I have been playing with WebAssembly since Go added support for it in 2017.

For a very long time now, I've been wanting to be able to accept files from an end user and process them with Go on their local machine. Basically I just want to read files from file inputs. I knew it had to be possible, but could not in all this time find a good walkthrough online. A couple nights ago I set my mind to it and figured it out.

Essentially we need to execute the following JavaScript, but in Go via the JS syscall API.

So after transliterating that JavaScript into Go syscall/js calls, we then using js.CopyBytesToGo to pass the given Uint8Array back to our WASM runtime where we can do with the bytes as we please.

Note, given the keyword any here, this example requires Go 1.18 - the syscall/js library is still considered experimental and expect it to break on major go releases.

This is as written for brevity and could be improved in code safety in a number of pretty obvious ways.

The iframe below runs the compiled WASM and spits out any file you upload to it, via Go.


Read More / Comment »

Use a GIF as a Zoom Virtual Background

Update August 17 2021: I've got the tool working in Chrome and Firefox by launching it a standalone new window instead of loading in an iframe. It is still broken in Safari for unknown reasons. It's not ideal, but until the whole SharedArrayBuffer debacle settles down, it's probably the best I can …

Read More / Comment »

Recent Comments

I like pixel art very much. Thank you

Great tool, though is there a way to generate lines to slice the circle into multiple equal segments, like if i'm making a sliced pizza art?

nice tool, used it many times, very good 11/10

The way I use this site is I generate a thin circle and I look at the blocks at the edge. By going along the circle, I count for every line how many squares ar…

It would be great if you could unmark blocks. Otherwise great improvements!