MCPcopy Create free account
hub / github.com/AlekSi/pointer / ToStringOrNil

Function ToStringOrNil

pointer_or_nil.go:120–125  ·  view source on GitHub ↗

ToStringOrNil returns a pointer to the passed string value, or nil, if passed value is a zero value.

(s string)

Source from the content-addressed store, hash-verified

118
119// ToStringOrNil returns a pointer to the passed string value, or nil, if passed value is a zero value.
120func ToStringOrNil(s string) *string {
121 if s == "" {
122 return nil
123 }
124 return &s
125}
126
127// ToUintOrNil returns a pointer to the passed uint value, or nil, if passed value is a zero value.
128func ToUintOrNil(u uint) *uint {

Callers 1

TestStringFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestStringFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…