isBytes
Checks if a value is a byte slice
isBytes
Checks if a value is a byte slice ([]byte).
Import
import "github.com/ChefBingbong/viem-go/utils/data"
Usage
import "github.com/ChefBingbong/viem-go/utils/data"// Valid byte slicevalid := data.IsBytes([]byte{0x01, 0x02})// true// Not a byte slicevalid = data.IsBytes("0x0102")// false// Nil is not bytesvalid = data.IsBytes(nil)// false
Returns
- Type:
bool
true if the value is a byte slice, false otherwise.
Parameters
value (required)
- Type:
any
The value to check.
valid := data.IsBytes([]byte{0x01, 0x02})// truevalid = data.IsBytes("0x0102")// falsevalid = data.IsBytes(nil)// false
Notes
- In Go, this is primarily useful for type assertions in generic contexts
- Returns
falsefornilvalues - Only returns
truefor actual[]bytetypes, not other slice types