From 1917bb6856dd3535f67befe1d2aab9c38892c88d Mon Sep 17 00:00:00 2001 From: Spiegel Date: Sat, 3 Feb 2024 18:58:11 +0900 Subject: [PATCH 1/2] Bump up external packages --- Taskfile.yml | 4 ++-- client.go | 20 ++++++++++---------- go.mod | 6 +++--- go.sum | 8 ++++---- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Taskfile.yml b/Taskfile.yml index 7467be4..0ece351 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -12,7 +12,7 @@ tasks: cmds: - go mod verify - go test -shuffle on ./... - - docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.51.1 golangci-lint run --enable gosec --timeout 3m0s ./... + - docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.55.2 golangci-lint run --enable gosec --timeout 3m0s ./... sources: - ./go.mod - '**/*.go' @@ -28,4 +28,4 @@ tasks: clean: desc: Initialize module and build cache, and remake go.sum file. cmds: - - go mod tidy -v -go=1.20 + - go mod tidy -v -go=1.21 diff --git a/client.go b/client.go index 0554757..d33196e 100644 --- a/client.go +++ b/client.go @@ -17,13 +17,13 @@ const ( defaultPartnerType = "Associates" ) -//Query interface for Client type +// Query interface for Client type type Query interface { Operation() Operation Payload() ([]byte, error) } -//Client interface +// Client interface type Client interface { Marketplace() string PartnerTag() string @@ -32,7 +32,7 @@ type Client interface { RequestContext(context.Context, Query) ([]byte, error) } -//client is http.Client for Aozora API Server +// client is http.Client for Aozora API Server type client struct { server *Server client fetch.Client @@ -41,27 +41,27 @@ type client struct { secretKey string } -//Marketplace returns name of Marketplace parameter for PA-API v5 +// Marketplace returns name of Marketplace parameter for PA-API v5 func (c *client) Marketplace() string { return c.server.Marketplace() } -//PartnerTag returns PartnerTag parameter for PA-API v5 +// PartnerTag returns PartnerTag parameter for PA-API v5 func (c *client) PartnerTag() string { return c.partnerTag } -//PartnerType returns PartnerType parameter for PA-API v5 +// PartnerType returns PartnerType parameter for PA-API v5 func (c *client) PartnerType() string { return defaultPartnerType } -//Request method returns response data (JSON format) by PA-APIv5. +// Request method returns response data (JSON format) by PA-APIv5. func (c *client) Request(q Query) ([]byte, error) { return c.RequestContext(context.Background(), q) } -//RequestContext method returns response data (JSON format) by PA-APIv5. (with context.Context) +// RequestContext method returns response data (JSON format) by PA-APIv5. (with context.Context) func (c *client) RequestContext(ctx context.Context, q Query) ([]byte, error) { payload, err := q.Payload() if err != nil { @@ -79,10 +79,10 @@ func (c *client) post(ctx context.Context, cmd Operation, payload []byte) ([]byt u := c.server.URL(cmd.Path()) hds := newHeaders(c.server, cmd, dt) sig := c.signiture(c.signedString(hds, payload), hds) - resp, err := c.client.Post( + resp, err := c.client.PostWithContext( + ctx, u, bytes.NewReader(payload), - fetch.WithContext(ctx), fetch.WithRequestHeaderSet("Accept", c.server.Accept()), fetch.WithRequestHeaderSet("Accept-Language", c.server.AcceptLanguage()), fetch.WithRequestHeaderSet("Content-Type", c.server.ContentType()), diff --git a/go.mod b/go.mod index 8e099c0..0ddeb18 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,8 @@ module github.com/goark/pa-api -go 1.20 +go 1.21 require ( - github.com/goark/errs v1.1.0 - github.com/goark/fetch v0.3.0 + github.com/goark/errs v1.3.2 + github.com/goark/fetch v0.4.1 ) diff --git a/go.sum b/go.sum index 7babbbf..0016866 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,4 @@ -github.com/goark/errs v1.1.0 h1:FKnyw4LVyRADIjM8Nj0Up6r0/y5cfADvZAd1E+tthXE= -github.com/goark/errs v1.1.0/go.mod h1:TtaPEoadm2mzqzfXdkkfpN2xuniCFm2q4JH+c1qzaqw= -github.com/goark/fetch v0.3.0 h1:2m32EGOLBi99RzI5urFfmv5++CMqfenVw7NH8z/lbX8= -github.com/goark/fetch v0.3.0/go.mod h1:sqDdPbbHeIjDVeHrgvzhHpkUr8X9pVC9DgJoVwU02x0= +github.com/goark/errs v1.3.2 h1:ifccNe1aK7Xezt4XVYwHUqalmnfhuphnEvh3FshCReQ= +github.com/goark/errs v1.3.2/go.mod h1:ZsQucxaDFVfSB8I99j4bxkDRfNOrlKINwg72QMuRWKw= +github.com/goark/fetch v0.4.1 h1:Y59g9sAdgqjPS7UADdLIoQGRxJE1WMo5ixlJi/ZcCfc= +github.com/goark/fetch v0.4.1/go.mod h1:umZxLIJHa15J8EQSp5zft1dHDv0VGwmQL6pOfaJ60FY= From 2a4615a3b3bd42a4d929fed51be806f986354daf Mon Sep 17 00:00:00 2001 From: Spiegel Date: Sat, 3 Feb 2024 19:05:17 +0900 Subject: [PATCH 2/2] Update GitHub Action: vulns.yml --- .github/workflows/vulns.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/vulns.yml b/.github/workflows/vulns.yml index 2200dfa..20d0d97 100644 --- a/.github/workflows/vulns.yml +++ b/.github/workflows/vulns.yml @@ -12,7 +12,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: ^1.20 + go-version-file: 'go.mod' - name: WriteGoList run: go list -json -m all > go.list - name: Nancy