go-twitch/ptr_types.go

153 lines
2.0 KiB
Go

package twitch
import (
"time"
"go.fifitido.net/twitch/api/bits"
"go.fifitido.net/twitch/api/channelpoints"
"go.fifitido.net/twitch/api/types"
)
func String(s string) *string {
return &s
}
func ToString(s *string) string {
if s == nil {
return ""
}
return *s
}
func StringSlice(s []string) *[]string {
return &s
}
func ToStringSlice(s *[]string) []string {
if s == nil {
return []string{}
}
return *s
}
func Bool(b bool) *bool {
return &b
}
func ToBool(b *bool) bool {
if b == nil {
return false
}
return *b
}
func Int(i int) *int {
return &i
}
func ToInt(i *int) int {
if i == nil {
return 0
}
return *i
}
func Int64(i int64) *int64 {
return &i
}
func ToInt64(i *int64) int64 {
if i == nil {
return 0
}
return *i
}
func Int32(i int32) *int32 {
return &i
}
func ToInt32(i *int32) int32 {
if i == nil {
return 0
}
return *i
}
func Float32(f float32) *float32 {
return &f
}
func ToFloat32(f *float32) float32 {
if f == nil {
return 0
}
return *f
}
func Float64(f float64) *float64 {
return &f
}
func ToFloat64(f *float64) float64 {
if f == nil {
return 0
}
return *f
}
func Time(t time.Time) *time.Time {
return &t
}
func ToTime(t *time.Time) time.Time {
if t == nil {
return time.Time{}
}
return *t
}
func Cursor(c types.Cursor) *types.Cursor {
return &c
}
func ToCursor(c *types.Cursor) types.Cursor {
if c == nil {
return ""
}
return *c
}
func BitsPeriod(p bits.Period) *bits.Period {
return &p
}
func ToBitsPeriod(p *bits.Period) bits.Period {
if p == nil {
return ""
}
return *p
}
func RewardRedemptionStatus(s channelpoints.RewardRedemptionStatus) *channelpoints.RewardRedemptionStatus {
return &s
}
func ToRewardRedemptionStatus(s *channelpoints.RewardRedemptionStatus) channelpoints.RewardRedemptionStatus {
if s == nil {
return ""
}
return *s
}
func SortOrder(s types.SortOrder) *types.SortOrder {
return &s
}
func ToSortOrder(s *types.SortOrder) types.SortOrder {
if s == nil {
return ""
}
return *s
}