diff --git a/autorest/to/convert.go b/autorest/to/convert.go index fdda2ce1a..86694bd25 100644 --- a/autorest/to/convert.go +++ b/autorest/to/convert.go @@ -145,3 +145,8 @@ func Float64(i *float64) float64 { func Float64Ptr(i float64) *float64 { return &i } + +// ByteSlicePtr returns a pointer to the passed byte slice. +func ByteSlicePtr(b []byte) *[]byte { + return &b +} diff --git a/autorest/to/convert_test.go b/autorest/to/convert_test.go index f8177a163..b7b85ed33 100644 --- a/autorest/to/convert_test.go +++ b/autorest/to/convert_test.go @@ -232,3 +232,11 @@ func TestFloat64Ptr(t *testing.T) { v, *Float64Ptr(v)) } } + +func TestByteSlicePtr(t *testing.T) { + v := []byte("bytes") + if out := ByteSlicePtr(v); !reflect.DeepEqual(*out, v) { + t.Fatalf("to: ByteSlicePtr failed to return the correct slice -- expected %v, received %v", + v, *out) + } +}