Skip to content

Commit

Permalink
deprecate legacy pointer functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jackofallops committed Sep 13, 2024
1 parent 3a3acb3 commit 5a6fec6
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions utils/bool.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package utils

// NormaliseNilableBool takes a pointer to a bool and returns a zero value or
// the real value if present
// Deprecated: please use the `From` function in the `pointer` package
func NormaliseNilableBool(input *bool) bool {
if input == nil {
return false
Expand Down
2 changes: 2 additions & 0 deletions utils/float.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package utils

// NormalizeNilableFloat normalizes a nilable float64 into a float64 value
// Deprecated: please use the `From` function in the `pointer` package
func NormalizeNilableFloat(input *float64) float64 {
if input == nil {
return 0
Expand All @@ -13,6 +14,7 @@ func NormalizeNilableFloat(input *float64) float64 {
}

// NormalizeNilableFloat32 normalizes a nilable float32 into a float32 value
// Deprecated: please use the `From` function in the `pointer` package
func NormalizeNilableFloat32(input *float32) float32 {
if input == nil {
return 0
Expand Down
3 changes: 3 additions & 0 deletions utils/int.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package utils

// NormaliseNilableInt takes a pointer to an int and returns a zero value or
// the real value if present
// Deprecated: please use the `From` function in the `pointer` package
func NormaliseNilableInt(input *int) int {
if input == nil {
return 0
Expand All @@ -15,6 +16,7 @@ func NormaliseNilableInt(input *int) int {

// NormaliseNilableInt32 takes a pointer to an int32 and returns a zero value or
// the real value if present
// Deprecated: please use the `From` function in the `pointer` package
func NormaliseNilableInt32(input *int32) int32 {
if input == nil {
return 0
Expand All @@ -25,6 +27,7 @@ func NormaliseNilableInt32(input *int32) int32 {

// NormaliseNilableInt64 takes a pointer to an int64 and returns a zero value or
// the real value if present
// Deprecated: please use the `From` function in the `pointer` package
func NormaliseNilableInt64(input *int64) int64 {
if input == nil {
return 0
Expand Down
12 changes: 12 additions & 0 deletions utils/pointer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,38 @@

package utils

// Bool
// Deprecated: please use the `To` function in the `pointer` package
func Bool(input bool) *bool {
return &input
}

// Int32
// Deprecated: please use the `To` function in the `pointer` package
func Int32(input int32) *int32 {
return &input
}

// Int64
// Deprecated: please use the `To` function in the `pointer` package
func Int64(input int64) *int64 {
return &input
}

// Float
// Deprecated: please use the `To` function in the `pointer` package
func Float(input float64) *float64 {
return &input
}

// String
// Deprecated: please use the`To` function in the `pointer` package
func String(input string) *string {
return &input
}

// StringSlice
// Deprecated: please use the `To` function in the `pointer` package
func StringSlice(input []string) *[]string {
if input == nil {
return nil
Expand Down
1 change: 1 addition & 0 deletions utils/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package utils

// NormalizeNilableString normalizes a nilable string into a string
// that is, if it's nil returns an empty string else the value
// Deprecated: please use the `From` function in the `pointer` package
func NormalizeNilableString(input *string) string {
if input == nil {
return ""
Expand Down

0 comments on commit 5a6fec6

Please sign in to comment.