Source File
time.go
Belonging Package
github.com/gofiber/fiber/v2/utils
package utilsimport ()var (timestampTimer sync.Once// Timestamp please start the timer function before you use this value// please load the value with atomic `atomic.LoadUint32(&utils.Timestamp)`Timestamp uint32)// StartTimeStampUpdater starts a concurrent function which stores the timestamp to an atomic value per second,// which is much better for performance than determining it at runtime each timefunc () {timestampTimer.Do(func() {// set initial valueatomic.StoreUint32(&Timestamp, uint32(time.Now().Unix()))go func( time.Duration) {:= time.NewTicker()defer .Stop()for := range .C {// update timestampatomic.StoreUint32(&Timestamp, uint32(.Unix()))}}(1 * time.Second) // duration})}
![]() |
The pages are generated with Golds v0.6.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |