Skip to content

Instantly share code, notes, and snippets.

@campoy
Created April 12, 2018 18:55
Show Gist options
  • Save campoy/bea1e18a7b72a212bc0c5463bc2043d4 to your computer and use it in GitHub Desktop.
Save campoy/bea1e18a7b72a212bc0c5463bc2043d4 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"strings"
)
func main() {
bs, err := ioutil.ReadAll(os.Stdin)
if err != nil {
log.Fatal(err)
}
b := new(strings.Builder)
fmt.Fprint(b, bs[0])
for _, c := range bs[1:] {
fmt.Fprintf(b, ", %d", c)
}
fmt.Printf("const bytes = new Uint8Array([%s]);", b)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment