2016-06-01 09:56:20 +02: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-21 04:19:15 +01:00
|
|
|
ntp
|
|
|
|
===
|
|
|
|
|
2017-10-04 08:33:49 +02:00
|
|
|
The ntp package is an implementation of a Simple NTP (SNTP) client based on
|
|
|
|
[RFC5905](https://tools.ietf.org/html/rfc5905). It allows you to connect to
|
|
|
|
a remote NTP server and request the current time.
|
2016-01-21 04:19:15 +01:00
|
|
|
|
2017-10-04 08:33:49 +02:00
|
|
|
If all you care about is the current time according to a known remote NTP
|
|
|
|
server, simply use the `Time` function:
|
2017-02-28 22:59:37 +01:00
|
|
|
```go
|
2017-09-19 10:36:14 +02:00
|
|
|
time, err := ntp.Time("0.beevik-ntp.pool.ntp.org")
|
2017-02-28 22:59:37 +01:00
|
|
|
```
|
2016-01-21 04:19:15 +01:00
|
|
|
|
2017-10-04 08:33:49 +02:00
|
|
|
If you want the time as well as additional metadata about the time, use the
|
|
|
|
`Query` function instead:
|
2017-02-28 22:59:37 +01:00
|
|
|
```go
|
2017-09-19 10:36:14 +02:00
|
|
|
response, err := ntp.Query("0.beevik-ntp.pool.ntp.org")
|
2017-02-28 22:59:37 +01:00
|
|
|
```
|
2017-09-19 10:36:14 +02:00
|
|
|
|
2017-10-04 08:33:49 +02:00
|
|
|
To use the NTP pool in your application, please request your own
|
|
|
|
[vendor zone](http://www.pool.ntp.org/en/vendors.html). Avoid using
|
|
|
|
the `[number].pool.ntp.org` zone names in your applications.
|