chore: ntp service dep with sing, optional synchronize system time

This commit is contained in:
riolu.rs
2023-09-03 17:48:52 +08:00
parent d6b80acfbc
commit d6cf2a837f
8 changed files with 130 additions and 90 deletions

14
ntp/time_unix.go Normal file
View File

@ -0,0 +1,14 @@
//go:build linux || darwin
package ntp
import (
"time"
"golang.org/x/sys/unix"
)
func setSystemTime(nowTime time.Time) error {
timeVal := unix.NsecToTimeval(nowTime.UnixNano())
return unix.Settimeofday(&timeVal)
}