Require quotes or 0x<hex> for string args

This commit is contained in:
Matt Bell
2017-01-02 18:28:47 -08:00
parent ab211d2dbe
commit 115e6939d0
+8
View File
@@ -285,5 +285,13 @@ func stringOrHexToBytes(s string) []byte {
}
return b
}
if !strings.HasPrefix(s, "\"") || !strings.HasSuffix(s, "\"") {
fmt.Printf("Invalid string arg: \"%s\". Must be quoted or a \"0x\"-prefixed hex string\n", s)
return []byte{}
}
// TODO: return errors
return []byte(s)
}