How to multiply duration (time.Duration) by an integer in Go?
Hello everyone! I just started learning Go and ran into a problem while working with the time package. I need to create a timer that fires every N seconds, where N is given by the user as an integer.
package main\n\nimport (\n "fmt"\n "time"\n)\n\nfunc main() {\n var n int\n fmt.Print("Enter interval in seconds: ")\n fmt.Scan(&n)\n \n // Trying to multiply duration\n interval := time.Second * n // Error!\n fmt.Println(interval)\n}\n\n\nThe compiler gives an error: invalid operation: time.Second * n (mismatched types time.Duration and int). I understand that time.Second is of type time.Duration, and n is of type int, and they cannot simply be multiplied. But how then