mirror of
https://gitee.com/johng/gf
synced 2026-07-03 11:51:04 +08:00
improve nil receiver handling for package gtime (#2226)
* improve nil receiver handling for package gtime * CI updates * CI updates
This commit is contained in:
16
.github/workflows/gf.yml
vendored
16
.github/workflows/gf.yml
vendored
@ -141,6 +141,12 @@ jobs:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Start Apollo Containers
|
||||
run: docker-compose -f ".github/workflows/apollo/docker-compose.yml" up -d --build
|
||||
|
||||
- name: Start Redis Cluster Containers
|
||||
run: docker-compose -f ".github/workflows/redis/docker-compose.yml" up -d --build
|
||||
|
||||
- name: Start Minikube
|
||||
uses: medyagh/setup-minikube@master
|
||||
|
||||
@ -161,22 +167,16 @@ jobs:
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||
|
||||
- name: Start redis cluster containers
|
||||
run: docker-compose -f ".github/workflows/redis/docker-compose.yml" up -d --build
|
||||
|
||||
- name: Start apollo containers
|
||||
run: docker-compose -f ".github/workflows/apollo/docker-compose.yml" up -d --build
|
||||
|
||||
- name: Before Script
|
||||
run: bash .github/workflows/before_script.sh
|
||||
|
||||
- name: Build & Test
|
||||
run: bash .github/workflows/build_and_test.sh
|
||||
|
||||
- name: Stop redis cluster containers
|
||||
- name: Stop Redis Cluster Containers
|
||||
run: docker-compose -f ".github/workflows/redis/docker-compose.yml" down
|
||||
|
||||
- name: Stop apollo containers
|
||||
- name: Stop Apollo Containers
|
||||
run: docker-compose -f ".github/workflows/apollo/docker-compose.yml" down
|
||||
|
||||
- name: Report Coverage
|
||||
|
||||
@ -317,7 +317,16 @@ func (t *Time) Truncate(d time.Duration) *Time {
|
||||
// See the documentation on the Time type for the pitfalls of using == with
|
||||
// Time values; most code should use Equal instead.
|
||||
func (t *Time) Equal(u *Time) bool {
|
||||
return t.Time.Equal(u.Time)
|
||||
switch {
|
||||
case t == nil && u != nil:
|
||||
return false
|
||||
case t == nil && u == nil:
|
||||
return true
|
||||
case t != nil && u == nil:
|
||||
return false
|
||||
default:
|
||||
return t.Time.Equal(u.Time)
|
||||
}
|
||||
}
|
||||
|
||||
// Before reports whether the time instant t is before u.
|
||||
@ -327,7 +336,14 @@ func (t *Time) Before(u *Time) bool {
|
||||
|
||||
// After reports whether the time instant t is after u.
|
||||
func (t *Time) After(u *Time) bool {
|
||||
return t.Time.After(u.Time)
|
||||
switch {
|
||||
case t == nil:
|
||||
return false
|
||||
case t != nil && u == nil:
|
||||
return true
|
||||
default:
|
||||
return t.Time.After(u.Time)
|
||||
}
|
||||
}
|
||||
|
||||
// Sub returns the duration t-u. If the result exceeds the maximum (or minimum)
|
||||
@ -335,6 +351,9 @@ func (t *Time) After(u *Time) bool {
|
||||
// will be returned.
|
||||
// To compute t-d for a duration d, use t.Add(-d).
|
||||
func (t *Time) Sub(u *Time) time.Duration {
|
||||
if t == nil || u == nil {
|
||||
return 0
|
||||
}
|
||||
return t.Time.Sub(u.Time)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user