NTP

Simple implementation of NTP client

Install

go get github.com/haikelfazzani/ntpc

Usage

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)
}

rfc5905 Public Time Servers

License

MIT

linuxmacosntpntp-clientrfc5905sntp