concat
Concatenates multiple byte slices or hex strings
Loading...
Concatenates multiple byte slices or hex strings
Concatenates multiple byte slices or hex strings into a single value.
import "github.com/ChefBingbong/viem-go/utils/data"import "github.com/ChefBingbong/viem-go/utils/data"
// Concatenate byte slicesresult := data.Concat([]byte{0x01}, []byte{0x02}, []byte{0x03})// []byte{0x01, 0x02, 0x03}
// Concatenate hex stringshexResult := data.ConcatHex("0x01", "0x02", "0x03")// "0x010203"[]byte for Concat/ConcatBytes, string for ConcatHexThe concatenated value. For byte slices, returns []byte. For hex strings, returns a hex string with 0x prefix.
...[]byte for Concat/ConcatBytes, ...string for ConcatHexOne or more byte slices or hex strings to concatenate.
// Concatenate multiple byte slicesresult := data.ConcatBytes( []byte{0x01, 0x02}, []byte{0x03, 0x04}, []byte{0x05},)// []byte{0x01, 0x02, 0x03, 0x04, 0x05}
// Concatenate multiple hex stringshexResult := data.ConcatHex( "0x0102", "0x0304", "0x05",)// "0x0102030405"Generic function that automatically detects the type based on the first element. For byte slices, use ConcatBytes explicitly.
Concatenates multiple byte slices into one.
Concatenates multiple hex strings into one. All inputs should have 0x prefix.