Skip to content

Commit 00f90f6

Browse files
committed
Create go.yml
1 parent 3cd011d commit 00f90f6

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

.github/workflows/go.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# This workflow will build a golang project
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
3+
4+
name: Go
5+
6+
on:
7+
pull_request:
8+
types: [opened, synchronize, reopened]
9+
10+
jobs:
11+
golangci:
12+
name: lint
13+
runs-on: gha-runner-x64
14+
environment: the-env
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-go@v5
18+
with:
19+
go-version: v1.20
20+
- name: golangci-lint
21+
uses: golangci/golangci-lint-action@v6
22+
with:
23+
version: v1.59
24+
25+
build:
26+
name: build
27+
environment: the-env
28+
runs-on: gha-runner-x64
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
- name: Set up Go
33+
uses: actions/setup-go@v4
34+
with:
35+
go-version: '1.20'
36+
37+
- name: Build
38+
run: go build -v ./...
39+
40+
test:
41+
if: github.repository_owner == 'zerotier'
42+
name: test
43+
environment: the-env
44+
runs-on: gha-runner-x64
45+
steps:
46+
- uses: actions/checkout@v4
47+
48+
- name: Set up Go
49+
uses: actions/setup-go@v4
50+
with:
51+
go-version: '1.20'
52+
53+
- name: Test
54+
env:
55+
ZEROTIER_CENTRAL_TOKEN: ${{ secrets.ZEROTIER_CENTRAL_TOKEN }}
56+
run: |
57+
go test -v ./...

client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func (c *Client) RoundTrip(req *http.Request) (*http.Response, error) {
135135
req.Header.Set("Authorization", fmt.Sprintf("bearer %s", c.apiKey))
136136

137137
if c.limits.Limit != 0 && c.limits.Remaining < c.limits.Limit {
138-
diff := time.Now().Add(time.Duration(c.limits.Limit-c.limits.Remaining) * 10 * time.Millisecond).Sub(time.Now())
138+
diff := time.Until(time.Now().Add(time.Duration(c.limits.Limit-c.limits.Remaining) * 10 * time.Millisecond))
139139
time.Sleep(diff)
140140
}
141141

0 commit comments

Comments
 (0)