Skip to content

Commit

Permalink
api: pointer conversion functions should return nil for nil input
Browse files Browse the repository at this point in the history
Signed-off-by: Dimitrios Karagiannis <[email protected]>
  • Loading branch information
alkar committed Nov 4, 2019
1 parent 827d6ba commit fce6735
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions megaport/api/helpers.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
package api

func String(v interface{}) *string {
if v == nil {
return nil
}
r := v.(string)
return &r
}

func Uint64(v interface{}) *uint64 {
if v == nil {
return nil
}
r := v.(uint64)
return &r
}

func Uint64FromInt(v interface{}) *uint64 {
if v == nil {
return nil
}
r := uint64(v.(int))
return &r
}

func Bool(v interface{}) *bool {
if v == nil {
return nil
}
r := v.(bool)
return &r
}

0 comments on commit fce6735

Please sign in to comment.