import "time" func main() { minutes := 5 duration := time.Duration(minutes) * time.Minute fmt.Printf("Duration: %v", duration) }
import "time" func main() { t := time.Now() duration := 10 * time.Minute newTime := t.Add(duration) fmt.Printf("New time: %v", newTime) }Here, we have added 10 minutes to the current time using the Add() method of the Time instance. The result is a new time instance that is 10 minutes ahead of the current time. Package library for these examples is "time" package.