Skip to content

Commit

Permalink
minecraft/conn.go: Allow passing empty time.Time in SetReadDeadline() (
Browse files Browse the repository at this point in the history
  • Loading branch information
JavierLeon9966 committed Jan 5, 2024
1 parent 2615e5f commit 36e5147
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions minecraft/conn.go
Expand Up @@ -487,12 +487,11 @@ func (conn *Conn) SetDeadline(t time.Time) error {
// SetReadDeadline sets the read deadline of the Conn to the time passed. The time must be after time.Now().
// Passing an empty time.Time to the method (time.Time{}) results in the read deadline being cleared.
func (conn *Conn) SetReadDeadline(t time.Time) error {
if t.Before(time.Now()) {
panic(fmt.Errorf("error setting read deadline: time passed is before time.Now()"))
}
empty := time.Time{}
if t == empty {
conn.readDeadline = make(chan time.Time)
} else if t.Before(time.Now()) {
panic(fmt.Errorf("error setting read deadline: time passed is before time.Now()"))
} else {
conn.readDeadline = time.After(time.Until(t))
}
Expand Down

0 comments on commit 36e5147

Please sign in to comment.