Commit Graph

2 Commits

Author SHA1 Message Date
josephinedotlee
78a3b8ec6c Implement String method for pointers (#122)
* Implement String method for pointers

By implementing this method ourselves using atomic
loading and fmt.Sprint, we can avoid possible unguarded
accesses to the embedded pointer if someone attempts to
fmt.Print the atomic.Pointer
.

* Use Pointer.Load, not wrapped.Load

Co-authored-by: Abhinav Gupta <abg@uber.com>
2022-09-20 15:23:16 -07:00
Abhinav Gupta
2ab21d86f6 Add Pointer[T] (#116)
Adds a Pointer[T] type that provide the same functionality as
Go 1.19's `sync/atomic.Pointer[T]` in both, Go 1.18 and 1.19.

In Go 1.19, this uses the standard library's implementation,
and in 1.18 our own custom implementation based on UnsafePointer.
For Go 1.17, even though it's now unsupported, this is a no-op.

Refs GO-1572
Resolves #115
2022-08-09 16:56:14 -07:00