2016-06-01 00:56:20 -07:00
|
|
|
[![Build Status](https://travis-ci.org/beevik/ntp.svg?branch=master)](https://travis-ci.org/beevik/ntp)
|
|
|
|
[![GoDoc](https://godoc.org/github.com/beevik/ntp?status.svg)](https://godoc.org/github.com/beevik/ntp)
|
|
|
|
|
2016-01-20 19:19:15 -08:00
|
|
|
ntp
|
|
|
|
===
|
|
|
|
|
2017-02-28 13:59:37 -08:00
|
|
|
The ntp package is an implementation of a simple NTP client. It allows you
|
|
|
|
to connect to a remote NTP server and request the current time.
|
2016-01-20 19:19:15 -08:00
|
|
|
|
2017-09-19 01:36:14 -07:00
|
|
|
To request the current time, simply do the following:
|
2017-02-28 13:59:37 -08:00
|
|
|
```go
|
2017-09-19 01:36:14 -07:00
|
|
|
time, err := ntp.Time("0.beevik-ntp.pool.ntp.org")
|
2017-02-28 13:59:37 -08:00
|
|
|
```
|
2016-01-20 19:19:15 -08:00
|
|
|
|
2017-02-28 13:59:37 -08:00
|
|
|
To request the current time along with additional metadata, use the Query
|
|
|
|
function:
|
|
|
|
```go
|
2017-09-19 01:36:14 -07:00
|
|
|
response, err := ntp.Query("0.beevik-ntp.pool.ntp.org")
|
2017-02-28 13:59:37 -08:00
|
|
|
```
|
2017-09-19 01:36:14 -07:00
|
|
|
|
|
|
|
NB: if you want to use the NTP Pool in your software you should request your
|
|
|
|
own [vendor zone](http://www.pool.ntp.org/en/vendors.html). You **must
|
|
|
|
absolutely not use the default pool.ntp.org zone names** as the default
|
|
|
|
configuration in your application or appliance.
|