Simple implementation of NTP client
go get github.com/haikelfazzani/ntpc
package main
import (
"fmt"
ntpc "github.com/haikelfazzani/ntpc/core"
)
func main() {
ntpc := &ntpc.NewClient{
Server: "pool.ntp.org",
Port: "123",
Timeout: 10,
}
timeNow, _ := ntpc.Query()
fmt.Println("\n> NTP time:", timeNow.Local())
dateTime := timeNow.Format("2006-01-02 15:04:05")
isUpdated := ntpc.UpdateSystem(dateTime)
fmt.Println("\n> System time updated:", isUpdated)
}
MIT