ms-auth/pkg/utils/converter.go

34 lines
471 B
Go
Raw Normal View History

2024-10-09 17:07:38 +00:00
package utils
import (
"google.golang.org/protobuf/types/known/timestamppb"
"time"
)
func TimeP(t *timestamppb.Timestamp) *time.Time {
if t == nil {
return nil
}
tt := t.AsTime()
return &tt
}
func TimestampP(t *time.Time) *timestamppb.Timestamp {
if t == nil {
return nil
}
return timestamppb.New(*t)
}
func AsTimeP(t time.Time) *time.Time {
return &t
}
func AsInt32P(v int32) *int32 {
return &v
}
func AsStringP(str string) *string {
return &str
}