From cd9c325895d9d01f6239ac9d12d01c6868d81c52 Mon Sep 17 00:00:00 2001 From: Travis LaDuke Date: Thu, 15 Aug 2024 10:52:28 -0700 Subject: [PATCH] Create go.yml --- .github/workflows/go.yml | 54 ++++++++++++++++++++++++++++++++++++++++ client.go | 2 +- 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/go.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..05600bd --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,54 @@ +# This workflow will build a golang project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go + +name: Go + +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + golangci: + name: lint + runs-on: gha-runner-x64 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: v1.20 + - name: golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + version: v1.59 + + build: + name: build + runs-on: gha-runner-x64 + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.20' + + - name: Build + run: go build -v ./... + + test: + if: github.repository_owner == 'zerotier' + name: test + runs-on: gha-runner-x64 + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.20' + + - name: Test + env: + ZEROTIER_CENTRAL_TOKEN: ${{ secrets.ZEROTIER_CENTRAL_TOKEN }} + run: | + go test -v ./... diff --git a/client.go b/client.go index 50975da..122b8c7 100644 --- a/client.go +++ b/client.go @@ -135,7 +135,7 @@ func (c *Client) RoundTrip(req *http.Request) (*http.Response, error) { req.Header.Set("Authorization", fmt.Sprintf("bearer %s", c.apiKey)) if c.limits.Limit != 0 && c.limits.Remaining < c.limits.Limit { - diff := time.Now().Add(time.Duration(c.limits.Limit-c.limits.Remaining) * 10 * time.Millisecond).Sub(time.Now()) + diff := time.Until(time.Now().Add(time.Duration(c.limits.Limit-c.limits.Remaining) * 10 * time.Millisecond)) time.Sleep(diff) }