diff options
Diffstat (limited to 'internal/files/bin')
-rw-r--r-- | internal/files/bin/bin.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/internal/files/bin/bin.go b/internal/files/bin/bin.go new file mode 100644 index 0000000..5b56313 --- /dev/null +++ b/internal/files/bin/bin.go @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "io/ioutil" + "os" +) + +func main() { + var buf []byte + var pos int + var b byte + var err error + buf, err = ioutil.ReadAll(os.Stdin) + if err == nil { + for _, b = range buf { + fmt.Printf("0x%02X, ", b) + pos++ + if pos >= 16 { + fmt.Println("") + pos = 0 + } + } + } + if err != nil { + fmt.Fprintf(os.Stderr, "%s\n", err) + } +} |