Standard library / time

time.Until()

Compute duration until t; negative results mean the target is past. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func Until(t Time) Duration

Parameters & Attributes

NameTypeDescription
tTimeReference instant.

Return Value

Duration

Compute duration until t; negative results mean the target is past.

Working Example

Example Snippetgo
package main
import (  "fmt"  "time")
func main() { target := time.Now().Add(-time.Hour); fmt.Println(time.Until(target) < 0) }
Go Reference