mirror of
https://github.com/rjNemo/underscore
synced 2026-06-06 10:36:43 +00:00
22 lines
296 B
Go
22 lines
296 B
Go
package underscore
|
|
|
|
// Convert values to pointers
|
|
//
|
|
// Instead of:
|
|
// v := "value"
|
|
// MyPointerVar = &v
|
|
//
|
|
// Or
|
|
// v1 := "value1"
|
|
// v2 := 100
|
|
//
|
|
// obj := Obj{
|
|
// Field1: &v,
|
|
// Field2: &v2,
|
|
// }
|
|
//
|
|
// Use:
|
|
// MyPointerVar = ToPointer("value")
|
|
func ToPointer[T any](in T) *T {
|
|
return &in
|
|
}
|