Add version to user agent

This commit is contained in:
Ryan Cavicchioni 2021-02-15 19:23:01 -06:00
parent f86c28b0a5
commit 36df906bbb
Signed by: ryanc
GPG Key ID: 877EEDAF9245103D
2 changed files with 19 additions and 0 deletions

View File

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

3
version.go Normal file
View File

@ -0,0 +1,3 @@
package lifx
const Version = "0.1.0-pre"