diff --git a/.custom-gcl.yml b/.custom-gcl.yml index 0a36cedd21d..2aa94b1bb08 100644 --- a/.custom-gcl.yml +++ b/.custom-gcl.yml @@ -1,4 +1,6 @@ version: v2.2.2 plugins: - - module: "github.com/google/go-github/v68/tools/sliceofpointers" + - module: "github.com/google/go-github/v75/tools/sliceofpointers" path: ./tools/sliceofpointers + - module: "github.com/google/go-github/v75/tools/fmtpercentv" + path: ./tools/fmtpercentv diff --git a/.golangci.yml b/.golangci.yml index b745b8d85a7..f35bafec21e 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -9,6 +9,7 @@ linters: - dogsled - dupl - errorlint + - fmtpercentv - forbidigo - gocritic - godot @@ -136,10 +137,14 @@ linters: os-create-temp: true os-temp-dir: true custom: + fmtpercentv: + type: module + description: Reports usage of %d or %s in format strings. + original-url: github.com/google/go-github/v75/tools/fmtpercentv sliceofpointers: type: module description: Reports usage of []*string and slices of structs without pointers. - original-url: github.com/google/go-github/v68/tools/sliceofpointers + original-url: github.com/google/go-github/v75/tools/sliceofpointers exclusions: rules: - linters: diff --git a/README.md b/README.md index a5edb04dd0d..82c34131f9f 100644 --- a/README.md +++ b/README.md @@ -215,7 +215,7 @@ To detect a primary API rate limit error, you can check if the error is a repos, _, err := client.Repositories.List(ctx, "", nil) var rateErr *github.RateLimitError if errors.As(err, &rateError) { - log.Printf("hit primary rate limit, used %d of %d\n", rateErr.Rate.Used, rateErr.rate.Limit) + log.Printf("hit primary rate limit, used %v of %v\n", rateErr.Rate.Used, rateErr.rate.Limit) } ``` diff --git a/example/actionpermissions/main.go b/example/actionpermissions/main.go index 31e8e111842..e952d05bc05 100644 --- a/example/actionpermissions/main.go +++ b/example/actionpermissions/main.go @@ -42,7 +42,7 @@ func main() { log.Fatal(err) } - fmt.Printf("Current ActionsPermissions %s\n", actionsPermissionsRepository.String()) + fmt.Printf("Current ActionsPermissions %v\n", actionsPermissionsRepository) actionsPermissionsRepository = &github.ActionsPermissionsRepository{Enabled: github.Ptr(true), AllowedActions: github.Ptr("selected")} _, _, err = client.Repositories.UpdateActionsPermissions(ctx, *owner, *name, *actionsPermissionsRepository) @@ -50,14 +50,14 @@ func main() { log.Fatal(err) } - fmt.Printf("Current ActionsPermissions %s\n", actionsPermissionsRepository.String()) + fmt.Printf("Current ActionsPermissions %v\n", actionsPermissionsRepository) actionsAllowed, _, err := client.Repositories.GetActionsAllowed(ctx, *owner, *name) if err != nil { log.Fatal(err) } - fmt.Printf("Current ActionsAllowed %s\n", actionsAllowed.String()) + fmt.Printf("Current ActionsAllowed %v\n", actionsAllowed) actionsAllowed = &github.ActionsAllowed{GithubOwnedAllowed: github.Ptr(true), VerifiedAllowed: github.Ptr(false), PatternsAllowed: []string{"a/b"}} _, _, err = client.Repositories.EditActionsAllowed(ctx, *owner, *name, *actionsAllowed) @@ -65,7 +65,7 @@ func main() { log.Fatal(err) } - fmt.Printf("Current ActionsAllowed %s\n", actionsAllowed.String()) + fmt.Printf("Current ActionsAllowed %v\n", actionsAllowed) actionsPermissionsRepository = &github.ActionsPermissionsRepository{Enabled: github.Ptr(true), AllowedActions: github.Ptr("all")} _, _, err = client.Repositories.UpdateActionsPermissions(ctx, *owner, *name, *actionsPermissionsRepository) @@ -73,5 +73,5 @@ func main() { log.Fatal(err) } - fmt.Printf("Current ActionsPermissions %s\n", actionsPermissionsRepository.String()) + fmt.Printf("Current ActionsPermissions %v\n", actionsPermissionsRepository) } diff --git a/example/commitpr/main.go b/example/commitpr/main.go index c1dda1e3fd9..48ff74f69eb 100644 --- a/example/commitpr/main.go +++ b/example/commitpr/main.go @@ -185,7 +185,7 @@ func createPR() (err error) { } if *prRepoOwner != "" && *prRepoOwner != *sourceOwner { - *commitBranch = fmt.Sprintf("%s:%s", *sourceOwner, *commitBranch) + *commitBranch = fmt.Sprintf("%v:%v", *sourceOwner, *commitBranch) } else { prRepoOwner = sourceOwner } @@ -208,7 +208,7 @@ func createPR() (err error) { return err } - fmt.Printf("PR created: %s\n", pr.GetHTMLURL()) + fmt.Printf("PR created: %v\n", pr.GetHTMLURL()) return nil } @@ -225,7 +225,7 @@ func main() { ref, err := getRef() if err != nil { - log.Fatalf("Unable to get/create the commit reference: %s\n", err) + log.Fatalf("Unable to get/create the commit reference: %v\n", err) } if ref == nil { log.Fatal("No error where returned but the reference is nil") @@ -233,14 +233,14 @@ func main() { tree, err := getTree(ref) if err != nil { - log.Fatalf("Unable to create the tree based on the provided files: %s\n", err) + log.Fatalf("Unable to create the tree based on the provided files: %v\n", err) } if err := pushCommit(ref, tree); err != nil { - log.Fatalf("Unable to create the commit: %s\n", err) + log.Fatalf("Unable to create the commit: %v\n", err) } if err := createPR(); err != nil { - log.Fatalf("Error while creating the pull request: %s", err) + log.Fatalf("Error while creating the pull request: %v", err) } } diff --git a/example/listenvironments/main.go b/example/listenvironments/main.go index 46784965a45..1c9a00ced10 100644 --- a/example/listenvironments/main.go +++ b/example/listenvironments/main.go @@ -46,5 +46,5 @@ func main() { } // The number of environments here should be equal to expectedPageSize - fmt.Printf("%d environments returned\n", len(envResponse.Environments)) + fmt.Printf("%v environments returned\n", len(envResponse.Environments)) } diff --git a/example/ratelimit/main.go b/example/ratelimit/main.go index 247d413d338..d7448af9528 100644 --- a/example/ratelimit/main.go +++ b/example/ratelimit/main.go @@ -27,7 +27,7 @@ func main() { rateLimiter := github_ratelimit.New(nil, github_primary_ratelimit.WithLimitDetectedCallback(func(ctx *github_primary_ratelimit.CallbackContext) { - fmt.Printf("Primary rate limit detected: category %s, reset time: %v\n", ctx.Category, ctx.ResetTime) + fmt.Printf("Primary rate limit detected: category %v, reset time: %v\n", ctx.Category, ctx.ResetTime) }), github_secondary_ratelimit.WithLimitDetectedCallback(func(ctx *github_secondary_ratelimit.CallbackContext) { fmt.Printf("Secondary rate limit detected: reset time: %v, total sleep time: %v\n", ctx.ResetTime, ctx.TotalSleepTime) diff --git a/example/verifyartifact/main.go b/example/verifyartifact/main.go index 619f42de7be..7a70ce8929c 100644 --- a/example/verifyartifact/main.go +++ b/example/verifyartifact/main.go @@ -49,13 +49,13 @@ var ( func usage() { fmt.Fprintln(os.Stderr, "This is an example of how to verify the provenance of an artifact using GitHub Attestations and the sigstore-go library.") - fmt.Fprintf(os.Stderr, "\nUsage: %s [flags]\n", os.Args[0]) + fmt.Fprintf(os.Stderr, "\nUsage: %v [flags]\n", os.Args[0]) fmt.Fprint(os.Stderr, "\nThe flags are:\n") flag.PrintDefaults() fmt.Fprintf(os.Stderr, ` Example: Verifying a GitHub CLI artifact - %s -owner cli \ + %v -owner cli \ -artifact-digest 2ce2e480e3c3f7ca0af83418d3ebaeedacee135dbac94bd946d7d84edabcdb64 \ -expected-san https://github.com/cli/cli/.github/workflows/deployment.yml@refs/heads/trunk @@ -118,7 +118,7 @@ func main() { func getTrustedMaterial() (root.TrustedMaterialCollection, error) { trustedRootJSON, err := os.ReadFile(*trustedRootJSONPath) if err != nil { - return nil, fmt.Errorf("failed to read %s: %w", *trustedRootJSONPath, err) + return nil, fmt.Errorf("failed to read %v: %w", *trustedRootJSONPath, err) } trustedRoot, err := root.NewTrustedRootFromJSON(trustedRootJSON) diff --git a/github/actions_artifacts_test.go b/github/actions_artifacts_test.go index 9eae793bc50..694a5e4e757 100644 --- a/github/actions_artifacts_test.go +++ b/github/actions_artifacts_test.go @@ -94,7 +94,7 @@ func TestActionsService_ListArtifacts_notFound(t *testing.T) { t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Actions.ListArtifacts return status %d, want %d", got, want) + t.Errorf("Actions.ListArtifacts return status %v, want %v", got, want) } if artifacts != nil { t.Errorf("Actions.ListArtifacts return %+v, want nil", artifacts) @@ -176,7 +176,7 @@ func TestActionsService_ListWorkflowRunArtifacts_notFound(t *testing.T) { t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Actions.ListWorkflowRunArtifacts return status %d, want %d", got, want) + t.Errorf("Actions.ListWorkflowRunArtifacts return status %v, want %v", got, want) } if artifacts != nil { t.Errorf("Actions.ListWorkflowRunArtifacts return %+v, want nil", artifacts) @@ -263,7 +263,7 @@ func TestActionsService_GetArtifact_notFound(t *testing.T) { t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Actions.GetArtifact return status %d, want %d", got, want) + t.Errorf("Actions.GetArtifact return status %v, want %v", got, want) } if artifact != nil { t.Errorf("Actions.GetArtifact return %+v, want nil", artifact) @@ -304,12 +304,12 @@ func TestActionsService_DownloadArtifact(t *testing.T) { t.Errorf("Actions.DownloadArtifact returned error: %v", err) } if resp.StatusCode != http.StatusFound { - t.Errorf("Actions.DownloadArtifact returned status: %d, want %d", resp.StatusCode, http.StatusFound) + t.Errorf("Actions.DownloadArtifact returned status: %v, want %v", resp.StatusCode, http.StatusFound) } want := "https://github.com/artifact" if url.String() != want { - t.Errorf("Actions.DownloadArtifact returned %+v, want %+v", url.String(), want) + t.Errorf("Actions.DownloadArtifact returned %+v, want %+v", url, want) } const methodName = "DownloadArtifact" @@ -420,7 +420,7 @@ func TestActionsService_DownloadArtifact_StatusMovedPermanently_dontFollowRedire ctx := t.Context() _, resp, _ := client.Actions.DownloadArtifact(ctx, "o", "r", 1, 0) if resp.StatusCode != http.StatusMovedPermanently { - t.Errorf("Actions.DownloadArtifact return status %d, want %d", resp.StatusCode, http.StatusMovedPermanently) + t.Errorf("Actions.DownloadArtifact return status %v, want %v", resp.StatusCode, http.StatusMovedPermanently) } }) } @@ -464,11 +464,11 @@ func TestActionsService_DownloadArtifact_StatusMovedPermanently_followRedirects( t.Errorf("Actions.DownloadArtifact return error: %v", err) } if resp.StatusCode != http.StatusFound { - t.Errorf("Actions.DownloadArtifact return status %d, want %d", resp.StatusCode, http.StatusFound) + t.Errorf("Actions.DownloadArtifact return status %v, want %v", resp.StatusCode, http.StatusFound) } want := "https://github.com/artifact" if url.String() != want { - t.Errorf("Actions.DownloadArtifact returned %+v, want %+v", url.String(), want) + t.Errorf("Actions.DownloadArtifact returned %+v, want %+v", url, want) } }) } @@ -515,7 +515,7 @@ func TestActionsService_DownloadArtifact_unexpectedCode(t *testing.T) { t.Error("Actions.DownloadArtifact should return unexpected status code") } if got, want := resp.Response.StatusCode, http.StatusNoContent; got != want { - t.Errorf("Actions.DownloadArtifact return status %d, want %d", got, want) + t.Errorf("Actions.DownloadArtifact return status %v, want %v", got, want) } if url != nil { t.Errorf("Actions.DownloadArtifact return %+v, want nil", url) @@ -582,7 +582,7 @@ func TestActionsService_DeleteArtifact_notFound(t *testing.T) { t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Actions.DeleteArtifact return status %d, want %d", got, want) + t.Errorf("Actions.DeleteArtifact return status %v, want %v", got, want) } } diff --git a/github/actions_cache_test.go b/github/actions_cache_test.go index 75a11a7bfae..ef3cd53fded 100644 --- a/github/actions_cache_test.go +++ b/github/actions_cache_test.go @@ -88,7 +88,7 @@ func TestActionsService_ListCaches_notFound(t *testing.T) { t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Actions.ListCaches return status %d, want %d", got, want) + t.Errorf("Actions.ListCaches return status %v, want %v", got, want) } if caches != nil { t.Errorf("Actions.ListCaches return %+v, want nil", caches) @@ -154,7 +154,7 @@ func TestActionsService_DeleteCachesByKey_notFound(t *testing.T) { t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Actions.DeleteCachesByKey return status %d, want %d", got, want) + t.Errorf("Actions.DeleteCachesByKey return status %v, want %v", got, want) } } @@ -216,7 +216,7 @@ func TestActionsService_DeleteCachesByID_notFound(t *testing.T) { t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Actions.DeleteCachesByID return status %d, want %d", got, want) + t.Errorf("Actions.DeleteCachesByID return status %v, want %v", got, want) } } @@ -294,7 +294,7 @@ func TestActionsService_GetCacheUsageForRepo_notFound(t *testing.T) { t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Actions.GetCacheUsageForRepo return status %d, want %d", got, want) + t.Errorf("Actions.GetCacheUsageForRepo return status %v, want %v", got, want) } if caches != nil { t.Errorf("Actions.GetCacheUsageForRepo return %+v, want nil", caches) @@ -367,7 +367,7 @@ func TestActionsService_ListCacheUsageByRepoForOrg_notFound(t *testing.T) { t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Actions.ListCacheUsageByRepoForOrg return status %d, want %d", got, want) + t.Errorf("Actions.ListCacheUsageByRepoForOrg return status %v, want %v", got, want) } if caches != nil { t.Errorf("Actions.ListCacheUsageByRepoForOrg return %+v, want nil", caches) @@ -438,7 +438,7 @@ func TestActionsService_GetCacheUsageForOrg_notFound(t *testing.T) { t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Actions.GetTotalCacheUsageForOrg return status %d, want %d", got, want) + t.Errorf("Actions.GetTotalCacheUsageForOrg return status %v, want %v", got, want) } if caches != nil { t.Errorf("Actions.GetTotalCacheUsageForOrg return %+v, want nil", caches) @@ -509,7 +509,7 @@ func TestActionsService_GetCacheUsageForEnterprise_notFound(t *testing.T) { t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Actions.GetTotalCacheUsageForEnterprise return status %d, want %d", got, want) + t.Errorf("Actions.GetTotalCacheUsageForEnterprise return status %v, want %v", got, want) } if caches != nil { t.Errorf("Actions.GetTotalCacheUsageForEnterprise return %+v, want nil", caches) diff --git a/github/actions_permissions_enterprise_test.go b/github/actions_permissions_enterprise_test.go index b27cfcc6122..53ef67149ed 100644 --- a/github/actions_permissions_enterprise_test.go +++ b/github/actions_permissions_enterprise_test.go @@ -437,7 +437,7 @@ func TestActionsService_UpdateArtifactAndLogRetentionPeriodInEnterprise(t *testi } if resp.StatusCode != http.StatusNoContent { - t.Errorf("Actions.UpdateArtifactAndLogRetentionPeriodInEnterprise = %d, want %d", resp.StatusCode, http.StatusNoContent) + t.Errorf("Actions.UpdateArtifactAndLogRetentionPeriodInEnterprise = %v, want %v", resp.StatusCode, http.StatusNoContent) } const methodName = "UpdateArtifactAndLogRetentionPeriodInEnterprise" @@ -509,7 +509,7 @@ func TestActionsService_UpdateSelfHostedRunnerPermissionsInEnterprise(t *testing } if resp.StatusCode != http.StatusNoContent { - t.Errorf("Actions.UpdateSelfHostedRunnerPermissionsInEnterprise = %d, want %d", resp.StatusCode, http.StatusNoContent) + t.Errorf("Actions.UpdateSelfHostedRunnerPermissionsInEnterprise = %v, want %v", resp.StatusCode, http.StatusNoContent) } const methodName = "UpdateSelfHostedRunnerPermissionsInEnterprise" @@ -590,7 +590,7 @@ func TestActionsService_UpdatePrivateRepoForkPRWorkflowSettingsInEnterprise(t *t } if resp.StatusCode != http.StatusNoContent { - t.Errorf("Actions.UpdatePrivateRepoForkPRWorkflowSettingsInEnterprise = %d, want %d", resp.StatusCode, http.StatusNoContent) + t.Errorf("Actions.UpdatePrivateRepoForkPRWorkflowSettingsInEnterprise = %v, want %v", resp.StatusCode, http.StatusNoContent) } const methodName = "UpdatePrivateRepoForkPRWorkflowSettingsInEnterprise" diff --git a/github/actions_permissions_orgs_test.go b/github/actions_permissions_orgs_test.go index 818715c919d..2a0ac0ad02b 100644 --- a/github/actions_permissions_orgs_test.go +++ b/github/actions_permissions_orgs_test.go @@ -477,7 +477,7 @@ func TestActionsService_UpdateArtifactAndLogRetentionPeriodInOrganization(t *tes } if resp.StatusCode != http.StatusNoContent { - t.Errorf("Actions.UpdateArtifactAndLogRetentionPeriodInOrganization = %d, want %d", resp.StatusCode, http.StatusNoContent) + t.Errorf("Actions.UpdateArtifactAndLogRetentionPeriodInOrganization = %v, want %v", resp.StatusCode, http.StatusNoContent) } const methodName = "UpdateArtifactAndLogRetentionPeriodInOrganization" @@ -552,7 +552,7 @@ func TestActionsService_UpdateSelfHostedRunnersSettingsInOrganization(t *testing } if resp.StatusCode != http.StatusNoContent { - t.Errorf("Actions.UpdateSelfHostedRunnersSettingsInOrganization = %d, want %d", resp.StatusCode, http.StatusNoContent) + t.Errorf("Actions.UpdateSelfHostedRunnersSettingsInOrganization = %v, want %v", resp.StatusCode, http.StatusNoContent) } const methodName = "UpdateSelfHostedRunnersSettingsInOrganization" @@ -760,7 +760,7 @@ func TestActionsService_UpdatePrivateRepoForkPRWorkflowSettingsInOrganization(t } if resp.StatusCode != http.StatusNoContent { - t.Errorf("Actions.UpdatePrivateRepoForkPRWorkflowSettingsInOrganization = %d, want %d", resp.StatusCode, http.StatusNoContent) + t.Errorf("Actions.UpdatePrivateRepoForkPRWorkflowSettingsInOrganization = %v, want %v", resp.StatusCode, http.StatusNoContent) } const methodName = "UpdatePrivateRepoForkPRWorkflowSettingsInOrganization" diff --git a/github/actions_variables_test.go b/github/actions_variables_test.go index 419472558b8..688a77beb07 100644 --- a/github/actions_variables_test.go +++ b/github/actions_variables_test.go @@ -745,8 +745,8 @@ func TestActionVariable_Marshal(t *testing.T) { want := fmt.Sprintf(`{ "name": "n", "value": "v", - "created_at": %s, - "updated_at": %s, + "created_at": %v, + "updated_at": %v, "visibility": "v", "selected_repositories_url": "s", "selected_repository_ids": [1,2,3] diff --git a/github/actions_workflow_jobs.go b/github/actions_workflow_jobs.go index 10067c8b260..dabc809170a 100644 --- a/github/actions_workflow_jobs.go +++ b/github/actions_workflow_jobs.go @@ -74,7 +74,7 @@ type ListWorkflowJobsOptions struct { // //meta:operation GET /repos/{owner}/{repo}/actions/runs/{run_id}/jobs func (s *ActionsService) ListWorkflowJobs(ctx context.Context, owner, repo string, runID int64, opts *ListWorkflowJobsOptions) (*Jobs, *Response, error) { - u := fmt.Sprintf("repos/%s/%s/actions/runs/%v/jobs", owner, repo, runID) + u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/jobs", owner, repo, runID) u, err := addOptions(u, opts) if err != nil { return nil, nil, err @@ -100,7 +100,7 @@ func (s *ActionsService) ListWorkflowJobs(ctx context.Context, owner, repo strin // //meta:operation GET /repos/{owner}/{repo}/actions/runs/{run_id}/attempts/{attempt_number}/jobs func (s *ActionsService) ListWorkflowJobsAttempt(ctx context.Context, owner, repo string, runID, attemptNumber int64, opts *ListOptions) (*Jobs, *Response, error) { - u := fmt.Sprintf("repos/%s/%s/actions/runs/%v/attempts/%v/jobs", owner, repo, runID, attemptNumber) + u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/attempts/%v/jobs", owner, repo, runID, attemptNumber) u, err := addOptions(u, opts) if err != nil { return nil, nil, err diff --git a/github/actions_workflow_jobs_test.go b/github/actions_workflow_jobs_test.go index 9be9df8f3fe..c20fec965f8 100644 --- a/github/actions_workflow_jobs_test.go +++ b/github/actions_workflow_jobs_test.go @@ -215,11 +215,11 @@ func TestActionsService_GetWorkflowJobLogs(t *testing.T) { t.Errorf("Actions.GetWorkflowJobLogs returned error: %v", err) } if resp.StatusCode != http.StatusFound { - t.Errorf("Actions.GetWorkflowJobLogs returned status: %d, want %d", resp.StatusCode, http.StatusFound) + t.Errorf("Actions.GetWorkflowJobLogs returned status: %v, want %v", resp.StatusCode, http.StatusFound) } want := "https://github.com/a" if url.String() != want { - t.Errorf("Actions.GetWorkflowJobLogs returned %+v, want %+v", url.String(), want) + t.Errorf("Actions.GetWorkflowJobLogs returned %+v, want %+v", url, want) } const methodName = "GetWorkflowJobLogs" @@ -272,7 +272,7 @@ func TestActionsService_GetWorkflowJobLogs_StatusMovedPermanently_dontFollowRedi ctx := t.Context() _, resp, _ := client.Actions.GetWorkflowJobLogs(ctx, "o", "r", 399444496, 0) if resp.StatusCode != http.StatusMovedPermanently { - t.Errorf("Actions.GetWorkflowJobLogs returned status: %d, want %d", resp.StatusCode, http.StatusMovedPermanently) + t.Errorf("Actions.GetWorkflowJobLogs returned status: %v, want %v", resp.StatusCode, http.StatusMovedPermanently) } }) } @@ -319,12 +319,12 @@ func TestActionsService_GetWorkflowJobLogs_StatusMovedPermanently_followRedirect } if resp.StatusCode != http.StatusFound { - t.Errorf("Actions.GetWorkflowJobLogs returned status: %d, want %d", resp.StatusCode, http.StatusFound) + t.Errorf("Actions.GetWorkflowJobLogs returned status: %v, want %v", resp.StatusCode, http.StatusFound) } want := "https://github.com/a" if url.String() != want { - t.Errorf("Actions.GetWorkflowJobLogs returned %+v, want %+v", url.String(), want) + t.Errorf("Actions.GetWorkflowJobLogs returned %+v, want %+v", url, want) } }) } @@ -373,7 +373,7 @@ func TestActionsService_GetWorkflowJobLogs_unexpectedCode(t *testing.T) { t.Error("Actions.GetWorkflowJobLogs should return unexpected status code") } if got, want := resp.Response.StatusCode, http.StatusNoContent; got != want { - t.Errorf("Actions.GetWorkflowJobLogs return status %d, want %d", got, want) + t.Errorf("Actions.GetWorkflowJobLogs return status %v, want %v", got, want) } if url != nil { t.Errorf("Actions.GetWorkflowJobLogs return %+v, want nil", url) diff --git a/github/actions_workflow_runs.go b/github/actions_workflow_runs.go index 2e20f1be36f..5306b39c3df 100644 --- a/github/actions_workflow_runs.go +++ b/github/actions_workflow_runs.go @@ -164,7 +164,7 @@ func (s *ActionsService) listWorkflowRuns(ctx context.Context, endpoint string, // //meta:operation GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs func (s *ActionsService) ListWorkflowRunsByID(ctx context.Context, owner, repo string, workflowID int64, opts *ListWorkflowRunsOptions) (*WorkflowRuns, *Response, error) { - u := fmt.Sprintf("repos/%s/%s/actions/workflows/%v/runs", owner, repo, workflowID) + u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/runs", owner, repo, workflowID) return s.listWorkflowRuns(ctx, u, opts) } @@ -174,7 +174,7 @@ func (s *ActionsService) ListWorkflowRunsByID(ctx context.Context, owner, repo s // //meta:operation GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs func (s *ActionsService) ListWorkflowRunsByFileName(ctx context.Context, owner, repo, workflowFileName string, opts *ListWorkflowRunsOptions) (*WorkflowRuns, *Response, error) { - u := fmt.Sprintf("repos/%s/%s/actions/workflows/%v/runs", owner, repo, workflowFileName) + u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/runs", owner, repo, workflowFileName) return s.listWorkflowRuns(ctx, u, opts) } @@ -184,7 +184,7 @@ func (s *ActionsService) ListWorkflowRunsByFileName(ctx context.Context, owner, // //meta:operation GET /repos/{owner}/{repo}/actions/runs func (s *ActionsService) ListRepositoryWorkflowRuns(ctx context.Context, owner, repo string, opts *ListWorkflowRunsOptions) (*WorkflowRuns, *Response, error) { - u := fmt.Sprintf("repos/%s/%s/actions/runs", owner, repo) + u := fmt.Sprintf("repos/%v/%v/actions/runs", owner, repo) u, err := addOptions(u, opts) if err != nil { return nil, nil, err @@ -398,7 +398,7 @@ func (s *ActionsService) getWorkflowRunLogsWithoutRateLimit(ctx context.Context, defer resp.Body.Close() if resp.StatusCode != http.StatusFound { - return nil, newResponse(resp), fmt.Errorf("unexpected status code: %s", resp.Status) + return nil, newResponse(resp), fmt.Errorf("unexpected status code: %v", resp.Status) } parsedURL, err := url.Parse(resp.Header.Get("Location")) diff --git a/github/actions_workflow_runs_test.go b/github/actions_workflow_runs_test.go index cf2146aa49d..41a0a14be53 100644 --- a/github/actions_workflow_runs_test.go +++ b/github/actions_workflow_runs_test.go @@ -222,11 +222,11 @@ func TestActionsService_GetWorkflowRunAttemptLogs(t *testing.T) { t.Errorf("Actions.GetWorkflowRunAttemptLogs returned error: %v", err) } if resp.StatusCode != http.StatusFound { - t.Errorf("Actions.GetWorkflowRunAttemptLogs returned status: %d, want %d", resp.StatusCode, http.StatusFound) + t.Errorf("Actions.GetWorkflowRunAttemptLogs returned status: %v, want %v", resp.StatusCode, http.StatusFound) } want := "https://github.com/a" if url.String() != want { - t.Errorf("Actions.GetWorkflowRunAttemptLogs returned %+v, want %+v", url.String(), want) + t.Errorf("Actions.GetWorkflowRunAttemptLogs returned %+v, want %+v", url, want) } const methodName = "GetWorkflowRunAttemptLogs" @@ -268,7 +268,7 @@ func TestActionsService_GetWorkflowRunAttemptLogs_StatusMovedPermanently_dontFol ctx := t.Context() _, resp, _ := client.Actions.GetWorkflowRunAttemptLogs(ctx, "o", "r", 399444496, 2, 0) if resp.StatusCode != http.StatusMovedPermanently { - t.Errorf("Actions.GetWorkflowRunAttemptLogs returned status: %d, want %d", resp.StatusCode, http.StatusMovedPermanently) + t.Errorf("Actions.GetWorkflowRunAttemptLogs returned status: %v, want %v", resp.StatusCode, http.StatusMovedPermanently) } }) } @@ -315,12 +315,12 @@ func TestActionsService_GetWorkflowRunAttemptLogs_StatusMovedPermanently_followR } if resp.StatusCode != http.StatusFound { - t.Errorf("Actions.GetWorkflowRunAttemptLogs returned status: %d, want %d", resp.StatusCode, http.StatusFound) + t.Errorf("Actions.GetWorkflowRunAttemptLogs returned status: %v, want %v", resp.StatusCode, http.StatusFound) } want := "https://github.com/a" if url.String() != want { - t.Errorf("Actions.GetWorkflowRunAttemptLogs returned %+v, want %+v", url.String(), want) + t.Errorf("Actions.GetWorkflowRunAttemptLogs returned %+v, want %+v", url, want) } const methodName = "GetWorkflowRunAttemptLogs" @@ -375,7 +375,7 @@ func TestActionsService_GetWorkflowRunAttemptLogs_unexpectedCode(t *testing.T) { t.Error("Actions.GetWorkflowRunAttemptLogs should return unexpected status code") } if got, want := resp.Response.StatusCode, http.StatusNoContent; got != want { - t.Errorf("Actions.GetWorkflowRunAttemptLogs return status %d, want %d", got, want) + t.Errorf("Actions.GetWorkflowRunAttemptLogs return status %v, want %v", got, want) } if url != nil { t.Errorf("Actions.GetWorkflowRunAttemptLogs return %+v, want nil", url) @@ -399,7 +399,7 @@ func TestActionsService_RerunWorkflowRunByID(t *testing.T) { t.Errorf("Actions.RerunWorkflowByID returned error: %v", err) } if resp.StatusCode != http.StatusCreated { - t.Errorf("Actions.RerunWorkflowRunByID returned status: %d, want %d", resp.StatusCode, http.StatusCreated) + t.Errorf("Actions.RerunWorkflowRunByID returned status: %v, want %v", resp.StatusCode, http.StatusCreated) } const methodName = "RerunWorkflowByID" @@ -428,7 +428,7 @@ func TestActionsService_RerunFailedJobsByID(t *testing.T) { t.Errorf("Actions.RerunFailedJobsByID returned error: %v", err) } if resp.StatusCode != http.StatusCreated { - t.Errorf("Actions.RerunFailedJobsByID returned status: %d, want %d", resp.StatusCode, http.StatusCreated) + t.Errorf("Actions.RerunFailedJobsByID returned status: %v, want %v", resp.StatusCode, http.StatusCreated) } const methodName = "RerunFailedJobsByID" @@ -457,7 +457,7 @@ func TestActionsService_RerunJobByID(t *testing.T) { t.Errorf("Actions.RerunJobByID returned error: %v", err) } if resp.StatusCode != http.StatusCreated { - t.Errorf("Actions.RerunJobByID returned status: %d, want %d", resp.StatusCode, http.StatusCreated) + t.Errorf("Actions.RerunJobByID returned status: %v, want %v", resp.StatusCode, http.StatusCreated) } const methodName = "RerunJobByID" @@ -486,7 +486,7 @@ func TestActionsService_CancelWorkflowRunByID(t *testing.T) { t.Errorf("Actions.CancelWorkflowRunByID returned error: %v (want AcceptedError)", err) } if resp.StatusCode != http.StatusAccepted { - t.Errorf("Actions.CancelWorkflowRunByID returned status: %d, want %d", resp.StatusCode, http.StatusAccepted) + t.Errorf("Actions.CancelWorkflowRunByID returned status: %v, want %v", resp.StatusCode, http.StatusAccepted) } const methodName = "CancelWorkflowRunByID" @@ -533,11 +533,11 @@ func TestActionsService_GetWorkflowRunLogs(t *testing.T) { t.Errorf("Actions.GetWorkflowRunLogs returned error: %v", err) } if resp.StatusCode != http.StatusFound { - t.Errorf("Actions.GetWorkflowRunLogs returned status: %d, want %d", resp.StatusCode, http.StatusFound) + t.Errorf("Actions.GetWorkflowRunLogs returned status: %v, want %v", resp.StatusCode, http.StatusFound) } want := "https://github.com/a" if url.String() != want { - t.Errorf("Actions.GetWorkflowRunLogs returned %+v, want %+v", url.String(), want) + t.Errorf("Actions.GetWorkflowRunLogs returned %+v, want %+v", url, want) } const methodName = "GetWorkflowRunLogs" @@ -579,7 +579,7 @@ func TestActionsService_GetWorkflowRunLogs_StatusMovedPermanently_dontFollowRedi ctx := t.Context() _, resp, _ := client.Actions.GetWorkflowRunLogs(ctx, "o", "r", 399444496, 0) if resp.StatusCode != http.StatusMovedPermanently { - t.Errorf("Actions.GetWorkflowJobLogs returned status: %d, want %d", resp.StatusCode, http.StatusMovedPermanently) + t.Errorf("Actions.GetWorkflowJobLogs returned status: %v, want %v", resp.StatusCode, http.StatusMovedPermanently) } }) } @@ -626,12 +626,12 @@ func TestActionsService_GetWorkflowRunLogs_StatusMovedPermanently_followRedirect } if resp.StatusCode != http.StatusFound { - t.Errorf("Actions.GetWorkflowJobLogs returned status: %d, want %d", resp.StatusCode, http.StatusFound) + t.Errorf("Actions.GetWorkflowJobLogs returned status: %v, want %v", resp.StatusCode, http.StatusFound) } want := "https://github.com/a" if url.String() != want { - t.Errorf("Actions.GetWorkflowJobLogs returned %+v, want %+v", url.String(), want) + t.Errorf("Actions.GetWorkflowJobLogs returned %+v, want %+v", url, want) } const methodName = "GetWorkflowRunLogs" @@ -686,7 +686,7 @@ func TestActionsService_GetWorkflowRunLogs_unexpectedCode(t *testing.T) { t.Error("Actions.GetWorkflowRunLogs should return unexpected status code") } if got, want := resp.Response.StatusCode, http.StatusNoContent; got != want { - t.Errorf("Actions.GetWorkflowRunLogs return status %d, want %d", got, want) + t.Errorf("Actions.GetWorkflowRunLogs return status %v, want %v", got, want) } if url != nil { t.Errorf("Actions.GetWorkflowRunLogs return %+v, want nil", url) diff --git a/github/actions_workflows.go b/github/actions_workflows.go index dbde83cf306..ff82b4c30ed 100644 --- a/github/actions_workflows.go +++ b/github/actions_workflows.go @@ -82,7 +82,7 @@ type WorkflowsPermissionsOpt struct { // //meta:operation GET /repos/{owner}/{repo}/actions/workflows func (s *ActionsService) ListWorkflows(ctx context.Context, owner, repo string, opts *ListOptions) (*Workflows, *Response, error) { - u := fmt.Sprintf("repos/%s/%s/actions/workflows", owner, repo) + u := fmt.Sprintf("repos/%v/%v/actions/workflows", owner, repo) u, err := addOptions(u, opts) if err != nil { return nil, nil, err diff --git a/github/activity_star.go b/github/activity_star.go index 782c09884d2..bdd27c3d8db 100644 --- a/github/activity_star.go +++ b/github/activity_star.go @@ -29,7 +29,7 @@ type Stargazer struct { // //meta:operation GET /repos/{owner}/{repo}/stargazers func (s *ActivityService) ListStargazers(ctx context.Context, owner, repo string, opts *ListOptions) ([]*Stargazer, *Response, error) { - u := fmt.Sprintf("repos/%s/%s/stargazers", owner, repo) + u := fmt.Sprintf("repos/%v/%v/stargazers", owner, repo) u, err := addOptions(u, opts) if err != nil { return nil, nil, err diff --git a/github/activity_watching.go b/github/activity_watching.go index 348590057b9..61429177862 100644 --- a/github/activity_watching.go +++ b/github/activity_watching.go @@ -31,7 +31,7 @@ type Subscription struct { // //meta:operation GET /repos/{owner}/{repo}/subscribers func (s *ActivityService) ListWatchers(ctx context.Context, owner, repo string, opts *ListOptions) ([]*User, *Response, error) { - u := fmt.Sprintf("repos/%s/%s/subscribers", owner, repo) + u := fmt.Sprintf("repos/%v/%v/subscribers", owner, repo) u, err := addOptions(u, opts) if err != nil { return nil, nil, err @@ -93,7 +93,7 @@ func (s *ActivityService) ListWatched(ctx context.Context, user string, opts *Li // //meta:operation GET /repos/{owner}/{repo}/subscription func (s *ActivityService) GetRepositorySubscription(ctx context.Context, owner, repo string) (*Subscription, *Response, error) { - u := fmt.Sprintf("repos/%s/%s/subscription", owner, repo) + u := fmt.Sprintf("repos/%v/%v/subscription", owner, repo) req, err := s.client.NewRequest("GET", u, nil) if err != nil { @@ -122,7 +122,7 @@ func (s *ActivityService) GetRepositorySubscription(ctx context.Context, owner, // //meta:operation PUT /repos/{owner}/{repo}/subscription func (s *ActivityService) SetRepositorySubscription(ctx context.Context, owner, repo string, subscription *Subscription) (*Subscription, *Response, error) { - u := fmt.Sprintf("repos/%s/%s/subscription", owner, repo) + u := fmt.Sprintf("repos/%v/%v/subscription", owner, repo) req, err := s.client.NewRequest("PUT", u, subscription) if err != nil { @@ -148,7 +148,7 @@ func (s *ActivityService) SetRepositorySubscription(ctx context.Context, owner, // //meta:operation DELETE /repos/{owner}/{repo}/subscription func (s *ActivityService) DeleteRepositorySubscription(ctx context.Context, owner, repo string) (*Response, error) { - u := fmt.Sprintf("repos/%s/%s/subscription", owner, repo) + u := fmt.Sprintf("repos/%v/%v/subscription", owner, repo) req, err := s.client.NewRequest("DELETE", u, nil) if err != nil { return nil, err diff --git a/github/admin_users.go b/github/admin_users.go index 843a177be96..e49a4b59dee 100644 --- a/github/admin_users.go +++ b/github/admin_users.go @@ -99,7 +99,7 @@ type UserAuthorization struct { // //meta:operation POST /admin/users/{username}/authorizations func (s *AdminService) CreateUserImpersonation(ctx context.Context, username string, opts *ImpersonateUserOptions) (*UserAuthorization, *Response, error) { - u := fmt.Sprintf("admin/users/%s/authorizations", username) + u := fmt.Sprintf("admin/users/%v/authorizations", username) req, err := s.client.NewRequest("POST", u, opts) if err != nil { @@ -121,7 +121,7 @@ func (s *AdminService) CreateUserImpersonation(ctx context.Context, username str // //meta:operation DELETE /admin/users/{username}/authorizations func (s *AdminService) DeleteUserImpersonation(ctx context.Context, username string) (*Response, error) { - u := fmt.Sprintf("admin/users/%s/authorizations", username) + u := fmt.Sprintf("admin/users/%v/authorizations", username) req, err := s.client.NewRequest("DELETE", u, nil) if err != nil { diff --git a/github/apps.go b/github/apps.go index 1a9fb214434..8bd32d45761 100644 --- a/github/apps.go +++ b/github/apps.go @@ -470,7 +470,7 @@ func (s *AppsService) FindRepositoryInstallation(ctx context.Context, owner, rep // //meta:operation GET /repositories/{repository_id}/installation func (s *AppsService) FindRepositoryInstallationByID(ctx context.Context, id int64) (*Installation, *Response, error) { - return s.getInstallation(ctx, fmt.Sprintf("repositories/%d/installation", id)) + return s.getInstallation(ctx, fmt.Sprintf("repositories/%v/installation", id)) } // FindUserInstallation finds the user's installation information. diff --git a/github/apps_hooks_deliveries_test.go b/github/apps_hooks_deliveries_test.go index 6b055c38acc..483611544ec 100644 --- a/github/apps_hooks_deliveries_test.go +++ b/github/apps_hooks_deliveries_test.go @@ -34,7 +34,7 @@ func TestAppsService_ListHookDeliveries(t *testing.T) { want := []*HookDelivery{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}} if d := cmp.Diff(deliveries, want); d != "" { - t.Errorf("Apps.ListHooks want (-), got (+):\n%s", d) + t.Errorf("Apps.ListHooks want (-), got (+):\n%v", d) } const methodName = "ListHookDeliveries" diff --git a/github/apps_manifest.go b/github/apps_manifest.go index 5b6ff9af414..fdd8d7b1e7a 100644 --- a/github/apps_manifest.go +++ b/github/apps_manifest.go @@ -35,7 +35,7 @@ type AppConfig struct { // //meta:operation POST /app-manifests/{code}/conversions func (s *AppsService) CompleteAppManifest(ctx context.Context, code string) (*AppConfig, *Response, error) { - u := fmt.Sprintf("app-manifests/%s/conversions", code) + u := fmt.Sprintf("app-manifests/%v/conversions", code) req, err := s.client.NewRequest("POST", u, nil) if err != nil { return nil, nil, err diff --git a/github/checks_test.go b/github/checks_test.go index d3fb08b83ef..19cf35df2f0 100644 --- a/github/checks_test.go +++ b/github/checks_test.go @@ -742,8 +742,8 @@ func Test_CheckRunMarshal(t *testing.T) { "details_url": "u", "status": "s", "conclusion": "c", - "started_at": "%s", - "completed_at": "%s", + "started_at": "%v", + "completed_at": "%v", "output": { "title": "t", "summary": "s", @@ -789,8 +789,8 @@ func Test_CheckRunMarshal(t *testing.T) { "description": "d", "external_url": "u", "html_url": "h", - "created_at": "%s", - "updated_at": "%s" + "created_at": "%v", + "updated_at": "%v" }, "pull_requests": [ { @@ -920,8 +920,8 @@ func Test_CheckSuiteMarshal(t *testing.T) { "description": "d", "external_url": "u", "html_url": "h", - "created_at": "%s", - "updated_at": "%s" + "created_at": "%v", + "updated_at": "%v" }, "repository": { "id": 1 diff --git a/github/code_scanning.go b/github/code_scanning.go index 19a88241d37..982efc4597f 100644 --- a/github/code_scanning.go +++ b/github/code_scanning.go @@ -613,7 +613,7 @@ type DefaultSetupConfiguration struct { // //meta:operation GET /repos/{owner}/{repo}/code-scanning/default-setup func (s *CodeScanningService) GetDefaultSetupConfiguration(ctx context.Context, owner, repo string) (*DefaultSetupConfiguration, *Response, error) { - u := fmt.Sprintf("repos/%s/%s/code-scanning/default-setup", owner, repo) + u := fmt.Sprintf("repos/%v/%v/code-scanning/default-setup", owner, repo) req, err := s.client.NewRequest("GET", u, nil) if err != nil { @@ -656,7 +656,7 @@ type UpdateDefaultSetupConfigurationResponse struct { // //meta:operation PATCH /repos/{owner}/{repo}/code-scanning/default-setup func (s *CodeScanningService) UpdateDefaultSetupConfiguration(ctx context.Context, owner, repo string, options *UpdateDefaultSetupConfigurationOptions) (*UpdateDefaultSetupConfigurationResponse, *Response, error) { - u := fmt.Sprintf("repos/%s/%s/code-scanning/default-setup", owner, repo) + u := fmt.Sprintf("repos/%v/%v/code-scanning/default-setup", owner, repo) req, err := s.client.NewRequest("PATCH", u, options) if err != nil { diff --git a/github/codesofconduct.go b/github/codesofconduct.go index aba05741713..159340e0a74 100644 --- a/github/codesofconduct.go +++ b/github/codesofconduct.go @@ -61,7 +61,7 @@ func (c *Client) ListCodesOfConduct(ctx context.Context) ([]*CodeOfConduct, *Res // //meta:operation GET /codes_of_conduct/{key} func (s *CodesOfConductService) Get(ctx context.Context, key string) (*CodeOfConduct, *Response, error) { - u := fmt.Sprintf("codes_of_conduct/%s", key) + u := fmt.Sprintf("codes_of_conduct/%v", key) req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, nil, err diff --git a/github/enterprise_network_configurations_test.go b/github/enterprise_network_configurations_test.go index eb91a18397c..ad3b4b7b2fc 100644 --- a/github/enterprise_network_configurations_test.go +++ b/github/enterprise_network_configurations_test.go @@ -76,7 +76,7 @@ func TestEnterpriseService_ListEnterpriseNetworkConfigurations(t *testing.T) { }, } if !cmp.Equal(configurations, want) { - t.Errorf("Enterprise.ListEnterpriseNetworkConfigurations mismatch (-want +got):\n%s", cmp.Diff(want, configurations)) + t.Errorf("Enterprise.ListEnterpriseNetworkConfigurations mismatch (-want +got):\n%v", cmp.Diff(want, configurations)) } const methodName = "ListEnterpriseNetworkConfigurations" @@ -133,7 +133,7 @@ func TestEnterpriseService_CreateEnterpriseNetworkConfiguration(t *testing.T) { CreatedOn: &Timestamp{time.Date(2024, 4, 9, 17, 30, 15, 0, time.UTC)}, } if !cmp.Equal(configuration, want) { - t.Errorf("Enterprise.CreateEnterpriseNetworkConfiguration mismatch (-want +got):\n%s", cmp.Diff(want, configuration)) + t.Errorf("Enterprise.CreateEnterpriseNetworkConfiguration mismatch (-want +got):\n%v", cmp.Diff(want, configuration)) } validationTest := []struct { @@ -220,7 +220,7 @@ func TestEnterpriseService_GetEnterpriseNetworkConfiguration(t *testing.T) { CreatedOn: &Timestamp{time.Date(2024, 12, 10, 19, 0, 15, 0, time.UTC)}, } if !cmp.Equal(configuration, want) { - t.Errorf("Enterprise.GetEnterpriseNetworkConfiguration mismatch (-want +got):\n%s", cmp.Diff(want, configuration)) + t.Errorf("Enterprise.GetEnterpriseNetworkConfiguration mismatch (-want +got):\n%v", cmp.Diff(want, configuration)) } const methodName = "GetEnterpriseNetworkConfiguration" @@ -276,7 +276,7 @@ func TestEnterpriseService_UpdateEnterpriseNetworkConfiguration(t *testing.T) { CreatedOn: &Timestamp{time.Date(2024, 12, 10, 19, 0, 15, 0, time.UTC)}, } if !cmp.Equal(configuration, want) { - t.Errorf("Enterprise.UpdateEnterpriseNetworkConfiguration mismatch (-want +get)\n%s", cmp.Diff(want, configuration)) + t.Errorf("Enterprise.UpdateEnterpriseNetworkConfiguration mismatch (-want +get)\n%v", cmp.Diff(want, configuration)) } validationTest := []struct { @@ -385,7 +385,7 @@ func TestEnterpriseService_GetEnterpriseNetworkSettingsResource(t *testing.T) { Region: Ptr("germanywestcentral"), } if !cmp.Equal(resource, want) { - t.Errorf("Enterprise.GetEnterpriseNetworkSettingsResource mistach (-want +got):\n%s", cmp.Diff(want, resource)) + t.Errorf("Enterprise.GetEnterpriseNetworkSettingsResource mistach (-want +got):\n%v", cmp.Diff(want, resource)) } const methodName = "GetEnterpriseNetworkSettingsResource" diff --git a/github/examples_test.go b/github/examples_test.go index 603ba34cf43..b1c6f67e229 100644 --- a/github/examples_test.go +++ b/github/examples_test.go @@ -135,7 +135,7 @@ func ExamplePullRequestsService_Create() { return } - fmt.Printf("PR created: %s\n", pr.GetHTMLURL()) + fmt.Printf("PR created: %v\n", pr.GetHTMLURL()) } func ExampleTeamsService_ListTeams() { @@ -161,7 +161,7 @@ func ExampleTeamsService_ListTeams() { } for _, t := range teams { if t.GetName() == teamName { - fmt.Printf("Team %q has ID %d\n", teamName, t.GetID()) + fmt.Printf("Team %q has ID %v\n", teamName, t.GetID()) return } } diff --git a/github/gen-stringify-test.go b/github/gen-stringify-test.go index f4aee63eee2..3eefe8b84ed 100644 --- a/github/gen-stringify-test.go +++ b/github/gen-stringify-test.go @@ -192,7 +192,7 @@ func (t *templateData) processAST(f *ast.File) error { } st, ok := ts.Type.(*ast.StructType) if !ok { - logf("Ignoring AST type %T, Name=%q", ts.Type, ts.Name.String()) + logf("Ignoring AST type %T, Name=%q", ts.Type, ts.Name) continue } for _, field := range st.Fields.List { @@ -215,7 +215,7 @@ func (t *templateData) processAST(f *ast.File) error { se, ok := field.Type.(*ast.StarExpr) if !ok { - logf("Ignoring type %T for Name=%q, FieldName=%q", field.Type, ts.Name.String(), fieldName.String()) + logf("Ignoring type %T for Name=%q, FieldName=%q", field.Type, ts.Name, fieldName) continue } @@ -349,7 +349,7 @@ func (t *templateData) dump() error { } clean, err := format.Source(buf.Bytes()) if err != nil { - log.Printf("failed-to-format source:\n%v", buf.String()) + log.Printf("failed-to-format source:\n%v", buf) return err } diff --git a/github/git_commits.go b/github/git_commits.go index 4da15bb0d1d..5bf6cf7aa9b 100644 --- a/github/git_commits.go +++ b/github/git_commits.go @@ -202,14 +202,14 @@ func createSignatureMessage(commit *createCommit) (string, error) { var message []string if commit.Tree != nil { - message = append(message, fmt.Sprintf("tree %s", *commit.Tree)) + message = append(message, fmt.Sprintf("tree %v", *commit.Tree)) } for _, parent := range commit.Parents { - message = append(message, fmt.Sprintf("parent %s", parent)) + message = append(message, fmt.Sprintf("parent %v", parent)) } - message = append(message, fmt.Sprintf("author %s <%s> %d %s", commit.Author.GetName(), commit.Author.GetEmail(), commit.Author.GetDate().Unix(), commit.Author.GetDate().Format("-0700"))) + message = append(message, fmt.Sprintf("author %v <%v> %v %v", commit.Author.GetName(), commit.Author.GetEmail(), commit.Author.GetDate().Unix(), commit.Author.GetDate().Format("-0700"))) committer := commit.Committer if committer == nil { @@ -217,7 +217,7 @@ func createSignatureMessage(commit *createCommit) (string, error) { } // There needs to be a double newline after committer - message = append(message, fmt.Sprintf("committer %s <%s> %d %s\n", committer.GetName(), committer.GetEmail(), committer.GetDate().Unix(), committer.GetDate().Format("-0700"))) + message = append(message, fmt.Sprintf("committer %v <%v> %v %v\n", committer.GetName(), committer.GetEmail(), committer.GetDate().Unix(), committer.GetDate().Format("-0700"))) message = append(message, *commit.Message) return strings.Join(message, "\n"), nil diff --git a/github/git_commits_test.go b/github/git_commits_test.go index 0ba7d396211..95f81d61c7a 100644 --- a/github/git_commits_test.go +++ b/github/git_commits_test.go @@ -333,7 +333,7 @@ Commit Message.` mux.HandleFunc("/repos/o/r/git/commits", func(w http.ResponseWriter, r *http.Request) { assertNilError(t, json.NewDecoder(r.Body).Decode(&gotBody)) testMethod(t, r, "POST") - fmt.Fprintf(w, `{"sha":"%s"}`, sha) + fmt.Fprintf(w, `{"sha":"%v"}`, sha) }) ctx := t.Context() wantCommit := &Commit{SHA: Ptr(sha)} @@ -341,10 +341,10 @@ Commit Message.` commit, _, err := client.Git.CreateCommit(ctx, "o", "r", input, &opts) assertNilError(t, err) if cmp.Diff(gotBody, wantBody) != "" { - t.Errorf("Request body = %+v, want %+v\n%s", gotBody, wantBody, cmp.Diff(gotBody, wantBody)) + t.Errorf("Request body = %+v, want %+v\n%v", gotBody, wantBody, cmp.Diff(gotBody, wantBody)) } if cmp.Diff(commit, wantCommit) != "" { - t.Errorf("Git.CreateCommit returned %+v, want %+v\n%s", commit, wantCommit, cmp.Diff(commit, wantCommit)) + t.Errorf("Git.CreateCommit returned %+v, want %+v\n%v", commit, wantCommit, cmp.Diff(commit, wantCommit)) } } @@ -464,7 +464,7 @@ committer go-github 1493849023 +0200 Commit Message.` if msg != expected { - t.Errorf("Returned message incorrect. returned %s, want %s", msg, expected) + t.Errorf("Returned message incorrect. returned %v, want %v", msg, expected) } } @@ -492,7 +492,7 @@ committer foo 1493849023 +0200 Commit Message.` if msg != expected { - t.Errorf("Returned message incorrect. returned %s, want %s", msg, expected) + t.Errorf("Returned message incorrect. returned %v, want %v", msg, expected) } } diff --git a/github/git_refs_test.go b/github/git_refs_test.go index d0102470133..86dca48039c 100644 --- a/github/git_refs_test.go +++ b/github/git_refs_test.go @@ -87,7 +87,7 @@ func TestGitService_GetRef_noRefs(t *testing.T) { t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Git.GetRef returned status %d, want %d", got, want) + t.Errorf("Git.GetRef returned status %v, want %v", got, want) } if ref != nil { t.Errorf("Git.GetRef return %+v, want nil", ref) diff --git a/github/git_trees_test.go b/github/git_trees_test.go index 52ce5d8123f..54015739f24 100644 --- a/github/git_trees_test.go +++ b/github/git_trees_test.go @@ -32,7 +32,7 @@ func TestMarshalJSON_withNilContentAndSHA(t *testing.T) { want := `{"sha":null,"path":"path","mode":"mode","type":"type"}` if string(got) != want { - t.Errorf("MarshalJSON = %s, want %v", got, want) + t.Errorf("MarshalJSON = %v, want %v", got, want) } } @@ -115,7 +115,7 @@ func TestGitService_CreateTree(t *testing.T) { want := []byte(`{"base_tree":"b","tree":[{"sha":"7c258a9869f33c1e1e1f74fbb32f07c86cb5a75b","path":"file.rb","mode":"100644","type":"blob"}]}` + "\n") if !bytes.Equal(got, want) { - t.Errorf("Git.CreateTree request body: %s, want %s", got, want) + t.Errorf("Git.CreateTree request body: %v, want %v", got, want) } fmt.Fprint(w, `{ @@ -193,7 +193,7 @@ func TestGitService_CreateTree_Content(t *testing.T) { want := []byte(`{"base_tree":"b","tree":[{"path":"content.md","mode":"100644","content":"file content"}]}` + "\n") if !bytes.Equal(got, want) { - t.Errorf("Git.CreateTree request body: %s, want %s", got, want) + t.Errorf("Git.CreateTree request body: %v, want %v", got, want) } fmt.Fprint(w, `{ @@ -273,7 +273,7 @@ func TestGitService_CreateTree_Delete(t *testing.T) { want := []byte(`{"base_tree":"b","tree":[{"sha":null,"path":"content.md","mode":"100644"}]}` + "\n") if !bytes.Equal(got, want) { - t.Errorf("Git.CreateTree request body: %s, want %s", got, want) + t.Errorf("Git.CreateTree request body: %v, want %v", got, want) } fmt.Fprint(w, `{ diff --git a/github/github.go b/github/github.go index 02602142887..5a7488fc7e4 100644 --- a/github/github.go +++ b/github/github.go @@ -353,7 +353,7 @@ func (c *Client) WithAuthToken(token string) *Client { c2.client.Transport = roundTripperFunc( func(req *http.Request) (*http.Response, error) { req = req.Clone(req.Context()) - req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token)) + req.Header.Set("Authorization", fmt.Sprintf("Bearer %v", token)) return transport.RoundTrip(req) }, ) @@ -1169,13 +1169,13 @@ type ErrorBlock struct { func (r *ErrorResponse) Error() string { if r.Response != nil && r.Response.Request != nil { - return fmt.Sprintf("%v %v: %d %v %+v", + return fmt.Sprintf("%v %v: %v %v %+v", r.Response.Request.Method, sanitizeURL(r.Response.Request.URL), r.Response.StatusCode, r.Message, r.Errors) } if r.Response != nil { - return fmt.Sprintf("%d %v %+v", r.Response.StatusCode, r.Message, r.Errors) + return fmt.Sprintf("%v %v %+v", r.Response.StatusCode, r.Message, r.Errors) } return fmt.Sprintf("%v %+v", r.Message, r.Errors) @@ -1241,7 +1241,7 @@ type RateLimitError struct { } func (r *RateLimitError) Error() string { - return fmt.Sprintf("%v %v: %d %v %v", + return fmt.Sprintf("%v %v: %v %v %v", r.Response.Request.Method, sanitizeURL(r.Response.Request.URL), r.Response.StatusCode, r.Message, formatRateReset(time.Until(r.Rate.Reset.Time))) } @@ -1295,7 +1295,7 @@ type AbuseRateLimitError struct { } func (r *AbuseRateLimitError) Error() string { - return fmt.Sprintf("%v %v: %d %v", + return fmt.Sprintf("%v %v: %v %v", r.Response.Request.Method, sanitizeURL(r.Response.Request.URL), r.Response.StatusCode, r.Message) } @@ -1329,7 +1329,7 @@ type RedirectionError struct { } func (r *RedirectionError) Error() string { - return fmt.Sprintf("%v %v: %d location %v", + return fmt.Sprintf("%v %v: %v location %v", r.Response.Request.Method, sanitizeURL(r.Response.Request.URL), r.StatusCode, sanitizeURL(r.Location)) } @@ -1699,9 +1699,9 @@ func formatRateReset(d time.Duration) string { var timeString string if minutes > 0 { - timeString = fmt.Sprintf("%dm%02ds", minutes, seconds) + timeString = fmt.Sprintf("%vm%02ds", minutes, seconds) } else { - timeString = fmt.Sprintf("%ds", seconds) + timeString = fmt.Sprintf("%vs", seconds) } if isNegative { diff --git a/github/github_test.go b/github/github_test.go index a66f6d16b2c..71479fb78c1 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -157,7 +157,7 @@ func testBody(t *testing.T, r *http.Request, want string) { t.Errorf("Error reading request body: %v", err) } if got := string(b); got != want { - t.Errorf("request Body is %s, want %s", got, want) + t.Errorf("request Body is %v, want %v", got, want) } } @@ -183,7 +183,7 @@ func testJSONMarshal(t *testing.T, v any, want string) { } if diff := cmp.Diff(string(w), string(got)); diff != "" { - t.Errorf("json.Marshal returned:\n%s\nwant:\n%s\ndiff:\n%v", got, w, diff) + t.Errorf("json.Marshal returned:\n%v\nwant:\n%v\ndiff:\n%v", got, w, diff) } } @@ -504,10 +504,10 @@ func TestWithEnterpriseURLs(t *testing.T) { t.Fatalf("got unexpected error: %v", err) } if c.BaseURL.String() != test.wantBaseURL { - t.Errorf("BaseURL is %v, want %v", c.BaseURL.String(), test.wantBaseURL) + t.Errorf("BaseURL is %v, want %v", c.BaseURL, test.wantBaseURL) } if c.UploadURL.String() != test.wantUploadURL { - t.Errorf("UploadURL is %v, want %v", c.UploadURL.String(), test.wantUploadURL) + t.Errorf("UploadURL is %v, want %v", c.UploadURL, test.wantUploadURL) } } validate(NewClient(nil).WithEnterpriseURLs(test.baseURL, test.uploadURL)) @@ -1109,7 +1109,7 @@ func TestDo_httpError(t *testing.T) { t.Fatal("Expected HTTP 400 error, got no error.") } if resp.StatusCode != 400 { - t.Errorf("Expected HTTP 400 error, got %d status code.", resp.StatusCode) + t.Errorf("Expected HTTP 400 error, got %v status code.", resp.StatusCode) } } @@ -1169,10 +1169,10 @@ func TestDo_preservesResponseInHTTPError(t *testing.T) { t.Fatal("Expected response to be returned even with error") } if got, want := resp.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Response status = %d, want %d", got, want) + t.Errorf("Response status = %v, want %v", got, want) } if got, want := errResp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Error response status = %d, want %d", got, want) + t.Errorf("Error response status = %v, want %v", got, want) } // Verify error contains proper message @@ -1595,7 +1595,7 @@ func TestDo_rateLimit_sleepUntilResponseResetLimitRetryOnce(t *testing.T) { t.Error("Expected error to be returned.") } if got, want := requestCount, 2; got != want { - t.Errorf("Expected 2 requests, got %d", got) + t.Errorf("Expected 2 requests, got %v", got) } } @@ -1628,7 +1628,7 @@ func TestDo_rateLimit_sleepUntilClientResetLimit(t *testing.T) { t.Errorf("Response status code = %v, want %v", got, want) } if got, want := requestCount, 1; got != want { - t.Errorf("Expected 1 request, got %d", got) + t.Errorf("Expected 1 request, got %v", got) } } @@ -1663,7 +1663,7 @@ func TestDo_rateLimit_abortSleepContextCancelled(t *testing.T) { t.Error("Expected context deadline exceeded error.") } if got, want := requestCount, 1; got != want { - t.Errorf("Expected 1 requests, got %d", got) + t.Errorf("Expected 1 requests, got %v", got) } } @@ -1698,7 +1698,7 @@ func TestDo_rateLimit_abortSleepContextCancelledClientLimit(t *testing.T) { t.Errorf("Expected request to be prevented because context cancellation, got: %v.", got) } if got, want := requestCount, 0; got != want { - t.Errorf("Expected 1 requests, got %d", got) + t.Errorf("Expected 1 requests, got %v", got) } } @@ -1950,10 +1950,10 @@ func TestDo_rateLimit_disableRateLimitCheck(t *testing.T) { t.Errorf("Response status code = %v, want %v", got, want) } if got, want := requestCount, 1; got != want { - t.Errorf("Expected 1 request, got %d", got) + t.Errorf("Expected 1 request, got %v", got) } if got, want := client.rateLimits[CoreCategory].Remaining, 0; got != want { - t.Errorf("Expected 0 requests remaining, got %d", got) + t.Errorf("Expected 0 requests remaining, got %v", got) } } @@ -1986,10 +1986,10 @@ func TestDo_rateLimit_bypassRateLimitCheck(t *testing.T) { t.Errorf("Response status code = %v, want %v", got, want) } if got, want := requestCount, 1; got != want { - t.Errorf("Expected 1 request, got %d", got) + t.Errorf("Expected 1 request, got %v", got) } if got, want := client.rateLimits[CoreCategory].Remaining, 5000; got != want { - t.Errorf("Expected 5000 requests remaining, got %d", got) + t.Errorf("Expected 5000 requests remaining, got %v", got) } } @@ -2706,11 +2706,11 @@ func TestSetCredentialsAsHeaders(t *testing.T) { } if actualID != id { - t.Errorf("id is %s, want %s", actualID, id) + t.Errorf("id is %v, want %v", actualID, id) } if actualSecret != secret { - t.Errorf("secret is %s, want %s", actualSecret, secret) + t.Errorf("secret is %v, want %v", actualSecret, secret) } } @@ -3161,7 +3161,7 @@ func TestClientCopy_leak_transport(t *testing.T) { srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") accessToken := r.Header.Get("Authorization") - _, _ = fmt.Fprintf(w, `{"login": "%s"}`, accessToken) + _, _ = fmt.Fprintf(w, `{"login": "%v"}`, accessToken) })) clientPreconfiguredWithURLs, err := NewClient(nil).WithEnterpriseURLs(srv.URL, srv.URL) if err != nil { diff --git a/github/issue_import_test.go b/github/issue_import_test.go index 427946c5105..4c5cd147257 100644 --- a/github/issue_import_test.go +++ b/github/issue_import_test.go @@ -224,6 +224,7 @@ func TestIssueImportService_CheckStatusSince(t *testing.T) { testMethod(t, r, "GET") testHeader(t, r, "Accept", mediaTypeIssueImportAPI) w.WriteHeader(http.StatusOK) + //nolint:fmtpercentv assertWrite(t, w, []byte(fmt.Sprintf("[%s]", issueImportResponseJSON))) }) diff --git a/github/issues.go b/github/issues.go index 18bd2eff4b5..6de04708dc8 100644 --- a/github/issues.go +++ b/github/issues.go @@ -286,7 +286,7 @@ func (s *IssuesService) ListByRepo(ctx context.Context, owner, repo string, opts // //meta:operation GET /repos/{owner}/{repo}/issues/{issue_number} func (s *IssuesService) Get(ctx context.Context, owner, repo string, number int) (*Issue, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/issues/%d", owner, repo, number) + u := fmt.Sprintf("repos/%v/%v/issues/%v", owner, repo, number) req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, nil, err @@ -331,7 +331,7 @@ func (s *IssuesService) Create(ctx context.Context, owner, repo string, issue *I // //meta:operation PATCH /repos/{owner}/{repo}/issues/{issue_number} func (s *IssuesService) Edit(ctx context.Context, owner, repo string, number int, issue *IssueRequest) (*Issue, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/issues/%d", owner, repo, number) + u := fmt.Sprintf("repos/%v/%v/issues/%v", owner, repo, number) req, err := s.client.NewRequest("PATCH", u, issue) if err != nil { return nil, nil, err @@ -386,7 +386,7 @@ type LockIssueOptions struct { // //meta:operation PUT /repos/{owner}/{repo}/issues/{issue_number}/lock func (s *IssuesService) Lock(ctx context.Context, owner, repo string, number int, opts *LockIssueOptions) (*Response, error) { - u := fmt.Sprintf("repos/%v/%v/issues/%d/lock", owner, repo, number) + u := fmt.Sprintf("repos/%v/%v/issues/%v/lock", owner, repo, number) req, err := s.client.NewRequest("PUT", u, opts) if err != nil { return nil, err @@ -401,7 +401,7 @@ func (s *IssuesService) Lock(ctx context.Context, owner, repo string, number int // //meta:operation DELETE /repos/{owner}/{repo}/issues/{issue_number}/lock func (s *IssuesService) Unlock(ctx context.Context, owner, repo string, number int) (*Response, error) { - u := fmt.Sprintf("repos/%v/%v/issues/%d/lock", owner, repo, number) + u := fmt.Sprintf("repos/%v/%v/issues/%v/lock", owner, repo, number) req, err := s.client.NewRequest("DELETE", u, nil) if err != nil { return nil, err diff --git a/github/issues_comments.go b/github/issues_comments.go index 7e0629eb312..8918e0894bb 100644 --- a/github/issues_comments.go +++ b/github/issues_comments.go @@ -64,7 +64,7 @@ func (s *IssuesService) ListComments(ctx context.Context, owner, repo string, nu if number == 0 { u = fmt.Sprintf("repos/%v/%v/issues/comments", owner, repo) } else { - u = fmt.Sprintf("repos/%v/%v/issues/%d/comments", owner, repo, number) + u = fmt.Sprintf("repos/%v/%v/issues/%v/comments", owner, repo, number) } u, err := addOptions(u, opts) if err != nil { @@ -94,7 +94,7 @@ func (s *IssuesService) ListComments(ctx context.Context, owner, repo string, nu // //meta:operation GET /repos/{owner}/{repo}/issues/comments/{comment_id} func (s *IssuesService) GetComment(ctx context.Context, owner, repo string, commentID int64) (*IssueComment, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/issues/comments/%d", owner, repo, commentID) + u := fmt.Sprintf("repos/%v/%v/issues/comments/%v", owner, repo, commentID) req, err := s.client.NewRequest("GET", u, nil) if err != nil { @@ -119,7 +119,7 @@ func (s *IssuesService) GetComment(ctx context.Context, owner, repo string, comm // //meta:operation POST /repos/{owner}/{repo}/issues/{issue_number}/comments func (s *IssuesService) CreateComment(ctx context.Context, owner, repo string, number int, comment *IssueComment) (*IssueComment, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/issues/%d/comments", owner, repo, number) + u := fmt.Sprintf("repos/%v/%v/issues/%v/comments", owner, repo, number) req, err := s.client.NewRequest("POST", u, comment) if err != nil { return nil, nil, err @@ -140,7 +140,7 @@ func (s *IssuesService) CreateComment(ctx context.Context, owner, repo string, n // //meta:operation PATCH /repos/{owner}/{repo}/issues/comments/{comment_id} func (s *IssuesService) EditComment(ctx context.Context, owner, repo string, commentID int64, comment *IssueComment) (*IssueComment, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/issues/comments/%d", owner, repo, commentID) + u := fmt.Sprintf("repos/%v/%v/issues/comments/%v", owner, repo, commentID) req, err := s.client.NewRequest("PATCH", u, comment) if err != nil { return nil, nil, err @@ -160,7 +160,7 @@ func (s *IssuesService) EditComment(ctx context.Context, owner, repo string, com // //meta:operation DELETE /repos/{owner}/{repo}/issues/comments/{comment_id} func (s *IssuesService) DeleteComment(ctx context.Context, owner, repo string, commentID int64) (*Response, error) { - u := fmt.Sprintf("repos/%v/%v/issues/comments/%d", owner, repo, commentID) + u := fmt.Sprintf("repos/%v/%v/issues/comments/%v", owner, repo, commentID) req, err := s.client.NewRequest("DELETE", u, nil) if err != nil { return nil, err diff --git a/github/issues_labels.go b/github/issues_labels.go index e2099034cef..243670ec7eb 100644 --- a/github/issues_labels.go +++ b/github/issues_labels.go @@ -134,7 +134,7 @@ func (s *IssuesService) DeleteLabel(ctx context.Context, owner, repo, name strin // //meta:operation GET /repos/{owner}/{repo}/issues/{issue_number}/labels func (s *IssuesService) ListLabelsByIssue(ctx context.Context, owner, repo string, number int, opts *ListOptions) ([]*Label, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/issues/%d/labels", owner, repo, number) + u := fmt.Sprintf("repos/%v/%v/issues/%v/labels", owner, repo, number) u, err := addOptions(u, opts) if err != nil { return nil, nil, err @@ -160,7 +160,7 @@ func (s *IssuesService) ListLabelsByIssue(ctx context.Context, owner, repo strin // //meta:operation POST /repos/{owner}/{repo}/issues/{issue_number}/labels func (s *IssuesService) AddLabelsToIssue(ctx context.Context, owner, repo string, number int, labels []string) ([]*Label, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/issues/%d/labels", owner, repo, number) + u := fmt.Sprintf("repos/%v/%v/issues/%v/labels", owner, repo, number) req, err := s.client.NewRequest("POST", u, labels) if err != nil { return nil, nil, err @@ -181,7 +181,7 @@ func (s *IssuesService) AddLabelsToIssue(ctx context.Context, owner, repo string // //meta:operation DELETE /repos/{owner}/{repo}/issues/{issue_number}/labels/{name} func (s *IssuesService) RemoveLabelForIssue(ctx context.Context, owner, repo string, number int, label string) (*Response, error) { - u := fmt.Sprintf("repos/%v/%v/issues/%d/labels/%v", owner, repo, number, label) + u := fmt.Sprintf("repos/%v/%v/issues/%v/labels/%v", owner, repo, number, label) req, err := s.client.NewRequest("DELETE", u, nil) if err != nil { return nil, err @@ -196,7 +196,7 @@ func (s *IssuesService) RemoveLabelForIssue(ctx context.Context, owner, repo str // //meta:operation PUT /repos/{owner}/{repo}/issues/{issue_number}/labels func (s *IssuesService) ReplaceLabelsForIssue(ctx context.Context, owner, repo string, number int, labels []string) ([]*Label, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/issues/%d/labels", owner, repo, number) + u := fmt.Sprintf("repos/%v/%v/issues/%v/labels", owner, repo, number) req, err := s.client.NewRequest("PUT", u, labels) if err != nil { return nil, nil, err @@ -217,7 +217,7 @@ func (s *IssuesService) ReplaceLabelsForIssue(ctx context.Context, owner, repo s // //meta:operation DELETE /repos/{owner}/{repo}/issues/{issue_number}/labels func (s *IssuesService) RemoveLabelsForIssue(ctx context.Context, owner, repo string, number int) (*Response, error) { - u := fmt.Sprintf("repos/%v/%v/issues/%d/labels", owner, repo, number) + u := fmt.Sprintf("repos/%v/%v/issues/%v/labels", owner, repo, number) req, err := s.client.NewRequest("DELETE", u, nil) if err != nil { return nil, err @@ -232,7 +232,7 @@ func (s *IssuesService) RemoveLabelsForIssue(ctx context.Context, owner, repo st // //meta:operation GET /repos/{owner}/{repo}/milestones/{milestone_number}/labels func (s *IssuesService) ListLabelsForMilestone(ctx context.Context, owner, repo string, number int, opts *ListOptions) ([]*Label, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/milestones/%d/labels", owner, repo, number) + u := fmt.Sprintf("repos/%v/%v/milestones/%v/labels", owner, repo, number) u, err := addOptions(u, opts) if err != nil { return nil, nil, err diff --git a/github/issues_milestones.go b/github/issues_milestones.go index 2aab8894578..74782902994 100644 --- a/github/issues_milestones.go +++ b/github/issues_milestones.go @@ -84,7 +84,7 @@ func (s *IssuesService) ListMilestones(ctx context.Context, owner, repo string, // //meta:operation GET /repos/{owner}/{repo}/milestones/{milestone_number} func (s *IssuesService) GetMilestone(ctx context.Context, owner, repo string, number int) (*Milestone, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/milestones/%d", owner, repo, number) + u := fmt.Sprintf("repos/%v/%v/milestones/%v", owner, repo, number) req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, nil, err @@ -126,7 +126,7 @@ func (s *IssuesService) CreateMilestone(ctx context.Context, owner, repo string, // //meta:operation PATCH /repos/{owner}/{repo}/milestones/{milestone_number} func (s *IssuesService) EditMilestone(ctx context.Context, owner, repo string, number int, milestone *Milestone) (*Milestone, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/milestones/%d", owner, repo, number) + u := fmt.Sprintf("repos/%v/%v/milestones/%v", owner, repo, number) req, err := s.client.NewRequest("PATCH", u, milestone) if err != nil { return nil, nil, err @@ -147,7 +147,7 @@ func (s *IssuesService) EditMilestone(ctx context.Context, owner, repo string, n // //meta:operation DELETE /repos/{owner}/{repo}/milestones/{milestone_number} func (s *IssuesService) DeleteMilestone(ctx context.Context, owner, repo string, number int) (*Response, error) { - u := fmt.Sprintf("repos/%v/%v/milestones/%d", owner, repo, number) + u := fmt.Sprintf("repos/%v/%v/milestones/%v", owner, repo, number) req, err := s.client.NewRequest("DELETE", u, nil) if err != nil { return nil, err diff --git a/github/issues_timeline_test.go b/github/issues_timeline_test.go index 2a076961b8a..de8ee202512 100644 --- a/github/issues_timeline_test.go +++ b/github/issues_timeline_test.go @@ -339,6 +339,6 @@ func TestTimeline_ReviewRequests(t *testing.T) { if !cmp.Equal(events, want) { t.Errorf("Issues.ListIssueTimeline review request events = %+v, want %+v", events, want) diff := cmp.Diff(events, want) - t.Errorf("Difference: %s", diff) + t.Errorf("Difference: %v", diff) } } diff --git a/github/licenses.go b/github/licenses.go index 34b8a3d8af1..60dfd71a193 100644 --- a/github/licenses.go +++ b/github/licenses.go @@ -84,7 +84,7 @@ func (s *LicensesService) List(ctx context.Context) ([]*License, *Response, erro // //meta:operation GET /licenses/{license} func (s *LicensesService) Get(ctx context.Context, licenseName string) (*License, *Response, error) { - u := fmt.Sprintf("licenses/%s", licenseName) + u := fmt.Sprintf("licenses/%v", licenseName) req, err := s.client.NewRequest("GET", u, nil) if err != nil { diff --git a/github/meta.go b/github/meta.go index 0637dfe0d8c..92c4bcff6f9 100644 --- a/github/meta.go +++ b/github/meta.go @@ -133,7 +133,7 @@ func (c *Client) APIMeta(ctx context.Context) (*APIMeta, *Response, error) { func (s *MetaService) Octocat(ctx context.Context, message string) (string, *Response, error) { u := "octocat" if message != "" { - u = fmt.Sprintf("%s?s=%s", u, url.QueryEscape(message)) + u = fmt.Sprintf("%v?s=%v", u, url.QueryEscape(message)) } req, err := s.client.NewRequest("GET", u, nil) diff --git a/github/migrations_test.go b/github/migrations_test.go index c832628ee7c..d13f943a440 100644 --- a/github/migrations_test.go +++ b/github/migrations_test.go @@ -65,6 +65,7 @@ func TestMigrationService_ListMigrations(t *testing.T) { testHeader(t, r, "Accept", mediaTypeMigrationsPreview) w.WriteHeader(http.StatusOK) + //nolint:fmtpercentv assertWrite(t, w, []byte(fmt.Sprintf("[%s]", migrationJSON))) }) diff --git a/github/migrations_user_test.go b/github/migrations_user_test.go index faa5c1bb836..276c8bfadf1 100644 --- a/github/migrations_user_test.go +++ b/github/migrations_user_test.go @@ -61,6 +61,7 @@ func TestMigrationService_ListUserMigrations(t *testing.T) { testHeader(t, r, "Accept", mediaTypeMigrationsPreview) w.WriteHeader(http.StatusOK) + //nolint:fmtpercentv assertWrite(t, w, []byte(fmt.Sprintf("[%s]", userMigrationJSON))) }) diff --git a/github/orgs.go b/github/orgs.go index bec49bbff5f..c810bfbb852 100644 --- a/github/orgs.go +++ b/github/orgs.go @@ -254,7 +254,7 @@ func (s *OrganizationsService) Get(ctx context.Context, org string) (*Organizati // //meta:operation GET /organizations/{organization_id} func (s *OrganizationsService) GetByID(ctx context.Context, id int64) (*Organization, *Response, error) { - u := fmt.Sprintf("organizations/%d", id) + u := fmt.Sprintf("organizations/%v", id) req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, nil, err diff --git a/github/orgs_codesecurity_configurations_test.go b/github/orgs_codesecurity_configurations_test.go index 868f3ca785e..38034a5982d 100644 --- a/github/orgs_codesecurity_configurations_test.go +++ b/github/orgs_codesecurity_configurations_test.go @@ -221,7 +221,7 @@ func TestOrganizationsService_DetachCodeSecurityConfigurationsFromRepositories(t want := http.StatusNoContent if resp.StatusCode != want { - t.Errorf("Organizations.DetachCodeSecurityConfigurationsFromRepositories returned status %d, want %d", resp.StatusCode, want) + t.Errorf("Organizations.DetachCodeSecurityConfigurationsFromRepositories returned status %v, want %v", resp.StatusCode, want) } const methodName = "DetachCodeSecurityConfigurationsFromRepositories" @@ -303,7 +303,7 @@ func TestOrganizationsService_DeleteCodeSecurityConfiguration(t *testing.T) { want := http.StatusNoContent if resp.StatusCode != want { - t.Errorf("Organizations.DeleteCodeSecurityConfiguration returned status %d, want %d", resp.StatusCode, want) + t.Errorf("Organizations.DeleteCodeSecurityConfiguration returned status %v, want %v", resp.StatusCode, want) } const methodName = "DeleteCodeSecurityConfiguration" @@ -332,7 +332,7 @@ func TestOrganizationsService_AttachCodeSecurityConfigurationsToRepositories(t * v := new(request) assertNilError(t, json.NewDecoder(r.Body).Decode(v)) if v.Scope != "selected" { - t.Errorf("Organizations.AttachCodeSecurityConfigurationsToRepositories request body scope = %s, want selected", v.Scope) + t.Errorf("Organizations.AttachCodeSecurityConfigurationsToRepositories request body scope = %v, want selected", v.Scope) } if !cmp.Equal(v.SelectedRepositoryIDs, []int64{5, 20}) { t.Errorf("Organizations.AttachCodeSecurityConfigurationsToRepositories request body selected_repository_ids = %+v, want %+v", v.SelectedRepositoryIDs, []int64{5, 20}) @@ -347,7 +347,7 @@ func TestOrganizationsService_AttachCodeSecurityConfigurationsToRepositories(t * want := http.StatusAccepted if resp.StatusCode != want { - t.Errorf("Organizations.AttachCodeSecurityConfigurationsToRepositories returned status %d, want %d", resp.StatusCode, want) + t.Errorf("Organizations.AttachCodeSecurityConfigurationsToRepositories returned status %v, want %v", resp.StatusCode, want) } const methodName = "AttachCodeSecurityConfigurationsToRepositories" @@ -386,7 +386,7 @@ func TestOrganizationsService_SetDefaultCodeSecurityConfiguration(t *testing.T) } wantStatus := http.StatusOK if resp.StatusCode != wantStatus { - t.Errorf("Organizations.SetDefaultCodeSecurityConfiguration returned status %d, want %d", resp.StatusCode, wantStatus) + t.Errorf("Organizations.SetDefaultCodeSecurityConfiguration returned status %v, want %v", resp.StatusCode, wantStatus) } want := &CodeSecurityConfigurationWithDefaultForNewRepos{ DefaultForNewRepos: Ptr("all"), diff --git a/github/orgs_hooks.go b/github/orgs_hooks.go index 9ad380cb904..e3bb25e78f4 100644 --- a/github/orgs_hooks.go +++ b/github/orgs_hooks.go @@ -43,7 +43,7 @@ func (s *OrganizationsService) ListHooks(ctx context.Context, org string, opts * // //meta:operation GET /orgs/{org}/hooks/{hook_id} func (s *OrganizationsService) GetHook(ctx context.Context, org string, id int64) (*Hook, *Response, error) { - u := fmt.Sprintf("orgs/%v/hooks/%d", org, id) + u := fmt.Sprintf("orgs/%v/hooks/%v", org, id) req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, nil, err @@ -101,7 +101,7 @@ func (s *OrganizationsService) CreateHook(ctx context.Context, org string, hook // //meta:operation PATCH /orgs/{org}/hooks/{hook_id} func (s *OrganizationsService) EditHook(ctx context.Context, org string, id int64, hook *Hook) (*Hook, *Response, error) { - u := fmt.Sprintf("orgs/%v/hooks/%d", org, id) + u := fmt.Sprintf("orgs/%v/hooks/%v", org, id) req, err := s.client.NewRequest("PATCH", u, hook) if err != nil { return nil, nil, err @@ -122,7 +122,7 @@ func (s *OrganizationsService) EditHook(ctx context.Context, org string, id int6 // //meta:operation POST /orgs/{org}/hooks/{hook_id}/pings func (s *OrganizationsService) PingHook(ctx context.Context, org string, id int64) (*Response, error) { - u := fmt.Sprintf("orgs/%v/hooks/%d/pings", org, id) + u := fmt.Sprintf("orgs/%v/hooks/%v/pings", org, id) req, err := s.client.NewRequest("POST", u, nil) if err != nil { return nil, err @@ -137,7 +137,7 @@ func (s *OrganizationsService) PingHook(ctx context.Context, org string, id int6 // //meta:operation DELETE /orgs/{org}/hooks/{hook_id} func (s *OrganizationsService) DeleteHook(ctx context.Context, org string, id int64) (*Response, error) { - u := fmt.Sprintf("orgs/%v/hooks/%d", org, id) + u := fmt.Sprintf("orgs/%v/hooks/%v", org, id) req, err := s.client.NewRequest("DELETE", u, nil) if err != nil { return nil, err diff --git a/github/orgs_hooks_deliveries_test.go b/github/orgs_hooks_deliveries_test.go index ba7a5783387..66c85ff905c 100644 --- a/github/orgs_hooks_deliveries_test.go +++ b/github/orgs_hooks_deliveries_test.go @@ -33,7 +33,7 @@ func TestOrganizationsService_ListHookDeliveries(t *testing.T) { want := []*HookDelivery{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}} if d := cmp.Diff(hooks, want); d != "" { - t.Errorf("Organizations.ListHooks want (-), got (+):\n%s", d) + t.Errorf("Organizations.ListHooks want (-), got (+):\n%v", d) } const methodName = "ListHookDeliveries" diff --git a/github/orgs_issue_types.go b/github/orgs_issue_types.go index 73e6f8d639a..a111dce3ff9 100644 --- a/github/orgs_issue_types.go +++ b/github/orgs_issue_types.go @@ -89,7 +89,7 @@ func (s *OrganizationsService) UpdateIssueType(ctx context.Context, org string, // //meta:operation DELETE /orgs/{org}/issue-types/{issue_type_id} func (s *OrganizationsService) DeleteIssueType(ctx context.Context, org string, issueTypeID int64) (*Response, error) { - u := fmt.Sprintf("orgs/%v/issue-types/%d", org, issueTypeID) + u := fmt.Sprintf("orgs/%v/issue-types/%v", org, issueTypeID) req, err := s.client.NewRequest("DELETE", u, nil) if err != nil { return nil, err diff --git a/github/orgs_network_configurations_test.go b/github/orgs_network_configurations_test.go index 216cb0ec23b..5a34238b78a 100644 --- a/github/orgs_network_configurations_test.go +++ b/github/orgs_network_configurations_test.go @@ -101,7 +101,7 @@ func TestOrganizationsService_ListOrgsNetworkConfigurations(t *testing.T) { }, } if !cmp.Equal(want, configurations) { - t.Errorf("Organizations.ListNetworkConfigurations mismatch (-want +got):\n%s", cmp.Diff(want, configurations)) + t.Errorf("Organizations.ListNetworkConfigurations mismatch (-want +got):\n%v", cmp.Diff(want, configurations)) } const methodName = "ListNetworkConfigurations" @@ -162,7 +162,7 @@ func TestOrganizationsService_CreateOrgsNetworkConfiguration(t *testing.T) { } if !cmp.Equal(want, configuration) { - t.Errorf("Organizations.CreateNetworkConfiguration mismatch (-want +got):\n%s", cmp.Diff(want, configuration)) + t.Errorf("Organizations.CreateNetworkConfiguration mismatch (-want +got):\n%v", cmp.Diff(want, configuration)) } validationTests := []struct { @@ -274,7 +274,7 @@ func TestOrganizationsService_GetOrgsNetworkConfiguration(t *testing.T) { CreatedOn: &Timestamp{time.Date(2024, 12, 10, 19, 30, 45, 0, time.UTC)}, } if !cmp.Equal(want, configuration) { - t.Errorf("Organizations.GetNetworkConfiguration mismatch (-want +got):\n%s", cmp.Diff(want, configuration)) + t.Errorf("Organizations.GetNetworkConfiguration mismatch (-want +got):\n%v", cmp.Diff(want, configuration)) } const methodName = "GetNetworkConfiguration" @@ -335,7 +335,7 @@ func TestOrganizationsService_UpdateOrgsNetworkConfiguration(t *testing.T) { CreatedOn: &Timestamp{time.Date(2024, 12, 10, 19, 30, 45, 0, time.UTC)}, } if !cmp.Equal(want, configuration) { - t.Errorf("Organizations.UpdateNetworkConfiguration mismatch (-want +got):\n%s", cmp.Diff(want, configuration)) + t.Errorf("Organizations.UpdateNetworkConfiguration mismatch (-want +got):\n%v", cmp.Diff(want, configuration)) } validationTests := []struct { @@ -469,7 +469,7 @@ func TestOrganizationsService_GetOrgsNetworkConfigurationResource(t *testing.T) } if !cmp.Equal(want, resource) { - t.Errorf("Organizations.GetNetworkConfigurationResource mismatch (-want +got):\n%s", cmp.Diff(want, resource)) + t.Errorf("Organizations.GetNetworkConfigurationResource mismatch (-want +got):\n%v", cmp.Diff(want, resource)) } const methodName = "GetNetworkConfiguration" diff --git a/github/orgs_personal_access_tokens.go b/github/orgs_personal_access_tokens.go index 651dcc26d77..8155ad402bf 100644 --- a/github/orgs_personal_access_tokens.go +++ b/github/orgs_personal_access_tokens.go @@ -162,7 +162,7 @@ func addListFineGrainedPATOptions(s string, opts *ListFineGrainedPATOptions) (st if len(opts.Owner) > 0 { ownerVals := make([]string, len(opts.Owner)) for i, owner := range opts.Owner { - ownerVals[i] = fmt.Sprintf("owner[]=%s", url.QueryEscape(owner)) + ownerVals[i] = fmt.Sprintf("owner[]=%v", url.QueryEscape(owner)) } ownerQuery := strings.Join(ownerVals, "&") diff --git a/github/orgs_personal_access_tokens_test.go b/github/orgs_personal_access_tokens_test.go index b20fd8e4081..05cbeaaa0d6 100644 --- a/github/orgs_personal_access_tokens_test.go +++ b/github/orgs_personal_access_tokens_test.go @@ -33,11 +33,11 @@ func TestOrganizationsService_ListFineGrainedPersonalAccessTokens(t *testing.T) for key, expectedValues := range expectedQuery { actualValues := query[key] if len(actualValues) != len(expectedValues) { - t.Errorf("Expected %d values for query param %s, got %d", len(expectedValues), key, len(actualValues)) + t.Errorf("Expected %v values for query param %v, got %v", len(expectedValues), key, len(actualValues)) } for i, expectedValue := range expectedValues { if actualValues[i] != expectedValue { - t.Errorf("Expected query param %s to be %s, got %s", key, expectedValue, actualValues[i]) + t.Errorf("Expected query param %v to be %v, got %v", key, expectedValue, actualValues[i]) } } } diff --git a/github/pulls.go b/github/pulls.go index 48717941f37..a490feb5785 100644 --- a/github/pulls.go +++ b/github/pulls.go @@ -214,7 +214,7 @@ func (s *PullRequestsService) ListPullRequestsWithCommit(ctx context.Context, ow // //meta:operation GET /repos/{owner}/{repo}/pulls/{pull_number} func (s *PullRequestsService) Get(ctx context.Context, owner, repo string, number int) (*PullRequest, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/pulls/%d", owner, repo, number) + u := fmt.Sprintf("repos/%v/%v/pulls/%v", owner, repo, number) req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, nil, err @@ -235,7 +235,7 @@ func (s *PullRequestsService) Get(ctx context.Context, owner, repo string, numbe // //meta:operation GET /repos/{owner}/{repo}/pulls/{pull_number} func (s *PullRequestsService) GetRaw(ctx context.Context, owner, repo string, number int, opts RawOptions) (string, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/pulls/%d", owner, repo, number) + u := fmt.Sprintf("repos/%v/%v/pulls/%v", owner, repo, number) req, err := s.client.NewRequest("GET", u, nil) if err != nil { return "", nil, err @@ -247,7 +247,7 @@ func (s *PullRequestsService) GetRaw(ctx context.Context, owner, repo string, nu case Patch: req.Header.Set("Accept", mediaTypeV3Patch) default: - return "", nil, fmt.Errorf("unsupported raw type %d", opts.Type) + return "", nil, fmt.Errorf("unsupported raw type %v", opts.Type) } var buf bytes.Buffer @@ -325,7 +325,7 @@ type PullRequestBranchUpdateResponse struct { // //meta:operation PUT /repos/{owner}/{repo}/pulls/{pull_number}/update-branch func (s *PullRequestsService) UpdateBranch(ctx context.Context, owner, repo string, number int, opts *PullRequestBranchUpdateOptions) (*PullRequestBranchUpdateResponse, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/pulls/%d/update-branch", owner, repo, number) + u := fmt.Sprintf("repos/%v/%v/pulls/%v/update-branch", owner, repo, number) req, err := s.client.NewRequest("PUT", u, opts) if err != nil { @@ -366,7 +366,7 @@ func (s *PullRequestsService) Edit(ctx context.Context, owner, repo string, numb return nil, nil, errors.New("pull must be provided") } - u := fmt.Sprintf("repos/%v/%v/pulls/%d", owner, repo, number) + u := fmt.Sprintf("repos/%v/%v/pulls/%v", owner, repo, number) update := &pullRequestUpdate{ Title: pull.Title, @@ -401,7 +401,7 @@ func (s *PullRequestsService) Edit(ctx context.Context, owner, repo string, numb // //meta:operation GET /repos/{owner}/{repo}/pulls/{pull_number}/commits func (s *PullRequestsService) ListCommits(ctx context.Context, owner, repo string, number int, opts *ListOptions) ([]*RepositoryCommit, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/pulls/%d/commits", owner, repo, number) + u := fmt.Sprintf("repos/%v/%v/pulls/%v/commits", owner, repo, number) u, err := addOptions(u, opts) if err != nil { return nil, nil, err @@ -427,7 +427,7 @@ func (s *PullRequestsService) ListCommits(ctx context.Context, owner, repo strin // //meta:operation GET /repos/{owner}/{repo}/pulls/{pull_number}/files func (s *PullRequestsService) ListFiles(ctx context.Context, owner, repo string, number int, opts *ListOptions) ([]*CommitFile, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/pulls/%d/files", owner, repo, number) + u := fmt.Sprintf("repos/%v/%v/pulls/%v/files", owner, repo, number) u, err := addOptions(u, opts) if err != nil { return nil, nil, err @@ -453,7 +453,7 @@ func (s *PullRequestsService) ListFiles(ctx context.Context, owner, repo string, // //meta:operation GET /repos/{owner}/{repo}/pulls/{pull_number}/merge func (s *PullRequestsService) IsMerged(ctx context.Context, owner, repo string, number int) (bool, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/pulls/%d/merge", owner, repo, number) + u := fmt.Sprintf("repos/%v/%v/pulls/%v/merge", owner, repo, number) req, err := s.client.NewRequest("GET", u, nil) if err != nil { return false, nil, err @@ -497,7 +497,7 @@ type pullRequestMergeRequest struct { // //meta:operation PUT /repos/{owner}/{repo}/pulls/{pull_number}/merge func (s *PullRequestsService) Merge(ctx context.Context, owner, repo string, number int, commitMessage string, options *PullRequestOptions) (*PullRequestMergeResult, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/pulls/%d/merge", owner, repo, number) + u := fmt.Sprintf("repos/%v/%v/pulls/%v/merge", owner, repo, number) pullRequestBody := &pullRequestMergeRequest{} if commitMessage != "" { diff --git a/github/pulls_comments.go b/github/pulls_comments.go index 431b4508810..0c495c5965b 100644 --- a/github/pulls_comments.go +++ b/github/pulls_comments.go @@ -82,7 +82,7 @@ func (s *PullRequestsService) ListComments(ctx context.Context, owner, repo stri if number == 0 { u = fmt.Sprintf("repos/%v/%v/pulls/comments", owner, repo) } else { - u = fmt.Sprintf("repos/%v/%v/pulls/%d/comments", owner, repo, number) + u = fmt.Sprintf("repos/%v/%v/pulls/%v/comments", owner, repo, number) } u, err := addOptions(u, opts) if err != nil { @@ -113,7 +113,7 @@ func (s *PullRequestsService) ListComments(ctx context.Context, owner, repo stri // //meta:operation GET /repos/{owner}/{repo}/pulls/comments/{comment_id} func (s *PullRequestsService) GetComment(ctx context.Context, owner, repo string, commentID int64) (*PullRequestComment, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/pulls/comments/%d", owner, repo, commentID) + u := fmt.Sprintf("repos/%v/%v/pulls/comments/%v", owner, repo, commentID) req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, nil, err @@ -138,7 +138,7 @@ func (s *PullRequestsService) GetComment(ctx context.Context, owner, repo string // //meta:operation POST /repos/{owner}/{repo}/pulls/{pull_number}/comments func (s *PullRequestsService) CreateComment(ctx context.Context, owner, repo string, number int, comment *PullRequestComment) (*PullRequestComment, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/pulls/%d/comments", owner, repo, number) + u := fmt.Sprintf("repos/%v/%v/pulls/%v/comments", owner, repo, number) req, err := s.client.NewRequest("POST", u, comment) if err != nil { return nil, nil, err @@ -169,7 +169,7 @@ func (s *PullRequestsService) CreateCommentInReplyTo(ctx context.Context, owner, Body: body, InReplyTo: commentID, } - u := fmt.Sprintf("repos/%v/%v/pulls/%d/comments", owner, repo, number) + u := fmt.Sprintf("repos/%v/%v/pulls/%v/comments", owner, repo, number) req, err := s.client.NewRequest("POST", u, comment) if err != nil { return nil, nil, err @@ -191,7 +191,7 @@ func (s *PullRequestsService) CreateCommentInReplyTo(ctx context.Context, owner, // //meta:operation PATCH /repos/{owner}/{repo}/pulls/comments/{comment_id} func (s *PullRequestsService) EditComment(ctx context.Context, owner, repo string, commentID int64, comment *PullRequestComment) (*PullRequestComment, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/pulls/comments/%d", owner, repo, commentID) + u := fmt.Sprintf("repos/%v/%v/pulls/comments/%v", owner, repo, commentID) req, err := s.client.NewRequest("PATCH", u, comment) if err != nil { return nil, nil, err @@ -212,7 +212,7 @@ func (s *PullRequestsService) EditComment(ctx context.Context, owner, repo strin // //meta:operation DELETE /repos/{owner}/{repo}/pulls/comments/{comment_id} func (s *PullRequestsService) DeleteComment(ctx context.Context, owner, repo string, commentID int64) (*Response, error) { - u := fmt.Sprintf("repos/%v/%v/pulls/comments/%d", owner, repo, commentID) + u := fmt.Sprintf("repos/%v/%v/pulls/comments/%v", owner, repo, commentID) req, err := s.client.NewRequest("DELETE", u, nil) if err != nil { return nil, err diff --git a/github/pulls_reviewers.go b/github/pulls_reviewers.go index 526047937e3..9d142474140 100644 --- a/github/pulls_reviewers.go +++ b/github/pulls_reviewers.go @@ -36,7 +36,7 @@ type removeReviewersRequest struct { // //meta:operation POST /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers func (s *PullRequestsService) RequestReviewers(ctx context.Context, owner, repo string, number int, reviewers ReviewersRequest) (*PullRequest, *Response, error) { - u := fmt.Sprintf("repos/%s/%s/pulls/%d/requested_reviewers", owner, repo, number) + u := fmt.Sprintf("repos/%v/%v/pulls/%v/requested_reviewers", owner, repo, number) req, err := s.client.NewRequest("POST", u, &reviewers) if err != nil { return nil, nil, err @@ -57,7 +57,7 @@ func (s *PullRequestsService) RequestReviewers(ctx context.Context, owner, repo // //meta:operation GET /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers func (s *PullRequestsService) ListReviewers(ctx context.Context, owner, repo string, number int, opts *ListOptions) (*Reviewers, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/pulls/%d/requested_reviewers", owner, repo, number) + u := fmt.Sprintf("repos/%v/%v/pulls/%v/requested_reviewers", owner, repo, number) u, err := addOptions(u, opts) if err != nil { return nil, nil, err @@ -93,7 +93,7 @@ func (s *PullRequestsService) RemoveReviewers(ctx context.Context, owner, repo s removeRequest.Reviewers = []string{} } - u := fmt.Sprintf("repos/%s/%s/pulls/%d/requested_reviewers", owner, repo, number) + u := fmt.Sprintf("repos/%v/%v/pulls/%v/requested_reviewers", owner, repo, number) req, err := s.client.NewRequest("DELETE", u, &removeRequest) if err != nil { return nil, err diff --git a/github/pulls_reviews.go b/github/pulls_reviews.go index 84e06a0eab7..e8cf7a75b0c 100644 --- a/github/pulls_reviews.go +++ b/github/pulls_reviews.go @@ -108,7 +108,7 @@ func (r PullRequestReviewDismissalRequest) String() string { // //meta:operation GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews func (s *PullRequestsService) ListReviews(ctx context.Context, owner, repo string, number int, opts *ListOptions) ([]*PullRequestReview, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews", owner, repo, number) + u := fmt.Sprintf("repos/%v/%v/pulls/%v/reviews", owner, repo, number) u, err := addOptions(u, opts) if err != nil { return nil, nil, err @@ -134,7 +134,7 @@ func (s *PullRequestsService) ListReviews(ctx context.Context, owner, repo strin // //meta:operation GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id} func (s *PullRequestsService) GetReview(ctx context.Context, owner, repo string, number int, reviewID int64) (*PullRequestReview, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d", owner, repo, number, reviewID) + u := fmt.Sprintf("repos/%v/%v/pulls/%v/reviews/%v", owner, repo, number, reviewID) req, err := s.client.NewRequest("GET", u, nil) if err != nil { @@ -156,7 +156,7 @@ func (s *PullRequestsService) GetReview(ctx context.Context, owner, repo string, // //meta:operation DELETE /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id} func (s *PullRequestsService) DeletePendingReview(ctx context.Context, owner, repo string, number int, reviewID int64) (*PullRequestReview, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d", owner, repo, number, reviewID) + u := fmt.Sprintf("repos/%v/%v/pulls/%v/reviews/%v", owner, repo, number, reviewID) req, err := s.client.NewRequest("DELETE", u, nil) if err != nil { @@ -178,7 +178,7 @@ func (s *PullRequestsService) DeletePendingReview(ctx context.Context, owner, re // //meta:operation GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/comments func (s *PullRequestsService) ListReviewComments(ctx context.Context, owner, repo string, number int, reviewID int64, opts *ListOptions) ([]*PullRequestComment, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d/comments", owner, repo, number, reviewID) + u := fmt.Sprintf("repos/%v/%v/pulls/%v/reviews/%v/comments", owner, repo, number, reviewID) u, err := addOptions(u, opts) if err != nil { return nil, nil, err @@ -238,7 +238,7 @@ func (s *PullRequestsService) ListReviewComments(ctx context.Context, owner, rep // //meta:operation POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews func (s *PullRequestsService) CreateReview(ctx context.Context, owner, repo string, number int, review *PullRequestReviewRequest) (*PullRequestReview, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews", owner, repo, number) + u := fmt.Sprintf("repos/%v/%v/pulls/%v/reviews", owner, repo, number) req, err := s.client.NewRequest("POST", u, review) if err != nil { @@ -272,7 +272,7 @@ func (s *PullRequestsService) UpdateReview(ctx context.Context, owner, repo stri opts := &struct { Body string `json:"body"` }{Body: body} - u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d", owner, repo, number, reviewID) + u := fmt.Sprintf("repos/%v/%v/pulls/%v/reviews/%v", owner, repo, number, reviewID) req, err := s.client.NewRequest("PUT", u, opts) if err != nil { @@ -294,7 +294,7 @@ func (s *PullRequestsService) UpdateReview(ctx context.Context, owner, repo stri // //meta:operation POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/events func (s *PullRequestsService) SubmitReview(ctx context.Context, owner, repo string, number int, reviewID int64, review *PullRequestReviewRequest) (*PullRequestReview, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d/events", owner, repo, number, reviewID) + u := fmt.Sprintf("repos/%v/%v/pulls/%v/reviews/%v/events", owner, repo, number, reviewID) req, err := s.client.NewRequest("POST", u, review) if err != nil { @@ -316,7 +316,7 @@ func (s *PullRequestsService) SubmitReview(ctx context.Context, owner, repo stri // //meta:operation PUT /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/dismissals func (s *PullRequestsService) DismissReview(ctx context.Context, owner, repo string, number int, reviewID int64, review *PullRequestReviewDismissalRequest) (*PullRequestReview, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d/dismissals", owner, repo, number, reviewID) + u := fmt.Sprintf("repos/%v/%v/pulls/%v/reviews/%v/dismissals", owner, repo, number, reviewID) req, err := s.client.NewRequest("PUT", u, review) if err != nil { diff --git a/github/pulls_test.go b/github/pulls_test.go index c02143564c5..ea724cd5d6e 100644 --- a/github/pulls_test.go +++ b/github/pulls_test.go @@ -163,7 +163,7 @@ func TestPullRequestsService_GetRaw_diff(t *testing.T) { } want := rawStr if got != want { - t.Errorf("PullRequests.GetRaw returned %s want %s", got, want) + t.Errorf("PullRequests.GetRaw returned %v want %v", got, want) } const methodName = "GetRaw" @@ -200,7 +200,7 @@ func TestPullRequestsService_GetRaw_patch(t *testing.T) { } want := rawStr if got != want { - t.Errorf("PullRequests.GetRaw returned %s want %s", got, want) + t.Errorf("PullRequests.GetRaw returned %v want %v", got, want) } } @@ -495,15 +495,15 @@ func TestPullRequestsService_Edit(t *testing.T) { ctx := t.Context() pull, _, err := client.PullRequests.Edit(ctx, "o", "r", i, tt.input) if err != nil { - t.Errorf("%d: PullRequests.Edit returned error: %v", i, err) + t.Errorf("%v: PullRequests.Edit returned error: %v", i, err) } if !cmp.Equal(pull, tt.want) { - t.Errorf("%d: PullRequests.Edit returned %+v, want %+v", i, pull, tt.want) + t.Errorf("%v: PullRequests.Edit returned %+v, want %+v", i, pull, tt.want) } if !madeRequest { - t.Errorf("%d: PullRequest.Edit did not make the expected request", i) + t.Errorf("%v: PullRequest.Edit did not make the expected request", i) } const methodName = "Edit" @@ -795,7 +795,7 @@ func TestPullRequestsService_Merge_options(t *testing.T) { for i, test := range tests { madeRequest := false - mux.HandleFunc(fmt.Sprintf("/repos/o/r/pulls/%d/merge", i), func(_ http.ResponseWriter, r *http.Request) { + mux.HandleFunc(fmt.Sprintf("/repos/o/r/pulls/%v/merge", i), func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") testBody(t, r, test.wantBody+"\n") madeRequest = true @@ -803,7 +803,7 @@ func TestPullRequestsService_Merge_options(t *testing.T) { ctx := t.Context() _, _, _ = client.PullRequests.Merge(ctx, "o", "r", i, "merging pull request", test.options) if !madeRequest { - t.Errorf("%d: PullRequests.Merge(%#v): expected request was not made", i, test.options) + t.Errorf("%v: PullRequests.Merge(%#v): expected request was not made", i, test.options) } } } diff --git a/github/repos.go b/github/repos.go index 03780fee4fb..5388e8a87e9 100644 --- a/github/repos.go +++ b/github/repos.go @@ -689,7 +689,7 @@ func (s *RepositoriesService) GetCodeOfConduct(ctx context.Context, owner, repo // //meta:operation GET /repositories/{repository_id} func (s *RepositoriesService) GetByID(ctx context.Context, id int64) (*Repository, *Response, error) { - u := fmt.Sprintf("repositories/%d", id) + u := fmt.Sprintf("repositories/%v", id) req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, nil, err @@ -1453,7 +1453,7 @@ func (s *RepositoriesService) GetBranch(ctx context.Context, owner, repo, branch defer resp.Body.Close() if resp.StatusCode != http.StatusOK { - return nil, newResponse(resp), fmt.Errorf("unexpected status code: %s", resp.Status) + return nil, newResponse(resp), fmt.Errorf("unexpected status code: %v", resp.Status) } b := new(Branch) diff --git a/github/repos_actions_permissions_test.go b/github/repos_actions_permissions_test.go index 927b338019d..5666c2dc73d 100644 --- a/github/repos_actions_permissions_test.go +++ b/github/repos_actions_permissions_test.go @@ -251,7 +251,7 @@ func TestRepositoriesService_UpdateArtifactAndLogRetentionPeriod(t *testing.T) { } if resp.StatusCode != http.StatusNoContent { - t.Errorf("Repositories.UpdateArtifactAndLogRetentionPeriod = %d, want %d", resp.StatusCode, http.StatusNoContent) + t.Errorf("Repositories.UpdateArtifactAndLogRetentionPeriod = %v, want %v", resp.StatusCode, http.StatusNoContent) } const methodName = "UpdateArtifactAndLogRetentionPeriod" @@ -332,7 +332,7 @@ func TestRepositoriesService_UpdatePrivateRepoForkPRWorkflowSettings(t *testing. } if resp.StatusCode != http.StatusNoContent { - t.Errorf("Repositories.UpdatePrivateRepoForkPRWorkflowSettings = %d, want %d", resp.StatusCode, http.StatusNoContent) + t.Errorf("Repositories.UpdatePrivateRepoForkPRWorkflowSettings = %v, want %v", resp.StatusCode, http.StatusNoContent) } const methodName = "UpdatePrivateRepoForkPRWorkflowSettings" diff --git a/github/repos_commits.go b/github/repos_commits.go index 48c87007ecd..9d7c8d47822 100644 --- a/github/repos_commits.go +++ b/github/repos_commits.go @@ -192,7 +192,7 @@ func (s *RepositoriesService) GetCommitRaw(ctx context.Context, owner, repo, sha case Patch: req.Header.Set("Accept", mediaTypeV3Patch) default: - return "", nil, fmt.Errorf("unsupported raw type %d", opts.Type) + return "", nil, fmt.Errorf("unsupported raw type %v", opts.Type) } var buf bytes.Buffer @@ -287,7 +287,7 @@ func (s *RepositoriesService) CompareCommitsRaw(ctx context.Context, owner, repo case Patch: req.Header.Set("Accept", mediaTypeV3Patch) default: - return "", nil, fmt.Errorf("unsupported raw type %d", opts.Type) + return "", nil, fmt.Errorf("unsupported raw type %v", opts.Type) } var buf bytes.Buffer diff --git a/github/repos_commits_test.go b/github/repos_commits_test.go index 71e9aa21fc1..82f794b9c00 100644 --- a/github/repos_commits_test.go +++ b/github/repos_commits_test.go @@ -177,7 +177,7 @@ func TestRepositoriesService_GetCommitRaw_diff(t *testing.T) { } want := rawStr if got != want { - t.Errorf("Repositories.GetCommitRaw returned %s want %s", got, want) + t.Errorf("Repositories.GetCommitRaw returned %v want %v", got, want) } const methodName = "GetCommitRaw" @@ -214,7 +214,7 @@ func TestRepositoriesService_GetCommitRaw_patch(t *testing.T) { } want := rawStr if got != want { - t.Errorf("Repositories.GetCommitRaw returned %s want %s", got, want) + t.Errorf("Repositories.GetCommitRaw returned %v want %v", got, want) } } @@ -550,7 +550,7 @@ func TestRepositoriesService_CompareCommitsRaw_diff(t *testing.T) { } want := rawStr if got != want { - t.Errorf("Repositories.GetCommitRaw returned %s want %s", got, want) + t.Errorf("Repositories.GetCommitRaw returned %v want %v", got, want) } const methodName = "CompareCommitsRaw" @@ -608,7 +608,7 @@ func TestRepositoriesService_CompareCommitsRaw_patch(t *testing.T) { } want := rawStr if got != want { - t.Errorf("Repositories.GetCommitRaw returned %s want %s", got, want) + t.Errorf("Repositories.GetCommitRaw returned %v want %v", got, want) } }) } diff --git a/github/repos_contents.go b/github/repos_contents.go index d5b0582b826..2378cd2330e 100644 --- a/github/repos_contents.go +++ b/github/repos_contents.go @@ -155,7 +155,7 @@ func (s *RepositoriesService) DownloadContents(ctx context.Context, owner, repo, for _, contents := range dirContents { if contents.GetName() == filename { if contents.GetDownloadURL() == "" { - return nil, resp, fmt.Errorf("no download link found for %s", filepath) + return nil, resp, fmt.Errorf("no download link found for %v", filepath) } dlReq, err := http.NewRequestWithContext(ctx, "GET", *contents.DownloadURL, nil) if err != nil { @@ -170,7 +170,7 @@ func (s *RepositoriesService) DownloadContents(ctx context.Context, owner, repo, } } - return nil, resp, fmt.Errorf("no file named %s found in %s", filename, dir) + return nil, resp, fmt.Errorf("no file named %v found in %v", filename, dir) } // DownloadContentsWithMeta is identical to DownloadContents but additionally @@ -204,7 +204,7 @@ func (s *RepositoriesService) DownloadContentsWithMeta(ctx context.Context, owne for _, contents := range dirContents { if contents.GetName() == filename { if contents.GetDownloadURL() == "" { - return nil, contents, resp, fmt.Errorf("no download link found for %s", filepath) + return nil, contents, resp, fmt.Errorf("no download link found for %v", filepath) } dlReq, err := http.NewRequestWithContext(ctx, "GET", *contents.DownloadURL, nil) if err != nil { @@ -219,7 +219,7 @@ func (s *RepositoriesService) DownloadContentsWithMeta(ctx context.Context, owne } } - return nil, nil, resp, fmt.Errorf("no file named %s found in %s", filename, dir) + return nil, nil, resp, fmt.Errorf("no file named %v found in %v", filename, dir) } // GetContents can return either the metadata and content of a single file @@ -241,7 +241,7 @@ func (s *RepositoriesService) GetContents(ctx context.Context, owner, repo, path } escapedPath := (&url.URL{Path: strings.TrimSuffix(path, "/")}).String() - u := fmt.Sprintf("repos/%s/%s/contents/%s", owner, repo, escapedPath) + u := fmt.Sprintf("repos/%v/%v/contents/%v", owner, repo, escapedPath) u, err = addOptions(u, opts) if err != nil { return nil, nil, nil, err @@ -268,7 +268,7 @@ func (s *RepositoriesService) GetContents(ctx context.Context, owner, repo, path return nil, directoryContent, resp, nil } - return nil, nil, resp, fmt.Errorf("unmarshaling failed for both file and directory content: %s and %s", fileUnmarshalError, directoryUnmarshalError) + return nil, nil, resp, fmt.Errorf("unmarshaling failed for both file and directory content: %v and %v", fileUnmarshalError, directoryUnmarshalError) } // CreateFile creates a new file in a repository at the given path and returns @@ -278,7 +278,7 @@ func (s *RepositoriesService) GetContents(ctx context.Context, owner, repo, path // //meta:operation PUT /repos/{owner}/{repo}/contents/{path} func (s *RepositoriesService) CreateFile(ctx context.Context, owner, repo, path string, opts *RepositoryContentFileOptions) (*RepositoryContentResponse, *Response, error) { - u := fmt.Sprintf("repos/%s/%s/contents/%s", owner, repo, path) + u := fmt.Sprintf("repos/%v/%v/contents/%v", owner, repo, path) req, err := s.client.NewRequest("PUT", u, opts) if err != nil { return nil, nil, err @@ -300,7 +300,7 @@ func (s *RepositoriesService) CreateFile(ctx context.Context, owner, repo, path // //meta:operation PUT /repos/{owner}/{repo}/contents/{path} func (s *RepositoriesService) UpdateFile(ctx context.Context, owner, repo, path string, opts *RepositoryContentFileOptions) (*RepositoryContentResponse, *Response, error) { - u := fmt.Sprintf("repos/%s/%s/contents/%s", owner, repo, path) + u := fmt.Sprintf("repos/%v/%v/contents/%v", owner, repo, path) req, err := s.client.NewRequest("PUT", u, opts) if err != nil { return nil, nil, err @@ -322,7 +322,7 @@ func (s *RepositoriesService) UpdateFile(ctx context.Context, owner, repo, path // //meta:operation DELETE /repos/{owner}/{repo}/contents/{path} func (s *RepositoriesService) DeleteFile(ctx context.Context, owner, repo, path string, opts *RepositoryContentFileOptions) (*RepositoryContentResponse, *Response, error) { - u := fmt.Sprintf("repos/%s/%s/contents/%s", owner, repo, path) + u := fmt.Sprintf("repos/%v/%v/contents/%v", owner, repo, path) req, err := s.client.NewRequest("DELETE", u, opts) if err != nil { return nil, nil, err @@ -358,9 +358,9 @@ const ( //meta:operation GET /repos/{owner}/{repo}/tarball/{ref} //meta:operation GET /repos/{owner}/{repo}/zipball/{ref} func (s *RepositoriesService) GetArchiveLink(ctx context.Context, owner, repo string, archiveformat ArchiveFormat, opts *RepositoryContentGetOptions, maxRedirects int) (*url.URL, *Response, error) { - u := fmt.Sprintf("repos/%s/%s/%s", owner, repo, archiveformat) + u := fmt.Sprintf("repos/%v/%v/%v", owner, repo, archiveformat) if opts != nil && opts.Ref != "" { - u += fmt.Sprintf("/%s", opts.Ref) + u += fmt.Sprintf("/%v", opts.Ref) } if s.client.RateLimitRedirectionalEndpoints { diff --git a/github/repos_contents_test.go b/github/repos_contents_test.go index 16d4fe532e4..ed782da8701 100644 --- a/github/repos_contents_test.go +++ b/github/repos_contents_test.go @@ -65,11 +65,11 @@ func TestRepositoryContent_GetContent(t *testing.T) { r := RepositoryContent{Encoding: tt.encoding, Content: tt.content} got, err := r.GetContent() if err != nil && !tt.wantErr { - t.Errorf("RepositoryContent(%s, %s) returned unexpected error: %v", + t.Errorf("RepositoryContent(%v, %v) returned unexpected error: %v", stringOrNil(tt.encoding), stringOrNil(tt.content), err) } if err == nil && tt.wantErr { - t.Errorf("RepositoryContent(%s, %s) did not return unexpected error", + t.Errorf("RepositoryContent(%v, %v) did not return unexpected error", stringOrNil(tt.encoding), stringOrNil(tt.content)) } if want := tt.want; got != want { @@ -459,7 +459,7 @@ func TestRepositoriesService_DownloadContentsWithMeta_FailedResponse(t *testing. t.Parallel() client, mux, serverURL := setup(t) - downloadURL := fmt.Sprintf("%s%s/download/f", serverURL, baseURLPath) + downloadURL := fmt.Sprintf("%v%v/download/f", serverURL, baseURLPath) mux.HandleFunc("/repos/o/r/contents/d/f", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") @@ -896,11 +896,11 @@ func TestRepositoriesService_GetArchiveLink(t *testing.T) { t.Errorf("Repositories.GetArchiveLink returned error: %v", err) } if resp.StatusCode != http.StatusFound { - t.Errorf("Repositories.GetArchiveLink returned status: %d, want %d", resp.StatusCode, http.StatusFound) + t.Errorf("Repositories.GetArchiveLink returned status: %v, want %v", resp.StatusCode, http.StatusFound) } want := "https://github.com/a" if url.String() != want { - t.Errorf("Repositories.GetArchiveLink returned %+v, want %+v", url.String(), want) + t.Errorf("Repositories.GetArchiveLink returned %+v, want %+v", url, want) } const methodName = "GetArchiveLink" @@ -950,7 +950,7 @@ func TestRepositoriesService_GetArchiveLink_StatusMovedPermanently_dontFollowRed ctx := t.Context() _, resp, _ := client.Repositories.GetArchiveLink(ctx, "o", "r", Tarball, &RepositoryContentGetOptions{}, 0) if resp.StatusCode != http.StatusMovedPermanently { - t.Errorf("Repositories.GetArchiveLink returned status: %d, want %d", resp.StatusCode, http.StatusMovedPermanently) + t.Errorf("Repositories.GetArchiveLink returned status: %v, want %v", resp.StatusCode, http.StatusMovedPermanently) } }) } @@ -994,11 +994,11 @@ func TestRepositoriesService_GetArchiveLink_StatusMovedPermanently_followRedirec t.Errorf("Repositories.GetArchiveLink returned error: %v", err) } if resp.StatusCode != http.StatusFound { - t.Errorf("Repositories.GetArchiveLink returned status: %d, want %d", resp.StatusCode, http.StatusFound) + t.Errorf("Repositories.GetArchiveLink returned status: %v, want %v", resp.StatusCode, http.StatusFound) } want := "https://github.com/a" if url.String() != want { - t.Errorf("Repositories.GetArchiveLink returned %+v, want %+v", url.String(), want) + t.Errorf("Repositories.GetArchiveLink returned %+v, want %+v", url, want) } }) } diff --git a/github/repos_environments.go b/github/repos_environments.go index eab51a11b1d..7bc8394ac38 100644 --- a/github/repos_environments.go +++ b/github/repos_environments.go @@ -111,7 +111,7 @@ func (r *RequiredReviewer) UnmarshalJSON(data []byte) error { // //meta:operation GET /repos/{owner}/{repo}/environments func (s *RepositoriesService) ListEnvironments(ctx context.Context, owner, repo string, opts *EnvironmentListOptions) (*EnvResponse, *Response, error) { - u := fmt.Sprintf("repos/%s/%s/environments", owner, repo) + u := fmt.Sprintf("repos/%v/%v/environments", owner, repo) u, err := addOptions(u, opts) if err != nil { return nil, nil, err @@ -136,7 +136,7 @@ func (s *RepositoriesService) ListEnvironments(ctx context.Context, owner, repo // //meta:operation GET /repos/{owner}/{repo}/environments/{environment_name} func (s *RepositoriesService) GetEnvironment(ctx context.Context, owner, repo, name string) (*Environment, *Response, error) { - u := fmt.Sprintf("repos/%s/%s/environments/%s", owner, repo, name) + u := fmt.Sprintf("repos/%v/%v/environments/%v", owner, repo, name) req, err := s.client.NewRequest("GET", u, nil) if err != nil { @@ -194,7 +194,7 @@ type createUpdateEnvironmentNoEnterprise struct { // //meta:operation PUT /repos/{owner}/{repo}/environments/{environment_name} func (s *RepositoriesService) CreateUpdateEnvironment(ctx context.Context, owner, repo, name string, environment *CreateUpdateEnvironment) (*Environment, *Response, error) { - u := fmt.Sprintf("repos/%s/%s/environments/%s", owner, repo, name) + u := fmt.Sprintf("repos/%v/%v/environments/%v", owner, repo, name) req, err := s.client.NewRequest("PUT", u, environment) if err != nil { @@ -242,7 +242,7 @@ func (s *RepositoriesService) createNewEnvNoEnterprise(ctx context.Context, u st // //meta:operation DELETE /repos/{owner}/{repo}/environments/{environment_name} func (s *RepositoriesService) DeleteEnvironment(ctx context.Context, owner, repo, name string) (*Response, error) { - u := fmt.Sprintf("repos/%s/%s/environments/%s", owner, repo, name) + u := fmt.Sprintf("repos/%v/%v/environments/%v", owner, repo, name) req, err := s.client.NewRequest("DELETE", u, nil) if err != nil { diff --git a/github/repos_environments_test.go b/github/repos_environments_test.go index 05a8ad82d34..e273b512b68 100644 --- a/github/repos_environments_test.go +++ b/github/repos_environments_test.go @@ -97,7 +97,7 @@ func TestCreateUpdateEnvironment_MarshalJSON(t *testing.T) { want := `{"wait_timer":0,"reviewers":null,"can_admins_bypass":true,"deployment_branch_policy":null}` if string(got) != want { - t.Errorf("MarshalJSON = %s, want %v", got, want) + t.Errorf("MarshalJSON = %v, want %v", got, want) } } diff --git a/github/repos_hooks.go b/github/repos_hooks.go index 862dd8b0e5f..bbadab80094 100644 --- a/github/repos_hooks.go +++ b/github/repos_hooks.go @@ -143,7 +143,7 @@ func (s *RepositoriesService) ListHooks(ctx context.Context, owner, repo string, // //meta:operation GET /repos/{owner}/{repo}/hooks/{hook_id} func (s *RepositoriesService) GetHook(ctx context.Context, owner, repo string, id int64) (*Hook, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/hooks/%d", owner, repo, id) + u := fmt.Sprintf("repos/%v/%v/hooks/%v", owner, repo, id) req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, nil, err @@ -163,7 +163,7 @@ func (s *RepositoriesService) GetHook(ctx context.Context, owner, repo string, i // //meta:operation PATCH /repos/{owner}/{repo}/hooks/{hook_id} func (s *RepositoriesService) EditHook(ctx context.Context, owner, repo string, id int64, hook *Hook) (*Hook, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/hooks/%d", owner, repo, id) + u := fmt.Sprintf("repos/%v/%v/hooks/%v", owner, repo, id) req, err := s.client.NewRequest("PATCH", u, hook) if err != nil { return nil, nil, err @@ -183,7 +183,7 @@ func (s *RepositoriesService) EditHook(ctx context.Context, owner, repo string, // //meta:operation DELETE /repos/{owner}/{repo}/hooks/{hook_id} func (s *RepositoriesService) DeleteHook(ctx context.Context, owner, repo string, id int64) (*Response, error) { - u := fmt.Sprintf("repos/%v/%v/hooks/%d", owner, repo, id) + u := fmt.Sprintf("repos/%v/%v/hooks/%v", owner, repo, id) req, err := s.client.NewRequest("DELETE", u, nil) if err != nil { return nil, err @@ -197,7 +197,7 @@ func (s *RepositoriesService) DeleteHook(ctx context.Context, owner, repo string // //meta:operation POST /repos/{owner}/{repo}/hooks/{hook_id}/pings func (s *RepositoriesService) PingHook(ctx context.Context, owner, repo string, id int64) (*Response, error) { - u := fmt.Sprintf("repos/%v/%v/hooks/%d/pings", owner, repo, id) + u := fmt.Sprintf("repos/%v/%v/hooks/%v/pings", owner, repo, id) req, err := s.client.NewRequest("POST", u, nil) if err != nil { return nil, err @@ -211,7 +211,7 @@ func (s *RepositoriesService) PingHook(ctx context.Context, owner, repo string, // //meta:operation POST /repos/{owner}/{repo}/hooks/{hook_id}/tests func (s *RepositoriesService) TestHook(ctx context.Context, owner, repo string, id int64) (*Response, error) { - u := fmt.Sprintf("repos/%v/%v/hooks/%d/tests", owner, repo, id) + u := fmt.Sprintf("repos/%v/%v/hooks/%v/tests", owner, repo, id) req, err := s.client.NewRequest("POST", u, nil) if err != nil { return nil, err @@ -253,7 +253,7 @@ func (s *RepositoriesService) Unsubscribe(ctx context.Context, owner, repo, even // See: https://www.w3.org/TR/websub/#subscriber-sends-subscription-request func (s *RepositoriesService) createWebSubRequest(hubMode, owner, repo, event, callback string, secret []byte) (*http.Request, error) { topic := fmt.Sprintf( - "https://github.com/%s/%s/events/%s", + "https://github.com/%v/%v/events/%v", owner, repo, event, diff --git a/github/repos_hooks_deliveries_test.go b/github/repos_hooks_deliveries_test.go index 00401ffbb59..e171eb27e28 100644 --- a/github/repos_hooks_deliveries_test.go +++ b/github/repos_hooks_deliveries_test.go @@ -34,7 +34,7 @@ func TestRepositoriesService_ListHookDeliveries(t *testing.T) { want := []*HookDelivery{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}} if d := cmp.Diff(hooks, want); d != "" { - t.Errorf("Repositories.ListHooks want (-), got (+):\n%s", d) + t.Errorf("Repositories.ListHooks want (-), got (+):\n%v", d) } const methodName = "ListHookDeliveries" diff --git a/github/repos_prereceive_hooks.go b/github/repos_prereceive_hooks.go index 144d2ec3388..02f5ff5dedd 100644 --- a/github/repos_prereceive_hooks.go +++ b/github/repos_prereceive_hooks.go @@ -57,7 +57,7 @@ func (s *RepositoriesService) ListPreReceiveHooks(ctx context.Context, owner, re // //meta:operation GET /repos/{owner}/{repo}/pre-receive-hooks/{pre_receive_hook_id} func (s *RepositoriesService) GetPreReceiveHook(ctx context.Context, owner, repo string, id int64) (*PreReceiveHook, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/pre-receive-hooks/%d", owner, repo, id) + u := fmt.Sprintf("repos/%v/%v/pre-receive-hooks/%v", owner, repo, id) req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, nil, err @@ -81,7 +81,7 @@ func (s *RepositoriesService) GetPreReceiveHook(ctx context.Context, owner, repo // //meta:operation PATCH /repos/{owner}/{repo}/pre-receive-hooks/{pre_receive_hook_id} func (s *RepositoriesService) UpdatePreReceiveHook(ctx context.Context, owner, repo string, id int64, hook *PreReceiveHook) (*PreReceiveHook, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/pre-receive-hooks/%d", owner, repo, id) + u := fmt.Sprintf("repos/%v/%v/pre-receive-hooks/%v", owner, repo, id) req, err := s.client.NewRequest("PATCH", u, hook) if err != nil { return nil, nil, err @@ -105,7 +105,7 @@ func (s *RepositoriesService) UpdatePreReceiveHook(ctx context.Context, owner, r // //meta:operation DELETE /repos/{owner}/{repo}/pre-receive-hooks/{pre_receive_hook_id} func (s *RepositoriesService) DeletePreReceiveHook(ctx context.Context, owner, repo string, id int64) (*Response, error) { - u := fmt.Sprintf("repos/%v/%v/pre-receive-hooks/%d", owner, repo, id) + u := fmt.Sprintf("repos/%v/%v/pre-receive-hooks/%v", owner, repo, id) req, err := s.client.NewRequest("DELETE", u, nil) if err != nil { return nil, err diff --git a/github/repos_releases.go b/github/repos_releases.go index db0f0d9279f..b5cff73260b 100644 --- a/github/repos_releases.go +++ b/github/repos_releases.go @@ -93,7 +93,7 @@ func (r ReleaseAsset) String() string { // //meta:operation GET /repos/{owner}/{repo}/releases func (s *RepositoriesService) ListReleases(ctx context.Context, owner, repo string, opts *ListOptions) ([]*RepositoryRelease, *Response, error) { - u := fmt.Sprintf("repos/%s/%s/releases", owner, repo) + u := fmt.Sprintf("repos/%v/%v/releases", owner, repo) u, err := addOptions(u, opts) if err != nil { return nil, nil, err @@ -118,7 +118,7 @@ func (s *RepositoriesService) ListReleases(ctx context.Context, owner, repo stri // //meta:operation GET /repos/{owner}/{repo}/releases/{release_id} func (s *RepositoriesService) GetRelease(ctx context.Context, owner, repo string, id int64) (*RepositoryRelease, *Response, error) { - u := fmt.Sprintf("repos/%s/%s/releases/%d", owner, repo, id) + u := fmt.Sprintf("repos/%v/%v/releases/%v", owner, repo, id) return s.getSingleRelease(ctx, u) } @@ -128,7 +128,7 @@ func (s *RepositoriesService) GetRelease(ctx context.Context, owner, repo string // //meta:operation GET /repos/{owner}/{repo}/releases/latest func (s *RepositoriesService) GetLatestRelease(ctx context.Context, owner, repo string) (*RepositoryRelease, *Response, error) { - u := fmt.Sprintf("repos/%s/%s/releases/latest", owner, repo) + u := fmt.Sprintf("repos/%v/%v/releases/latest", owner, repo) return s.getSingleRelease(ctx, u) } @@ -138,7 +138,7 @@ func (s *RepositoriesService) GetLatestRelease(ctx context.Context, owner, repo // //meta:operation GET /repos/{owner}/{repo}/releases/tags/{tag} func (s *RepositoriesService) GetReleaseByTag(ctx context.Context, owner, repo, tag string) (*RepositoryRelease, *Response, error) { - u := fmt.Sprintf("repos/%s/%s/releases/tags/%s", owner, repo, tag) + u := fmt.Sprintf("repos/%v/%v/releases/tags/%v", owner, repo, tag) return s.getSingleRelease(ctx, u) } @@ -148,7 +148,7 @@ func (s *RepositoriesService) GetReleaseByTag(ctx context.Context, owner, repo, // //meta:operation POST /repos/{owner}/{repo}/releases/generate-notes func (s *RepositoriesService) GenerateReleaseNotes(ctx context.Context, owner, repo string, opts *GenerateNotesOptions) (*RepositoryReleaseNotes, *Response, error) { - u := fmt.Sprintf("repos/%s/%s/releases/generate-notes", owner, repo) + u := fmt.Sprintf("repos/%v/%v/releases/generate-notes", owner, repo) req, err := s.client.NewRequest("POST", u, opts) if err != nil { return nil, nil, err @@ -208,7 +208,7 @@ func (s *RepositoriesService) CreateRelease(ctx context.Context, owner, repo str return nil, nil, errors.New("release must be provided") } - u := fmt.Sprintf("repos/%s/%s/releases", owner, repo) + u := fmt.Sprintf("repos/%v/%v/releases", owner, repo) releaseReq := &repositoryReleaseRequest{ TagName: release.TagName, @@ -248,7 +248,7 @@ func (s *RepositoriesService) EditRelease(ctx context.Context, owner, repo strin return nil, nil, errors.New("release must be provided") } - u := fmt.Sprintf("repos/%s/%s/releases/%d", owner, repo, id) + u := fmt.Sprintf("repos/%v/%v/releases/%v", owner, repo, id) releaseReq := &repositoryReleaseRequest{ TagName: release.TagName, @@ -280,7 +280,7 @@ func (s *RepositoriesService) EditRelease(ctx context.Context, owner, repo strin // //meta:operation DELETE /repos/{owner}/{repo}/releases/{release_id} func (s *RepositoriesService) DeleteRelease(ctx context.Context, owner, repo string, id int64) (*Response, error) { - u := fmt.Sprintf("repos/%s/%s/releases/%d", owner, repo, id) + u := fmt.Sprintf("repos/%v/%v/releases/%v", owner, repo, id) req, err := s.client.NewRequest("DELETE", u, nil) if err != nil { @@ -295,7 +295,7 @@ func (s *RepositoriesService) DeleteRelease(ctx context.Context, owner, repo str // //meta:operation GET /repos/{owner}/{repo}/releases/{release_id}/assets func (s *RepositoriesService) ListReleaseAssets(ctx context.Context, owner, repo string, id int64, opts *ListOptions) ([]*ReleaseAsset, *Response, error) { - u := fmt.Sprintf("repos/%s/%s/releases/%d/assets", owner, repo, id) + u := fmt.Sprintf("repos/%v/%v/releases/%v/assets", owner, repo, id) u, err := addOptions(u, opts) if err != nil { return nil, nil, err @@ -320,7 +320,7 @@ func (s *RepositoriesService) ListReleaseAssets(ctx context.Context, owner, repo // //meta:operation GET /repos/{owner}/{repo}/releases/assets/{asset_id} func (s *RepositoriesService) GetReleaseAsset(ctx context.Context, owner, repo string, id int64) (*ReleaseAsset, *Response, error) { - u := fmt.Sprintf("repos/%s/%s/releases/assets/%d", owner, repo, id) + u := fmt.Sprintf("repos/%v/%v/releases/assets/%v", owner, repo, id) req, err := s.client.NewRequest("GET", u, nil) if err != nil { @@ -352,7 +352,7 @@ func (s *RepositoriesService) GetReleaseAsset(ctx context.Context, owner, repo s // //meta:operation GET /repos/{owner}/{repo}/releases/assets/{asset_id} func (s *RepositoriesService) DownloadReleaseAsset(ctx context.Context, owner, repo string, id int64, followRedirectsClient *http.Client) (rc io.ReadCloser, redirectURL string, err error) { - u := fmt.Sprintf("repos/%s/%s/releases/assets/%d", owner, repo, id) + u := fmt.Sprintf("repos/%v/%v/releases/assets/%v", owner, repo, id) req, err := s.client.NewRequest("GET", u, nil) if err != nil { @@ -416,7 +416,7 @@ func (s *RepositoriesService) downloadReleaseAssetFromURL(ctx context.Context, f // //meta:operation PATCH /repos/{owner}/{repo}/releases/assets/{asset_id} func (s *RepositoriesService) EditReleaseAsset(ctx context.Context, owner, repo string, id int64, release *ReleaseAsset) (*ReleaseAsset, *Response, error) { - u := fmt.Sprintf("repos/%s/%s/releases/assets/%d", owner, repo, id) + u := fmt.Sprintf("repos/%v/%v/releases/assets/%v", owner, repo, id) req, err := s.client.NewRequest("PATCH", u, release) if err != nil { @@ -437,7 +437,7 @@ func (s *RepositoriesService) EditReleaseAsset(ctx context.Context, owner, repo // //meta:operation DELETE /repos/{owner}/{repo}/releases/assets/{asset_id} func (s *RepositoriesService) DeleteReleaseAsset(ctx context.Context, owner, repo string, id int64) (*Response, error) { - u := fmt.Sprintf("repos/%s/%s/releases/assets/%d", owner, repo, id) + u := fmt.Sprintf("repos/%v/%v/releases/assets/%v", owner, repo, id) req, err := s.client.NewRequest("DELETE", u, nil) if err != nil { @@ -457,7 +457,7 @@ func (s *RepositoriesService) UploadReleaseAsset(ctx context.Context, owner, rep return nil, nil, errors.New("file must be provided") } - u := fmt.Sprintf("repos/%s/%s/releases/%d/assets", owner, repo, id) + u := fmt.Sprintf("repos/%v/%v/releases/%v/assets", owner, repo, id) u, err := addOptions(u, opts) if err != nil { return nil, nil, err diff --git a/github/repos_releases_test.go b/github/repos_releases_test.go index 5798221a8c1..6d2d5fd265d 100644 --- a/github/repos_releases_test.go +++ b/github/repos_releases_test.go @@ -588,7 +588,7 @@ func TestRepositoriesService_DownloadReleaseAsset_FollowRedirectToError(t *testi t.Error("Repositories.DownloadReleaseAsset returned stream, want nil") } if loc != "" { - t.Errorf(`Repositories.DownloadReleaseAsset returned "%s", want empty ""`, loc) + t.Errorf(`Repositories.DownloadReleaseAsset returned "%v", want empty ""`, loc) } } @@ -615,7 +615,7 @@ func TestRepositoriesService_DownloadReleaseAsset_APIError(t *testing.T) { } if loc != "" { - t.Errorf(`Repositories.DownloadReleaseAsset returned "%s", want empty ""`, loc) + t.Errorf(`Repositories.DownloadReleaseAsset returned "%v", want empty ""`, loc) } } @@ -746,7 +746,7 @@ func TestRepositoriesService_UploadReleaseAsset(t *testing.T) { client, mux, _ := setup(t) for key, test := range uploadTests { - releaseEndpoint := fmt.Sprintf("/repos/o/r/releases/%d/assets", key) + releaseEndpoint := fmt.Sprintf("/repos/o/r/releases/%v/assets", key) mux.HandleFunc(releaseEndpoint, func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") testHeader(t, r, "Content-Type", test.expectedMediaType) diff --git a/github/repos_test.go b/github/repos_test.go index aa4fe88e36f..0dc28671f81 100644 --- a/github/repos_test.go +++ b/github/repos_test.go @@ -1018,7 +1018,7 @@ func TestRepositoriesService_GetBranch_StatusMovedPermanently_followRedirects(t t.Errorf("Repositories.GetBranch returned error: %v", err) } if resp.StatusCode != http.StatusOK { - t.Errorf("Repositories.GetBranch returned status: %d, want %d", resp.StatusCode, http.StatusOK) + t.Errorf("Repositories.GetBranch returned status: %v, want %v", resp.StatusCode, http.StatusOK) } want := &Branch{ @@ -1066,7 +1066,7 @@ func TestRepositoriesService_GetBranch_notFound(t *testing.T) { t.Error("Repositories.GetBranch returned error: nil") } if resp.StatusCode != http.StatusNotFound { - t.Errorf("Repositories.GetBranch returned status: %d, want %d", resp.StatusCode, http.StatusNotFound) + t.Errorf("Repositories.GetBranch returned status: %v, want %v", resp.StatusCode, http.StatusNotFound) } // Add custom round tripper @@ -1193,7 +1193,7 @@ func TestRepositoriesService_GetBranchProtection(t *testing.T) { "required_approving_review_count":1 }, "enforce_admins":{ - "url":"%s", + "url":"%v", "enabled":true }, "restrictions":{ @@ -1333,7 +1333,7 @@ func TestRepositoriesService_GetBranchProtection_noDismissalRestrictions(t *test "required_approving_review_count":1 }, "enforce_admins":{ - "url":"%s", + "url":"%v", "enabled":true }, "restrictions":{ diff --git a/github/rules_test.go b/github/rules_test.go index 5ecdbc21d35..34a9f213ecd 100644 --- a/github/rules_test.go +++ b/github/rules_test.go @@ -254,7 +254,7 @@ func TestRulesetRules(t *testing.T) { if diff := cmp.Diff(test.json, string(got)); diff != "" { t.Errorf( - "json.Marshal returned:\n%s\nwant:\n%s\ndiff:\n%v", + "json.Marshal returned:\n%v\nwant:\n%v\ndiff:\n%v", got, test.json, diff, diff --git a/github/scim_test.go b/github/scim_test.go index 6d6fd870674..57642207ab9 100644 --- a/github/scim_test.go +++ b/github/scim_test.go @@ -568,7 +568,7 @@ func TestListSCIMProvisionedIdentitiesOptions_addOptions(t *testing.T) { StartIndex: Ptr(1), Count: Ptr(10), }, - fmt.Sprintf("%s?count=10&startIndex=1", url), + fmt.Sprintf("%v?count=10&startIndex=1", url), ) testAddURLOptions( @@ -579,7 +579,7 @@ func TestListSCIMProvisionedIdentitiesOptions_addOptions(t *testing.T) { Count: Ptr(10), Filter: Ptr("test"), }, - fmt.Sprintf("%s?count=10&filter=test&startIndex=1", url), + fmt.Sprintf("%v?count=10&filter=test&startIndex=1", url), ) } diff --git a/github/search.go b/github/search.go index a8d8a62cdcd..9f8798e14ab 100644 --- a/github/search.go +++ b/github/search.go @@ -311,7 +311,7 @@ func (s *SearchService) search(ctx context.Context, searchType string, parameter params.Set("repository_id", strconv.FormatInt(*parameters.RepositoryID, 10)) } params.Set("q", parameters.Query) - u := fmt.Sprintf("search/%s?%s", searchType, params.Encode()) + u := fmt.Sprintf("search/%v?%v", searchType, params.Encode()) req, err := s.client.NewRequest("GET", u, nil) if err != nil { diff --git a/github/security_advisories.go b/github/security_advisories.go index d99a43832e2..9d1e2513195 100644 --- a/github/security_advisories.go +++ b/github/security_advisories.go @@ -269,7 +269,7 @@ func (s *SecurityAdvisoriesService) ListGlobalSecurityAdvisories(ctx context.Con // //meta:operation GET /advisories/{ghsa_id} func (s *SecurityAdvisoriesService) GetGlobalSecurityAdvisories(ctx context.Context, ghsaID string) (*GlobalSecurityAdvisory, *Response, error) { - url := fmt.Sprintf("advisories/%s", ghsaID) + url := fmt.Sprintf("advisories/%v", ghsaID) req, err := s.client.NewRequest("GET", url, nil) if err != nil { return nil, nil, err diff --git a/github/security_advisories_test.go b/github/security_advisories_test.go index 22c3967a341..4db461a0d6a 100644 --- a/github/security_advisories_test.go +++ b/github/security_advisories_test.go @@ -538,7 +538,7 @@ func TestSecurityAdvisoriesService_ListRepositorySecurityAdvisoriesForOrg_BadReq t.Error("Expected HTTP 400 response") } if got, want := resp.Response.StatusCode, http.StatusBadRequest; got != want { - t.Errorf("ListRepositorySecurityAdvisoriesForOrg return status %d, want %d", got, want) + t.Errorf("ListRepositorySecurityAdvisoriesForOrg return status %v, want %v", got, want) } if advisories != nil { t.Errorf("ListRepositorySecurityAdvisoriesForOrg return %+v, want nil", advisories) @@ -568,7 +568,7 @@ func TestSecurityAdvisoriesService_ListRepositorySecurityAdvisoriesForOrg_NotFou t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("ListRepositorySecurityAdvisoriesForOrg return status %d, want %d", got, want) + t.Errorf("ListRepositorySecurityAdvisoriesForOrg return status %v, want %v", got, want) } if advisories != nil { t.Errorf("ListRepositorySecurityAdvisoriesForOrg return %+v, want nil", advisories) @@ -594,7 +594,7 @@ func TestSecurityAdvisoriesService_ListRepositorySecurityAdvisoriesForOrg_Unmars t.Errorf("ListRepositorySecurityAdvisoriesForOrg returned unexpected error: %v", err) } if got, want := resp.Response.StatusCode, http.StatusOK; got != want { - t.Errorf("ListRepositorySecurityAdvisoriesForOrg return status %d, want %d", got, want) + t.Errorf("ListRepositorySecurityAdvisoriesForOrg return status %v, want %v", got, want) } if advisories != nil { t.Errorf("ListRepositorySecurityAdvisoriesForOrg return %+v, want nil", advisories) @@ -623,7 +623,7 @@ func TestSecurityAdvisoriesService_ListRepositorySecurityAdvisoriesForOrg(t *tes t.Errorf("ListRepositorySecurityAdvisoriesForOrg returned error: %v, want nil", err) } if got, want := resp.Response.StatusCode, http.StatusOK; got != want { - t.Errorf("ListRepositorySecurityAdvisoriesForOrg return status %d, want %d", got, want) + t.Errorf("ListRepositorySecurityAdvisoriesForOrg return status %v, want %v", got, want) } want := []*SecurityAdvisory{ @@ -669,7 +669,7 @@ func TestSecurityAdvisoriesService_ListRepositorySecurityAdvisories_BadRequest(t t.Error("Expected HTTP 400 response") } if got, want := resp.Response.StatusCode, http.StatusBadRequest; got != want { - t.Errorf("ListRepositorySecurityAdvisories return status %d, want %d", got, want) + t.Errorf("ListRepositorySecurityAdvisories return status %v, want %v", got, want) } if advisories != nil { t.Errorf("ListRepositorySecurityAdvisories return %+v, want nil", advisories) @@ -699,7 +699,7 @@ func TestSecurityAdvisoriesService_ListRepositorySecurityAdvisories_NotFound(t * t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("ListRepositorySecurityAdvisories return status %d, want %d", got, want) + t.Errorf("ListRepositorySecurityAdvisories return status %v, want %v", got, want) } if advisories != nil { t.Errorf("ListRepositorySecurityAdvisories return %+v, want nil", advisories) @@ -725,7 +725,7 @@ func TestSecurityAdvisoriesService_ListRepositorySecurityAdvisories_UnmarshalErr t.Errorf("ListRepositorySecurityAdvisories returned unexpected error: %v", err) } if got, want := resp.Response.StatusCode, http.StatusOK; got != want { - t.Errorf("ListRepositorySecurityAdvisories return status %d, want %d", got, want) + t.Errorf("ListRepositorySecurityAdvisories return status %v, want %v", got, want) } if advisories != nil { t.Errorf("ListRepositorySecurityAdvisories return %+v, want nil", advisories) @@ -754,7 +754,7 @@ func TestSecurityAdvisoriesService_ListRepositorySecurityAdvisories(t *testing.T t.Errorf("ListRepositorySecurityAdvisories returned error: %v, want nil", err) } if got, want := resp.Response.StatusCode, http.StatusOK; got != want { - t.Errorf("ListRepositorySecurityAdvisories return status %d, want %d", got, want) + t.Errorf("ListRepositorySecurityAdvisories return status %v, want %v", got, want) } want := []*SecurityAdvisory{ diff --git a/github/strings.go b/github/strings.go index 10322301261..d7a52e283be 100644 --- a/github/strings.go +++ b/github/strings.go @@ -35,7 +35,7 @@ func stringifyValue(w *bytes.Buffer, val reflect.Value) { switch v.Kind() { case reflect.String: - fmt.Fprintf(w, `"%s"`, v) + fmt.Fprintf(w, `"%v"`, v) case reflect.Slice: w.WriteByte('[') for i := 0; i < v.Len(); i++ { @@ -55,7 +55,7 @@ func stringifyValue(w *bytes.Buffer, val reflect.Value) { // special handling of Timestamp values if v.Type() == timestampType { - fmt.Fprintf(w, "{%s}", v.Interface()) + fmt.Fprintf(w, "{%v}", v.Interface()) return } diff --git a/github/strings_test.go b/github/strings_test.go index b61d68908d5..accd8529362 100644 --- a/github/strings_test.go +++ b/github/strings_test.go @@ -76,7 +76,7 @@ func TestStringify(t *testing.T) { for i, tt := range tests { s := Stringify(tt.in) if s != tt.out { - t.Errorf("%d. Stringify(%q) => %q, want %q", i, tt.in, s, tt.out) + t.Errorf("%v. Stringify(%q) => %q, want %q", i, tt.in, s, tt.out) } } } @@ -139,7 +139,7 @@ func TestString(t *testing.T) { for i, tt := range tests { s := tt.in.(fmt.Stringer).String() if s != tt.out { - t.Errorf("%d. String() => %q, want %q", i, tt.in, tt.out) + t.Errorf("%v. String() => %q, want %q", i, tt.in, tt.out) } } } diff --git a/github/teams_members_test.go b/github/teams_members_test.go index 3f77696c30c..38e2d54e054 100644 --- a/github/teams_members_test.go +++ b/github/teams_members_test.go @@ -68,7 +68,7 @@ func TestTeamsService__ListTeamMembersByID_notFound(t *testing.T) { t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Teams.ListTeamMembersByID returned status %d, want %d", got, want) + t.Errorf("Teams.ListTeamMembersByID returned status %v, want %v", got, want) } if members != nil { t.Errorf("Teams.ListTeamMembersByID returned %+v, want nil", members) @@ -143,7 +143,7 @@ func TestTeamsService__ListTeamMembersBySlug_notFound(t *testing.T) { t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Teams.ListTeamMembersBySlug returned status %d, want %d", got, want) + t.Errorf("Teams.ListTeamMembersBySlug returned status %v, want %v", got, want) } if members != nil { t.Errorf("Teams.ListTeamMembersBySlug returned %+v, want nil", members) @@ -223,7 +223,7 @@ func TestTeamsService__GetTeamMembershipByID_notFound(t *testing.T) { t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Teams.GetTeamMembershipByID returned status %d, want %d", got, want) + t.Errorf("Teams.GetTeamMembershipByID returned status %v, want %v", got, want) } if membership != nil { t.Errorf("Teams.GetTeamMembershipByID returned %+v, want nil", membership) @@ -294,7 +294,7 @@ func TestTeamsService__GetTeamMembershipBySlug_notFound(t *testing.T) { t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Teams.GetTeamMembershipBySlug returned status %d, want %d", got, want) + t.Errorf("Teams.GetTeamMembershipBySlug returned status %v, want %v", got, want) } if membership != nil { t.Errorf("Teams.GetTeamMembershipBySlug returned %+v, want nil", membership) @@ -320,7 +320,7 @@ func TestTeamsService__GetTeamMembershipBySlug_invalidOrg(t *testing.T) { client, _, _ := setup(t) ctx := t.Context() - _, _, err := client.Teams.GetTeamMembershipBySlug(ctx, "%s", "s", "u") + _, _, err := client.Teams.GetTeamMembershipBySlug(ctx, "%v", "s", "u") testURLParseError(t, err) } @@ -392,7 +392,7 @@ func TestTeamsService__AddTeamMembershipByID_notFound(t *testing.T) { t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Teams.AddTeamMembershipByID returned status %d, want %d", got, want) + t.Errorf("Teams.AddTeamMembershipByID returned status %v, want %v", got, want) } if membership != nil { t.Errorf("Teams.AddTeamMembershipByID returned %+v, want nil", membership) @@ -481,7 +481,7 @@ func TestTeamsService__AddTeamMembershipBySlug_notFound(t *testing.T) { t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Teams.AddTeamMembershipBySlug returned status %d, want %d", got, want) + t.Errorf("Teams.AddTeamMembershipBySlug returned status %v, want %v", got, want) } if membership != nil { t.Errorf("Teams.AddTeamMembershipBySlug returned %+v, want nil", membership) @@ -552,7 +552,7 @@ func TestTeamsService__RemoveTeamMembershipByID_notFound(t *testing.T) { t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Teams.RemoveTeamMembershipByID returned status %d, want %d", got, want) + t.Errorf("Teams.RemoveTeamMembershipByID returned status %v, want %v", got, want) } const methodName = "RemoveTeamMembershipByID" @@ -607,7 +607,7 @@ func TestTeamsService__RemoveTeamMembershipBySlug_notFound(t *testing.T) { t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Teams.RemoveTeamMembershipBySlug returned status %d, want %d", got, want) + t.Errorf("Teams.RemoveTeamMembershipBySlug returned status %v, want %v", got, want) } const methodName = "RemoveTeamMembershipBySlug" @@ -684,7 +684,7 @@ func TestTeamsService__ListPendingTeamInvitationsByID_notFound(t *testing.T) { t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Teams.RemoveTeamMembershipByID returned status %d, want %d", got, want) + t.Errorf("Teams.RemoveTeamMembershipByID returned status %v, want %v", got, want) } if invitations != nil { t.Errorf("Teams.RemoveTeamMembershipByID returned %+v, want nil", invitations) @@ -759,7 +759,7 @@ func TestTeamsService__ListPendingTeamInvitationsBySlug_notFound(t *testing.T) { t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Teams.RemoveTeamMembershipByID returned status %d, want %d", got, want) + t.Errorf("Teams.RemoveTeamMembershipByID returned status %v, want %v", got, want) } if invitations != nil { t.Errorf("Teams.RemoveTeamMembershipByID returned %+v, want nil", invitations) diff --git a/github/teams_test.go b/github/teams_test.go index 60e777d91e3..735d86c3a57 100644 --- a/github/teams_test.go +++ b/github/teams_test.go @@ -112,7 +112,7 @@ func TestTeamsService_GetTeamByID_notFound(t *testing.T) { t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Teams.GetTeamByID returned status %d, want %d", got, want) + t.Errorf("Teams.GetTeamByID returned status %v, want %v", got, want) } if team != nil { t.Errorf("Teams.GetTeamByID returned %+v, want nil", team) @@ -178,7 +178,7 @@ func TestTeamsService_GetTeamBySlug_notFound(t *testing.T) { t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Teams.GetTeamBySlug returned status %d, want %d", got, want) + t.Errorf("Teams.GetTeamBySlug returned status %v, want %v", got, want) } if team != nil { t.Errorf("Teams.GetTeamBySlug returned %+v, want nil", team) @@ -693,7 +693,7 @@ func TestTeamsService_IsTeamRepoByID_false(t *testing.T) { t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Teams.IsTeamRepoByID returned status %d, want %d", got, want) + t.Errorf("Teams.IsTeamRepoByID returned status %v, want %v", got, want) } if repo != nil { t.Errorf("Teams.IsTeamRepoByID returned %+v, want nil", repo) @@ -715,7 +715,7 @@ func TestTeamsService_IsTeamRepoBySlug_false(t *testing.T) { t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Teams.IsTeamRepoByID returned status %d, want %d", got, want) + t.Errorf("Teams.IsTeamRepoByID returned status %v, want %v", got, want) } if repo != nil { t.Errorf("Teams.IsTeamRepoByID returned %+v, want nil", repo) @@ -737,7 +737,7 @@ func TestTeamsService_IsTeamRepoByID_error(t *testing.T) { t.Error("Expected HTTP 400 response") } if got, want := resp.Response.StatusCode, http.StatusBadRequest; got != want { - t.Errorf("Teams.IsTeamRepoByID returned status %d, want %d", got, want) + t.Errorf("Teams.IsTeamRepoByID returned status %v, want %v", got, want) } if repo != nil { t.Errorf("Teams.IsTeamRepoByID returned %+v, want nil", repo) @@ -759,7 +759,7 @@ func TestTeamsService_IsTeamRepoBySlug_error(t *testing.T) { t.Error("Expected HTTP 400 response") } if got, want := resp.Response.StatusCode, http.StatusBadRequest; got != want { - t.Errorf("Teams.IsTeamRepoBySlug returned status %d, want %d", got, want) + t.Errorf("Teams.IsTeamRepoBySlug returned status %v, want %v", got, want) } if repo != nil { t.Errorf("Teams.IsTeamRepoBySlug returned %+v, want nil", repo) @@ -1849,7 +1849,7 @@ func TestTeamsService_GetExternalGroup_notFound(t *testing.T) { t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Teams.GetExternalGroup returned status %d, want %d", got, want) + t.Errorf("Teams.GetExternalGroup returned status %v, want %v", got, want) } if eg != nil { t.Errorf("Teams.GetExternalGroup returned %+v, want nil", eg) @@ -1925,7 +1925,7 @@ func TestTeamsService_ListExternalGroups_notFound(t *testing.T) { t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Teams.ListExternalGroups returned status %d, want %d", got, want) + t.Errorf("Teams.ListExternalGroups returned status %v, want %v", got, want) } if eg != nil { t.Errorf("Teams.ListExternalGroups returned %+v, want nil", eg) @@ -1998,7 +1998,7 @@ func TestTeamsService_ListExternalGroupsForTeamBySlug_notFound(t *testing.T) { t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Teams.ListExternalGroupsForTeamBySlug returned status %d, want %d", got, want) + t.Errorf("Teams.ListExternalGroupsForTeamBySlug returned status %v, want %v", got, want) } if eg != nil { t.Errorf("Teams.ListExternalGroupsForTeamBySlug returned %+v, want nil", eg) @@ -2117,7 +2117,7 @@ func TestTeamsService_UpdateConnectedExternalGroup_notFound(t *testing.T) { t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Teams.UpdateConnectedExternalGroup returned status %d, want %d", got, want) + t.Errorf("Teams.UpdateConnectedExternalGroup returned status %v, want %v", got, want) } if eg != nil { t.Errorf("Teams.UpdateConnectedExternalGroup returned %+v, want nil", eg) @@ -2165,7 +2165,7 @@ func TestTeamsService_RemoveConnectedExternalGroup_notFound(t *testing.T) { t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("Teams.GetExternalGroup returned status %d, want %d", got, want) + t.Errorf("Teams.GetExternalGroup returned status %v, want %v", got, want) } } diff --git a/github/timestamp_test.go b/github/timestamp_test.go index 487a634ac1e..857cc3e7be0 100644 --- a/github/timestamp_test.go +++ b/github/timestamp_test.go @@ -41,12 +41,12 @@ func TestTimestamp_Marshal(t *testing.T) { for _, tc := range testCases { out, err := json.Marshal(tc.data) if gotErr := err != nil; gotErr != tc.wantErr { - t.Errorf("%s: gotErr=%v, wantErr=%v, err=%v", tc.desc, gotErr, tc.wantErr, err) + t.Errorf("%v: gotErr=%v, wantErr=%v, err=%v", tc.desc, gotErr, tc.wantErr, err) } got := string(out) equal := got == tc.want if (got == tc.want) != tc.equal { - t.Errorf("%s: got=%s, want=%s, equal=%v, want=%v", tc.desc, got, tc.want, equal, tc.equal) + t.Errorf("%v: got=%v, want=%v, equal=%v, want=%v", tc.desc, got, tc.want, equal, tc.equal) } } } @@ -75,12 +75,12 @@ func TestTimestamp_Unmarshal(t *testing.T) { var got Timestamp err := json.Unmarshal([]byte(tc.data), &got) if gotErr := err != nil; gotErr != tc.wantErr { - t.Errorf("%s: gotErr=%v, wantErr=%v, err=%v", tc.desc, gotErr, tc.wantErr, err) + t.Errorf("%v: gotErr=%v, wantErr=%v, err=%v", tc.desc, gotErr, tc.wantErr, err) continue } equal := got.Equal(tc.want) if equal != tc.equal { - t.Errorf("%s: got=%#v, want=%#v, equal=%v, want=%v", tc.desc, got, tc.want, equal, tc.equal) + t.Errorf("%v: got=%#v, want=%#v, equal=%v, want=%v", tc.desc, got, tc.want, equal, tc.equal) } } } @@ -97,15 +97,15 @@ func TestTimestamp_MarshalReflexivity(t *testing.T) { for _, tc := range testCases { data, err := json.Marshal(tc.data) if err != nil { - t.Errorf("%s: Marshal err=%v", tc.desc, err) + t.Errorf("%v: Marshal err=%v", tc.desc, err) } var got Timestamp err = json.Unmarshal(data, &got) if err != nil { - t.Errorf("%s: Unmarshal err=%v", tc.desc, err) + t.Errorf("%v: Unmarshal err=%v", tc.desc, err) } if !got.Equal(tc.data) { - t.Errorf("%s: %+v != %+v", tc.desc, got, data) + t.Errorf("%v: %+v != %+v", tc.desc, got, data) } } } @@ -124,19 +124,19 @@ func TestWrappedTimestamp_Marshal(t *testing.T) { wantErr bool equal bool }{ - {"Reference", WrappedTimestamp{0, Timestamp{referenceTime}}, fmt.Sprintf(`{"A":0,"Time":%s}`, referenceTimeStr), false, true}, - {"Empty", WrappedTimestamp{}, fmt.Sprintf(`{"A":0,"Time":%s}`, emptyTimeStr), false, true}, - {"Mismatch", WrappedTimestamp{}, fmt.Sprintf(`{"A":0,"Time":%s}`, referenceTimeStr), false, false}, + {"Reference", WrappedTimestamp{0, Timestamp{referenceTime}}, fmt.Sprintf(`{"A":0,"Time":%v}`, referenceTimeStr), false, true}, + {"Empty", WrappedTimestamp{}, fmt.Sprintf(`{"A":0,"Time":%v}`, emptyTimeStr), false, true}, + {"Mismatch", WrappedTimestamp{}, fmt.Sprintf(`{"A":0,"Time":%v}`, referenceTimeStr), false, false}, } for _, tc := range testCases { out, err := json.Marshal(tc.data) if gotErr := err != nil; gotErr != tc.wantErr { - t.Errorf("%s: gotErr=%v, wantErr=%v, err=%v", tc.desc, gotErr, tc.wantErr, err) + t.Errorf("%v: gotErr=%v, wantErr=%v, err=%v", tc.desc, gotErr, tc.wantErr, err) } got := string(out) equal := got == tc.want if equal != tc.equal { - t.Errorf("%s: got=%s, want=%s, equal=%v, want=%v", tc.desc, got, tc.want, equal, tc.equal) + t.Errorf("%v: got=%v, want=%v, equal=%v, want=%v", tc.desc, got, tc.want, equal, tc.equal) } } } @@ -164,12 +164,12 @@ func TestWrappedTimestamp_Unmarshal(t *testing.T) { var got Timestamp err := json.Unmarshal([]byte(tc.data), &got) if gotErr := err != nil; gotErr != tc.wantErr { - t.Errorf("%s: gotErr=%v, wantErr=%v, err=%v", tc.desc, gotErr, tc.wantErr, err) + t.Errorf("%v: gotErr=%v, wantErr=%v, err=%v", tc.desc, gotErr, tc.wantErr, err) continue } equal := got.Time.Equal(tc.want.Time.Time) if equal != tc.equal { - t.Errorf("%s: got=%#v, want=%#v, equal=%v, want=%v", tc.desc, got, tc.want, equal, tc.equal) + t.Errorf("%v: got=%#v, want=%#v, equal=%v, want=%v", tc.desc, got, tc.want, equal, tc.equal) } } } @@ -182,7 +182,7 @@ func TestTimestamp_GetTime(t *testing.T) { } t1 = &Timestamp{referenceTime} if !t1.GetTime().Equal(referenceTime) { - t.Errorf("want reference time, got: %s", t1.GetTime().String()) + t.Errorf("want reference time, got: %v", t1.GetTime()) } } @@ -198,15 +198,15 @@ func TestWrappedTimestamp_MarshalReflexivity(t *testing.T) { for _, tc := range testCases { bytes, err := json.Marshal(tc.data) if err != nil { - t.Errorf("%s: Marshal err=%v", tc.desc, err) + t.Errorf("%v: Marshal err=%v", tc.desc, err) } var got WrappedTimestamp err = json.Unmarshal(bytes, &got) if err != nil { - t.Errorf("%s: Unmarshal err=%v", tc.desc, err) + t.Errorf("%v: Unmarshal err=%v", tc.desc, err) } if !got.Time.Equal(tc.data.Time) { - t.Errorf("%s: %+v != %+v", tc.desc, got, tc.data) + t.Errorf("%v: %+v != %+v", tc.desc, got, tc.data) } } } diff --git a/github/users.go b/github/users.go index 28db59c5e1a..87dcc9a44d3 100644 --- a/github/users.go +++ b/github/users.go @@ -119,7 +119,7 @@ func (s *UsersService) Get(ctx context.Context, user string) (*User, *Response, // //meta:operation GET /user/{account_id} func (s *UsersService) GetByID(ctx context.Context, id int64) (*User, *Response, error) { - u := fmt.Sprintf("user/%d", id) + u := fmt.Sprintf("user/%v", id) req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, nil, err diff --git a/scrape/apps.go b/scrape/apps.go index b4e4366d954..8f9ca4d2c73 100644 --- a/scrape/apps.go +++ b/scrape/apps.go @@ -24,7 +24,7 @@ import ( // AppRestrictionsEnabled returns whether the specified organization has // restricted third-party application access. func (c *Client) AppRestrictionsEnabled(org string) (bool, error) { - doc, err := c.get("/organizations/%s/settings/oauth_application_policy", org) + doc, err := c.get("/organizations/%v/settings/oauth_application_policy", org) if err != nil { return false, err } @@ -47,7 +47,7 @@ func (c *Client) AppRestrictionsEnabled(org string) (bool, error) { // ListOAuthApps lists the reviewed OAuth Applications for the // specified organization (whether approved or denied). func (c *Client) ListOAuthApps(org string) ([]*OAuthApp, error) { - doc, err := c.get("/organizations/%s/settings/oauth_application_policy", org) + doc, err := c.get("/organizations/%v/settings/oauth_application_policy", org) if err != nil { return nil, err } diff --git a/scrape/payment.go b/scrape/payment.go index d00eaa9e728..6fbb3757386 100644 --- a/scrape/payment.go +++ b/scrape/payment.go @@ -18,7 +18,7 @@ import ( func (c *Client) OrgPaymentInformation(org string) (PaymentInformation, error) { var info PaymentInformation - doc, err := c.get("/organizations/%s/settings/billing/payment_information", org) + doc, err := c.get("/organizations/%v/settings/billing/payment_information", org) if err != nil { return info, err } diff --git a/test/integration/github_test.go b/test/integration/github_test.go index 58000cc9ed2..287da036e32 100644 --- a/test/integration/github_test.go +++ b/test/integration/github_test.go @@ -61,7 +61,7 @@ func createRandomTestRepository(t *testing.T, owner string, autoinit bool) *gith // create random repo name that does not currently exist var repoName string for { - repoName = fmt.Sprintf("test-%d", rand.Int()) + repoName = fmt.Sprintf("test-%v", rand.Int()) _, resp, err := client.Repositories.Get(t.Context(), owner, repoName) if err != nil { if resp.StatusCode == http.StatusNotFound { diff --git a/test/integration/pulls_test.go b/test/integration/pulls_test.go index 14b88ba9714..2a923b770cc 100644 --- a/test/integration/pulls_test.go +++ b/test/integration/pulls_test.go @@ -18,7 +18,7 @@ func TestPullRequests_ListCommits(t *testing.T) { } if got, want := len(commits), 3; got != want { - t.Fatalf("PullRequests.ListCommits() returned %d commits, want %d", got, want) + t.Fatalf("PullRequests.ListCommits() returned %v commits, want %v", got, want) } if got, want := *commits[0].Author.Login, "sqs"; got != want { diff --git a/test/integration/users_test.go b/test/integration/users_test.go index dd196aea928..182540a06eb 100644 --- a/test/integration/users_test.go +++ b/test/integration/users_test.go @@ -66,7 +66,7 @@ func TestUsers_Update(t *testing.T) { } // update location to test value - testLoc := fmt.Sprintf("test-%d", rand.Int()) + testLoc := fmt.Sprintf("test-%v", rand.Int()) u.Location = &testLoc _, _, err = client.Users.Edit(t.Context(), u) @@ -106,7 +106,7 @@ func TestUsers_Emails(t *testing.T) { var email string EmailLoop: for { - email = fmt.Sprintf("test-%d@example.com", rand.Int()) + email = fmt.Sprintf("test-%v@example.com", rand.Int()) for _, e := range emails { if e.Email != nil && *e.Email == email { continue EmailLoop @@ -226,7 +226,7 @@ func TestUsers_Keys(t *testing.T) { // Remove test key _, err = client.Users.DeleteKey(t.Context(), id) if err != nil { - t.Fatalf("Users.DeleteKey(%d) returned error: %v", id, err) + t.Fatalf("Users.DeleteKey(%v) returned error: %v", id, err) } // List keys again and verify test key was removed diff --git a/tools/fmtpercentv/fmtpercentv.go b/tools/fmtpercentv/fmtpercentv.go new file mode 100644 index 00000000000..904e709dc9c --- /dev/null +++ b/tools/fmtpercentv/fmtpercentv.go @@ -0,0 +1,96 @@ +// Copyright 2025 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package fmtpercentv is a custom linter to be used by +// golangci-lint to find instances of `%d` or `%s` in +// format strings when `%v` would be more consistent. +package fmtpercentv + +import ( + "go/ast" + "go/token" + "strings" + + "github.com/golangci/plugin-module-register/register" + "golang.org/x/tools/go/analysis" +) + +func init() { + register.Plugin("fmtpercentv", New) +} + +// FmtPercentVPlugin is a custom linter plugin for golangci-lint. +type FmtPercentVPlugin struct{} + +// New returns an analysis.Analyzer to use with golangci-lint. +func New(_ any) (register.LinterPlugin, error) { + return &FmtPercentVPlugin{}, nil +} + +// BuildAnalyzers builds the analyzers for the FmtPercentVPlugin. +func (f *FmtPercentVPlugin) BuildAnalyzers() ([]*analysis.Analyzer, error) { + return []*analysis.Analyzer{ + { + Name: "fmtpercentv", + Doc: "Reports usage of %d or %s in format strings.", + Run: run, + }, + }, nil +} + +// GetLoadMode returns the load mode for the FmtPercentVPlugin. +func (f *FmtPercentVPlugin) GetLoadMode() string { + return register.LoadModeSyntax +} + +func run(pass *analysis.Pass) (any, error) { + for _, file := range pass.Files { + ast.Inspect(file, func(n ast.Node) bool { + if n == nil { + return false + } + + switch t := n.(type) { + case *ast.CallExpr: + checkCallExpr(t, t.Pos(), pass) + } + + return true + }) + } + return nil, nil +} + +func checkCallExpr(expr *ast.CallExpr, tokenPos token.Pos, pass *analysis.Pass) { + fun, ok := expr.Fun.(*ast.SelectorExpr) + if !ok { + return + } + funX, ok := fun.X.(*ast.Ident) + if !ok { + return + } + if funX.Name != "fmt" && funX.Name != "t" { + return + } + if fun.Sel.Name != "Sprintf" && fun.Sel.Name != "Printf" && fun.Sel.Name != "Fprintf" && fun.Sel.Name != "Errorf" { + return + } + fmtStrBasicLit, ok := expr.Args[0].(*ast.BasicLit) + if !ok { + return + } + fmtStr := fmtStrBasicLit.Value + hasD := strings.Contains(fmtStr, "%d") + hasS := strings.Contains(fmtStr, "%s") + switch { + case hasD && hasS: + pass.Reportf(tokenPos, "use %%v instead of %%s and %%d") + case hasD: + pass.Reportf(tokenPos, "use %%v instead of %%d") + case hasS: + pass.Reportf(tokenPos, "use %%v instead of %%s") + } +} diff --git a/tools/fmtpercentv/fmtpercentv_test.go b/tools/fmtpercentv/fmtpercentv_test.go new file mode 100644 index 00000000000..876b1270405 --- /dev/null +++ b/tools/fmtpercentv/fmtpercentv_test.go @@ -0,0 +1,20 @@ +// Copyright 2025 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package fmtpercentv + +import ( + "testing" + + "golang.org/x/tools/go/analysis/analysistest" +) + +func TestRun(t *testing.T) { + t.Parallel() + testdata := analysistest.TestData() + plugin, _ := New(nil) + analyzers, _ := plugin.BuildAnalyzers() + analysistest.Run(t, testdata, analyzers[0], "has-warnings", "no-warnings") +} diff --git a/tools/fmtpercentv/go.mod b/tools/fmtpercentv/go.mod new file mode 100644 index 00000000000..900cebaa3cf --- /dev/null +++ b/tools/fmtpercentv/go.mod @@ -0,0 +1,13 @@ +module tools/fmtpercentv + +go 1.24.0 + +require ( + github.com/golangci/plugin-module-register v0.1.1 + golang.org/x/tools v0.29.0 +) + +require ( + golang.org/x/mod v0.22.0 // indirect + golang.org/x/sync v0.10.0 // indirect +) diff --git a/tools/fmtpercentv/go.sum b/tools/fmtpercentv/go.sum new file mode 100644 index 00000000000..c2f7392bb23 --- /dev/null +++ b/tools/fmtpercentv/go.sum @@ -0,0 +1,10 @@ +github.com/golangci/plugin-module-register v0.1.1 h1:TCmesur25LnyJkpsVrupv1Cdzo+2f7zX0H6Jkw1Ol6c= +github.com/golangci/plugin-module-register v0.1.1/go.mod h1:TTpqoB6KkwOJMV8u7+NyXMrkwwESJLOkfl9TxR1DGFc= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4= +golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= +golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= +golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/tools v0.29.0 h1:Xx0h3TtM9rzQpQuR4dKLrdglAmCEN5Oi+P74JdhdzXE= +golang.org/x/tools v0.29.0/go.mod h1:KMQVMRsVxU6nHCFXrBPhDB8XncLNLM0lIy/F14RP588= diff --git a/tools/fmtpercentv/testdata/src/has-warnings/main.go b/tools/fmtpercentv/testdata/src/has-warnings/main.go new file mode 100644 index 00000000000..a623a298286 --- /dev/null +++ b/tools/fmtpercentv/testdata/src/has-warnings/main.go @@ -0,0 +1,17 @@ +// Copyright 2025 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import "fmt" + +func main() { + _ = fmt.Sprintf("some/%d/url", 1) // want `use %v instead of %d` + _ = fmt.Sprintf("some/%s/url", "yo") // want `use %v instead of %s` + _ = fmt.Sprintf("some/%s/%d/url", "yo", 1) // want `use %v instead of %s and %d` + _ = fmt.Sprintf("some/%d/%s/url", 1, "yo") // want `use %v instead of %s and %d` + fmt.Printf("some %d", 1) // want `use %v instead of %d` + fmt.Printf("some %s", "thing") // want `use %v instead of %s` +} diff --git a/tools/fmtpercentv/testdata/src/no-warnings/main.go b/tools/fmtpercentv/testdata/src/no-warnings/main.go new file mode 100644 index 00000000000..8bbf3c4ec7e --- /dev/null +++ b/tools/fmtpercentv/testdata/src/no-warnings/main.go @@ -0,0 +1,14 @@ +// Copyright 2025 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import "fmt" + +func main() { + _ = fmt.Sprintf("some/%v/url", 1) // Should not be flagged + fmt.Printf("some %v", 1) // Should not be flagged + fmt.Printf("some %v", "thing") // Should not be flagged +} diff --git a/tools/metadata/main.go b/tools/metadata/main.go index b08ff587814..711c5bb5de5 100644 --- a/tools/metadata/main.go +++ b/tools/metadata/main.go @@ -158,7 +158,7 @@ func (c *unusedCmd) Run(root *rootCmd, k *kong.Context) error { enc.SetIndent("", " ") return enc.Encode(unused) } - fmt.Fprintf(k.Stdout, "Found %d unused operations\n", len(unused)) + fmt.Fprintf(k.Stdout, "Found %v unused operations\n", len(unused)) if len(unused) == 0 { return nil } @@ -166,7 +166,7 @@ func (c *unusedCmd) Run(root *rootCmd, k *kong.Context) error { for _, op := range unused { fmt.Fprintln(k.Stdout, op.Name) if op.DocumentationURL != "" { - fmt.Fprintf(k.Stdout, "doc: %s\n", op.DocumentationURL) + fmt.Fprintf(k.Stdout, "doc: %v\n", op.DocumentationURL) } fmt.Fprintln(k.Stdout, "") } diff --git a/tools/metadata/main_test.go b/tools/metadata/main_test.go index 8ac77135920..ebc339f4352 100644 --- a/tools/metadata/main_test.go +++ b/tools/metadata/main_test.go @@ -216,7 +216,7 @@ func checkGoldenDir(t *testing.T, origDir, resultDir, goldenDir string) { return err } golden = false - return fmt.Errorf("found unexpected file:\n%s", relPath) + return fmt.Errorf("found unexpected file:\n%v", relPath) })) } @@ -308,7 +308,7 @@ func (r testRun) assertErr(want string) { return } if strings.TrimSpace(r.err.Error()) != strings.TrimSpace(want) { - r.t.Errorf("unexpected error:\nwant:\n%s\ngot:\n%s", want, r.err.Error()) + r.t.Errorf("unexpected error:\nwant:\n%v\ngot:\n%v", want, r.err.Error()) } } @@ -339,7 +339,7 @@ func newTestServer(t *testing.T, ref string, files map[string]any) *httptest.Ser gotQuery := r.URL.Query() queryDiff := cmp.Diff(wantQuery, gotQuery) if queryDiff != "" { - t.Errorf("query mismatch for %s (-want +got):\n%s", r.URL.Path, queryDiff) + t.Errorf("query mismatch for %v (-want +got):\n%v", r.URL.Path, queryDiff) } w.WriteHeader(200) err := json.NewEncoder(w).Encode(val) @@ -407,7 +407,7 @@ func assertEqualFiles(t *testing.T, want, got string) bool { gotBytes = bytes.ReplaceAll(gotBytes, []byte("\r\n"), []byte("\n")) if !bytes.Equal(wantBytes, gotBytes) { diff := cmp.Diff(string(wantBytes), string(gotBytes)) - t.Errorf("files %q and %q differ: %s", want, got, diff) + t.Errorf("files %q and %q differ: %v", want, got, diff) return false } return true diff --git a/tools/metadata/metadata.go b/tools/metadata/metadata.go index 8e79de6b3eb..445f31a73d4 100644 --- a/tools/metadata/metadata.go +++ b/tools/metadata/metadata.go @@ -186,7 +186,7 @@ func (m *operationsFile) updateFromGithub(ctx context.Context, client *github.Cl return err } if resp.StatusCode != 200 { - return fmt.Errorf("unexpected status code: %s", resp.Status) + return fmt.Errorf("unexpected status code: %v", resp.Status) } ops, err := getOpsFromGithub(ctx, client, ref) if err != nil { @@ -281,7 +281,7 @@ func updateDocsVisitor(opsFile *operationsFile) nodeVisitor { return err } if len(ops) == 0 { - return fmt.Errorf("no operations defined for %s", serviceMethod) + return fmt.Errorf("no operations defined for %v", serviceMethod) } for _, op := range ops { @@ -343,12 +343,12 @@ func updateDocsVisitor(opsFile *operationsFile) nodeVisitor { } _, methodName, _ := strings.Cut(serviceMethod, ".") for _, opName := range undocumentedOps { - line := fmt.Sprintf("// Note: %s uses the undocumented GitHub API endpoint %q.", methodName, opName) + line := fmt.Sprintf("// Note: %v uses the undocumented GitHub API endpoint %q.", methodName, opName) group.List = append(group.List, &ast.Comment{Text: line}) } for _, op := range ops { group.List = append(group.List, &ast.Comment{ - Text: fmt.Sprintf("//meta:operation %s", op.Name), + Text: fmt.Sprintf("//meta:operation %v", op.Name), }) } group.List[0].Slash = fn.Pos() - 1 @@ -466,7 +466,7 @@ func methodOps(opsFile *operationsFile, cmap ast.CommentMap, fn *ast.FuncDecl) ( case 1: name := found[0].Name if seen[name] { - err = errors.Join(err, fmt.Errorf("duplicate operation: %s", name)) + err = errors.Join(err, fmt.Errorf("duplicate operation: %v", name)) } seen[name] = true ops = append(ops, found[0]) diff --git a/tools/metadata/openapi.go b/tools/metadata/openapi.go index 8b73cd22d22..d1de726f588 100644 --- a/tools/metadata/openapi.go +++ b/tools/metadata/openapi.go @@ -66,7 +66,7 @@ func (o *openapiFile) loadDescription(ctx context.Context, client *github.Client return err } if resp.StatusCode != 200 { - return fmt.Errorf("unexpected status code: %s", resp.Status) + return fmt.Errorf("unexpected status code: %v", resp.Status) } b, err := io.ReadAll(contents) if err != nil { @@ -119,7 +119,7 @@ func getDescriptions(ctx context.Context, client *github.Client, gitRef string) return nil, err } if resp.StatusCode != 200 { - return nil, fmt.Errorf("unexpected status code: %s", resp.Status) + return nil, fmt.Errorf("unexpected status code: %v", resp.Status) } files := make([]*openapiFile, 0, len(dir)) for _, d := range dir { @@ -129,7 +129,7 @@ func getDescriptions(ctx context.Context, client *github.Client, gitRef string) continue } file := openapiFile{ - filename: fmt.Sprintf("descriptions/%s/%s.json", d.GetName(), d.GetName()), + filename: fmt.Sprintf("descriptions/%v/%v.json", d.GetName(), d.GetName()), plan: m[pattern.SubexpIndex("plan")], planIdx: i, }