Fix deprecation warnings about `ptypes` package

`staticcheck` is complaining about `ptypes` pkg being deprecated.
This commit is contained in:
Jeff Widman 2022-02-04 12:53:04 -08:00
parent a357b1e4a7
commit 0c7b16492f
1 changed files with 6 additions and 4 deletions

View File

@ -5,7 +5,6 @@ import (
"fmt" "fmt"
"time" "time"
"github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes/empty" "github.com/golang/protobuf/ptypes/empty"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
"google.golang.org/grpc/status" "google.golang.org/grpc/status"
@ -72,26 +71,29 @@ func (s *bankServer) GetTransactions(req *GetTransactionsRequest, stream Bank_Ge
var start, end time.Time var start, end time.Time
if req.Start != nil { if req.Start != nil {
start, err = ptypes.Timestamp(req.Start) err := req.Start.CheckValid()
if err != nil { if err != nil {
return err return err
} }
start = req.Start.AsTime()
} }
if req.End != nil { if req.End != nil {
end, err = ptypes.Timestamp(req.End) err := req.End.CheckValid()
if err != nil { if err != nil {
return err return err
} }
end = req.End.AsTime()
} else { } else {
end = time.Date(9999, 12, 31, 23, 59, 59, 999999999, time.Local) end = time.Date(9999, 12, 31, 23, 59, 59, 999999999, time.Local)
} }
txns := acct.getTransactions() txns := acct.getTransactions()
for _, txn := range txns { for _, txn := range txns {
t, err := ptypes.Timestamp(txn.Date) err := txn.Date.CheckValid()
if err != nil { if err != nil {
return err return err
} }
t := txn.Date.AsTime()
if (t.After(start) || t.Equal(start)) && if (t.After(start) || t.Equal(start)) &&
(t.Before(end) || t.Equal(end)) { (t.Before(end) || t.Equal(end)) {