ptrpkg

package
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

README

ptr

基础类型取指针、指针取值和泛型指针辅助。

基础用法

namePtr := ptrpkg.Ptr("alice")
name := ptrpkg.Value(namePtr)

注意事项

区分零值和 nil 的业务含义,尤其是 PATCH/部分更新 DTO。

验证

go test ./ptr

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool deprecated

func Bool(a bool) *bool

Deprecated: 使用 Ptr[bool] 替代

func BoolSlice deprecated

func BoolSlice(a []bool) []*bool

Deprecated: 使用 Slice[bool] 替代

func BoolSliceValue deprecated

func BoolSliceValue(a []*bool) []bool

Deprecated: 使用 ValueSlice[bool] 替代

func BoolValue deprecated

func BoolValue(a *bool) bool

Deprecated: 使用 Value[bool] 替代

func Float32 deprecated

func Float32(a float32) *float32

Deprecated: 使用 Ptr[float32] 替代

func Float32Slice deprecated

func Float32Slice(a []float32) []*float32

Deprecated: 使用 Slice[float32] 替代

func Float32Value deprecated

func Float32Value(a *float32) float32

Deprecated: 使用 Value[float32] 替代

func Float32ValueSlice deprecated

func Float32ValueSlice(a []*float32) []float32

Deprecated: 使用 ValueSlice[float32] 替代

func Float64 deprecated

func Float64(a float64) *float64

Deprecated: 使用 Ptr[float64] 替代

func Float64Slice deprecated

func Float64Slice(a []float64) []*float64

Deprecated: 使用 Slice[float64] 替代

func Float64Value deprecated

func Float64Value(a *float64) float64

Deprecated: 使用 Value[float64] 替代

func Float64ValueSlice deprecated

func Float64ValueSlice(a []*float64) []float64

Deprecated: 使用 ValueSlice[float64] 替代

func Int deprecated

func Int(a int) *int

Deprecated: 使用 Ptr[int] 替代

func Int8 deprecated

func Int8(a int8) *int8

Deprecated: 使用 Ptr[int8] 替代

func Int8Slice deprecated

func Int8Slice(a []int8) []*int8

Deprecated: 使用 Slice[int8] 替代

func Int8Value deprecated

func Int8Value(a *int8) int8

Deprecated: 使用 Value[int8] 替代

func Int8ValueSlice deprecated

func Int8ValueSlice(a []*int8) []int8

Deprecated: 使用 ValueSlice[int8] 替代

func Int16 deprecated

func Int16(a int16) *int16

Deprecated: 使用 Ptr[int16] 替代

func Int16Slice deprecated

func Int16Slice(a []int16) []*int16

Deprecated: 使用 Slice[int16] 替代

func Int16Value deprecated

func Int16Value(a *int16) int16

Deprecated: 使用 Value[int16] 替代

func Int16ValueSlice deprecated

func Int16ValueSlice(a []*int16) []int16

Deprecated: 使用 ValueSlice[int16] 替代

func Int32 deprecated

func Int32(a int32) *int32

Deprecated: 使用 Ptr[int32] 替代

func Int32Slice deprecated

func Int32Slice(a []int32) []*int32

Deprecated: 使用 Slice[int32] 替代

func Int32Value deprecated

func Int32Value(a *int32) int32

Deprecated: 使用 Value[int32] 替代

func Int32ValueSlice deprecated

func Int32ValueSlice(a []*int32) []int32

Deprecated: 使用 ValueSlice[int32] 替代

func Int64 deprecated

func Int64(a int64) *int64

Deprecated: 使用 Ptr[int64] 替代

func Int64Slice deprecated

func Int64Slice(a []int64) []*int64

Deprecated: 使用 Slice[int64] 替代

func Int64Value deprecated

func Int64Value(a *int64) int64

Deprecated: 使用 Value[int64] 替代

func Int64ValueSlice deprecated

func Int64ValueSlice(a []*int64) []int64

Deprecated: 使用 ValueSlice[int64] 替代

