Skip to content

Commit e145dbb

Browse files
committed
adding BytesToStringValue
1 parent a42bb0d commit e145dbb

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

conv/values.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,15 @@ func StringToStringValue(s string) types.String {
566566
return types.String{Value: s}
567567
}
568568

569+
// BytesToStringValue takes a byte slice and wraps it as a types.String. If the provided slice is `nil`, then the
570+
// resulting String type will be marked as "null".
571+
func BytesToStringValue(b []byte) types.String {
572+
if b == nil {
573+
return types.String{Null: true}
574+
}
575+
return StringToStringValue(string(b))
576+
}
577+
569578
// StringPtrToStringValue takes a *string and wraps it up as a types.String
570579
// If the go value is nil, Null will be true on the outgoing attr.Value type
571580
func StringPtrToStringValue(s *string) types.String {

0 commit comments

Comments
 (0)