From 36df906bbb726525c1b524497a7c8606f0a0b525 Mon Sep 17 00:00:00 2001 From: Ryan Cavicchioni Date: Mon, 15 Feb 2021 19:23:01 -0600 Subject: [PATCH] Add version to user agent --- client.go | 16 ++++++++++++++++ version.go | 3 +++ 2 files changed, 19 insertions(+) create mode 100644 version.go diff --git a/client.go b/client.go index 07a1173..49743a2 100644 --- a/client.go +++ b/client.go @@ -10,6 +10,7 @@ import ( "net/http" "net/url" "strconv" + "strings" "time" ) @@ -71,6 +72,12 @@ var errorMap = map[int]error{ 523: errors.New("Something went wrong on LIFX's end"), } +var userAgent string + +func init() { + userAgent = initUserAgent() +} + func NewClient(accessToken string, options ...func(*Client)) *Client { var c *Client tr := &http.Transport{ @@ -333,3 +340,12 @@ func (c *Client) stateDelta(selector string, delta StateDelta) (*Response, error return resp, nil } + +func initUserAgent() string { + var b strings.Builder + + b.WriteString("lifx-go") + b.WriteRune('/') + b.WriteString(Version) + return b.String() +} diff --git a/version.go b/version.go new file mode 100644 index 0000000..144a529 --- /dev/null +++ b/version.go @@ -0,0 +1,3 @@ +package lifx + +const Version = "0.1.0-pre"