func IntSlice deprecated

func IntSlice(a []int) []*int

Deprecated: 使用 Slice[int] 替代

func IntValue deprecated

func IntValue(a *int) int

Deprecated: 使用 Value[int] 替代

func IntValueSlice deprecated

func IntValueSlice(a []*int) []int

Deprecated: 使用 ValueSlice[int] 替代

func Ptr

func Ptr[T any](v T) *T

Ptr 将任意类型的值转换为指针

func Slice

func Slice[T any](a []T) []*T

Slice 将值切片转换为指针切片

func String deprecated

func String(a string) *string

Deprecated: 使用 Ptr[string] 替代

func StringSlice deprecated

func StringSlice(a []string) []*string

Deprecated: 使用 Slice[string] 替代

func StringSliceValue deprecated

func StringSliceValue(a []*string) []string

Deprecated: 使用 ValueSlice[string] 替代

func StringValue deprecated

func StringValue(a *string) string

Deprecated: 使用 Value[string] 替代

func Uint deprecated

func Uint(a uint) *uint

Deprecated: 使用 Ptr[uint] 替代

func Uint8 deprecated

func Uint8(a uint8) *uint8

Deprecated: 使用 Ptr[uint8] 替代

func Uint8Slice deprecated

func Uint8Slice(a []uint8) []*uint8

Deprecated: 使用 Slice[uint8] 替代

func Uint8Value deprecated

func Uint8Value(a *uint8) uint8

Deprecated: 使用 Value[uint8] 替代

func Uint8ValueSlice deprecated

func Uint8ValueSlice(a []*uint8) []uint8

Deprecated: 使用 ValueSlice[uint8] 替代

func Uint16 deprecated

func Uint16(a uint16) *uint16

Deprecated: 使用 Ptr[uint16] 替代

func Uint16Slice deprecated

func Uint16Slice(a []uint16) []*uint16

Deprecated: 使用 Slice[uint16] 替代

func Uint16Value deprecated

func Uint16Value(a *uint16) uint16

Deprecated: 使用 Value[uint16] 替代

func Uint16ValueSlice deprecated

func Uint16ValueSlice(a []*uint16) []uint16

Deprecated: 使用 ValueSlice[uint16] 替代

func Uint32 deprecated

func Uint32(a uint32) *uint32

Deprecated: 使用 Ptr[uint32] 替代

func Uint32Slice deprecated

func Uint32Slice(a []uint32) []*uint32

Deprecated: 使用 Slice[uint32] 替代

func Uint32Value deprecated

func Uint32Value(a *uint32) uint32

Deprecated: 使用 Value[uint32] 替代

func Uint32ValueSlice deprecated

func Uint32ValueSlice(a []*uint32) []uint32

Deprecated: 使用 ValueSlice[uint32] 替代

func Uint64 deprecated

func Uint64(a uint64) *uint64

Deprecated: 使用 Ptr[uint64] 替代

func Uint64Slice deprecated

func Uint64Slice(a []uint64) []*uint64

Deprecated: 使用 Slice[uint64] 替代

func Uint64Value deprecated

func Uint64Value(a *uint64) uint64

Deprecated: 使用 Value[uint64] 替代

func Uint64ValueSlice deprecated

func Uint64ValueSlice(a []*uint64) []uint64

Deprecated: 使用 ValueSlice[uint64] 替代

func UintSlice deprecated

func UintSlice(a []uint) []*uint

Deprecated: 使用 Slice[uint] 替代

func UintValue deprecated

func UintValue(a *uint) uint

Deprecated: 使用 Value[uint] 替代

func UintValueSlice deprecated

func UintValueSlice(a []*uint) []uint

Deprecated: 使用 ValueSlice[uint] 替代

func Value

func Value[T comparable](p *T) T

Value 将指针转换为值,nil 指针返回零值

func ValueSlice

func ValueSlice[T any](a []*T) []T

ValueSlice 将指针切片转换为值切片

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL