1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-04 12:52:28 +08:00

doc: add go playground demo

This commit is contained in:
dudaodong
2023-06-20 14:04:18 +08:00
parent 3050d93703
commit 8f49078eb3
12 changed files with 63 additions and 21 deletions

View File

@@ -7,19 +7,19 @@ package pointer
import "reflect"
// Of returns a pointer to the value `v`.
// Play: todo
// Play: https://go.dev/play/p/HFd70x4DrMj
func Of[T any](v T) *T {
return &v
}
// Unwrap returns the value from the pointer.
// Play: todo
// Play: https://go.dev/play/p/cgeu3g7cjWb
func Unwrap[T any](p *T) T {
return *p
}
// ExtractPointer returns the underlying value by the given interface type
// Play: todo
// Play: https://go.dev/play/p/D7HFjeWU2ZP
func ExtractPointer(value any) any {
t := reflect.TypeOf(value)
v := reflect.ValueOf(value)