From a12cfb3898e8cc9e417d4aeb2ec51326882aa077 Mon Sep 17 00:00:00 2001 From: c9s Date: Mon, 8 Dec 2025 17:32:22 +0800 Subject: [PATCH 1/4] call binance us api for test https://api.binance.us --- client_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client_test.go b/client_test.go index 090f40a..7864149 100644 --- a/client_test.go +++ b/client_test.go @@ -9,15 +9,15 @@ import ( ) func TestClient(t *testing.T) { - baseURL, err := url.Parse("https://api.binance.com") + baseURL, err := url.Parse("https://api.binance.us") assert.NoError(t, err) ctx := context.Background() apiClient := &BaseAPIClient{ - BaseURL: baseURL, + BaseURL: baseURL, } - req, err := apiClient.NewRequest(ctx, "GET", "/api/v3/ping", nil , nil) + req, err := apiClient.NewRequest(ctx, "GET", "/api/v3/ping", nil, nil) if assert.NoError(t, err) { assert.NotNil(t, req) From f5840d81604c9e71edcff9575ed882dee6e0c506 Mon Sep 17 00:00:00 2001 From: c9s Date: Mon, 8 Dec 2025 17:28:59 +0800 Subject: [PATCH 2/4] fix parseref test --- parseref_test.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/parseref_test.go b/parseref_test.go index cf96c7b..40eadb9 100644 --- a/parseref_test.go +++ b/parseref_test.go @@ -7,8 +7,8 @@ func TestParseTypeSelector(t *testing.T) { main string } tests := []struct { - name string - args args + name string + args args wantErr bool wantSpec TypeSelector }{ @@ -41,7 +41,8 @@ func TestParseTypeSelector(t *testing.T) { }, wantErr: false, wantSpec: TypeSelector{ - Package: "github.com/c9s/requestgen", + // Package: "github.com/c9s/requestgen", + Package: ".", Member: "APIClient", IsSlice: true, }, @@ -53,7 +54,8 @@ func TestParseTypeSelector(t *testing.T) { }, wantErr: false, wantSpec: TypeSelector{ - Package: "github.com/c9s/requestgen", + // Package: "github.com/c9s/requestgen", + Package: ".", Member: "APIClient", }, }, From f4cdeaa5db0533ed606867cf5e3df8a691a3f16e Mon Sep 17 00:00:00 2001 From: c9s Date: Mon, 8 Dec 2025 17:25:31 +0800 Subject: [PATCH 3/4] add workflows --- .github/workflows/go.yml | 77 +++++++++++++++++++++++++++++++ .github/workflows/golang-lint.yml | 24 ++++++++++ .golangci.yml | 36 +++++++++++++++ 3 files changed, 137 insertions(+) create mode 100644 .github/workflows/go.yml create mode 100644 .github/workflows/golang-lint.yml create mode 100644 .golangci.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..b8f2d35 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,77 @@ +name: Go + +on: + push: + branches: + - "main" + pull_request: + # types: [synchronize, opened, reopened, edited] + # branches: + # - "main" + # - "v*" + +jobs: + build: + runs-on: ubuntu-latest + timeout-minutes: 15 + + strategy: + matrix: + redis-version: + - "6.2" + go-version: + - "1.25" + env: + GITHUB_CI: true + MYSQL_DATABASE: bbgo + MYSQL_USER: "root" + MYSQL_PASSWORD: "root" # pragma: allowlist secret + + steps: + + - uses: actions/checkout@v6 + with: + # lfs: 'true' + ssh-key: ${{ secrets.git_ssh_key }} + + - uses: actions/cache@v4 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Set up MySQL + run: | + sudo /etc/init.d/mysql start + mysql -e 'CREATE DATABASE ${{ env.MYSQL_DATABASE }};' -u${{ env.MYSQL_USER }} -p${{ env.MYSQL_PASSWORD }} + + - name: Set up redis + uses: shogo82148/actions-setup-redis@v1 + with: + redis-version: ${{ matrix.redis-version }} + # auto-start: "false" + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version: ${{ matrix.go-version }} + + - name: Test + run: | + go test -count 3 -race -coverprofile coverage.txt -covermode atomic ./... + sed -i -e '/_requestgen.go/d' coverage.txt + + - name: Revive Check + uses: morphy2k/revive-action@v2.7.7 # https://github.com/mgechev/revive/issues/956 + with: + reporter: github-pr-review + fail_on_error: true + + - name: Upload Coverage Report + uses: codecov/codecov-action@v5 + with: + files: ./coverage.txt,./coverage_dnum.txt + diff --git a/.github/workflows/golang-lint.yml b/.github/workflows/golang-lint.yml new file mode 100644 index 0000000..1070eef --- /dev/null +++ b/.github/workflows/golang-lint.yml @@ -0,0 +1,24 @@ +name: golang-lint +on: + push: + branches: [ main ] + pull_request: + +permissions: + contents: read + pull-requests: read + checks: write + +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: actions/setup-go@v6 + with: + go-version: '1.25' + - name: golangci-lint + uses: golangci/golangci-lint-action@v8 + with: + version: 'v2.6' diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..bcae6b3 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,36 @@ +version: "2" +run: + issues-exit-code: 0 + tests: true +linters: + default: none + enable: + - staticcheck + - bodyclose + - contextcheck + - dupword + - decorder + - goconst + - govet + - gosec + - misspell + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + paths: + - third_party$ + - builtin$ + - examples$ +formatters: + enable: + - gofmt + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ From 057b568a6a10e87e369abe4688b50a0741173cba Mon Sep 17 00:00:00 2001 From: c9s Date: Mon, 8 Dec 2025 17:28:55 +0800 Subject: [PATCH 4/4] upgrade go to 1.25 uprade golang.org/x/tools to 0.39 --- go.mod | 12 +++++------- go.sum | 22 ++++++++++++++-------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/go.mod b/go.mod index 44d034f..70560b3 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,6 @@ module github.com/c9s/requestgen -go 1.23.0 - -toolchain go1.23.6 +go 1.25.0 require ( github.com/fatih/camelcase v1.0.0 @@ -12,14 +10,14 @@ require ( github.com/sirupsen/logrus v1.8.1 github.com/stretchr/testify v1.4.0 golang.org/x/time v0.6.0 - golang.org/x/tools v0.35.0 + golang.org/x/tools v0.39.0 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/mod v0.26.0 // indirect - golang.org/x/sync v0.16.0 // indirect - golang.org/x/sys v0.34.0 // indirect + golang.org/x/mod v0.30.0 // indirect + golang.org/x/sync v0.18.0 // indirect + golang.org/x/sys v0.38.0 // indirect gopkg.in/yaml.v2 v2.2.2 // indirect ) diff --git a/go.sum b/go.sum index e36898d..3bf448f 100644 --- a/go.sum +++ b/go.sum @@ -19,17 +19,23 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -golang.org/x/mod v0.26.0 h1:EGMPT//Ezu+ylkCijjPc+f4Aih7sZvaAr+O3EHBxvZg= -golang.org/x/mod v0.26.0/go.mod h1:/j6NAhSk8iQ723BGAUyoAcn7SlD7s15Dp9Nd/SfeaFQ= -golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw= -golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/mod v0.30.0 h1:fDEXFVZ/fmCKProc/yAXXUijritrDzahmwwefnjoPFk= +golang.org/x/mod v0.30.0/go.mod h1:lAsf5O2EvJeSFMiBxXDki7sCgAxEUcZHXoXMKT4GJKc= +golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug= +golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= +golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I= +golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA= -golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ= +golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= +golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U= golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= -golang.org/x/tools v0.35.0 h1:mBffYraMEf7aa0sB+NuKnuCy8qI/9Bughn8dC2Gu5r0= -golang.org/x/tools v0.35.0/go.mod h1:NKdj5HkL/73byiZSJjqJgKn3ep7KjFkBOkR/Hps3VPw= +golang.org/x/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ= +golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs= +golang.org/x/tools v0.39.0 h1:ik4ho21kwuQln40uelmciQPp9SipgNDdrafrYA4TmQQ= +golang.org/x/tools v0.39.0/go.mod h1:JnefbkDPyD8UU2kI5fuf8ZX4/yUeh9W877ZeBONxUqQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=