Skip to content

Commit 3f75f81

Browse files
authored
Add Pointer function to package text (#23)
* adds Pointer fn
1 parent 9ca1e4e commit 3f75f81

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

text/text.go

+5
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,11 @@ func (t Text) ToValidUTF8(replacement Text) Text {
521521
return Text(strings.ToValidUTF8(t.String(), replacement.String()))
522522
}
523523

524+
// Pointer returns a pointer to t.
525+
func Pointer(t Text) *Text {
526+
return &t
527+
}
528+
524529
func collect(slice []string) Texts {
525530
res := make([]Text, len(slice))
526531
for i, v := range slice {

text/text_test.go

+7
Original file line numberDiff line numberDiff line change
@@ -1454,3 +1454,10 @@ func TestText_ToValidUTF8(t *testing.T) {
14541454
})
14551455
}
14561456
}
1457+
1458+
func TestPointer(t *testing.T) {
1459+
x := Text("abc")
1460+
if Pointer(x).String() != x.String() {
1461+
t.Error("Pointer failed")
1462+
}
1463+
}

0 commit comments

Comments
 (0)