From 838cf52dbe17005ee140203c565e9673846c6efd Mon Sep 17 00:00:00 2001 From: zyfy29 Date: Sat, 16 Aug 2025 21:34:38 +0900 Subject: [PATCH 1/5] feat: add exported names check in lint config --- .golangci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.golangci.yml b/.golangci.yml index 155a00a5059..07b4a0a839d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -84,6 +84,11 @@ linters: - name: error-return - name: error-strings - name: errorf + - name: exported + arguments: + - disableChecksOnConstants + - disableChecksOnVariables + - disableStutteringCheck - name: filename-format arguments: - ^[_a-z][_a-z0-9]*.go$ From 923650472f2ed286cacaab6a921411847d9d4ee5 Mon Sep 17 00:00:00 2001 From: zyfy29 Date: Sat, 16 Aug 2025 22:09:15 +0900 Subject: [PATCH 2/5] docs: add godoc comments to enhance code documentation in the github package --- github/actions_workflow_runs.go | 1 + github/apps.go | 2 ++ github/copilot.go | 1 + github/dependency_graph.go | 4 ++++ github/git_commits.go | 3 +++ github/git_trees.go | 1 + github/github.go | 2 ++ github/orgs_audit_log.go | 2 ++ github/repos_tags.go | 12 ++++++------ github/search.go | 1 + github/security_advisories.go | 4 ++++ 11 files changed, 27 insertions(+), 6 deletions(-) diff --git a/github/actions_workflow_runs.go b/github/actions_workflow_runs.go index 52ca31fd1ef..2e20f1be36f 100644 --- a/github/actions_workflow_runs.go +++ b/github/actions_workflow_runs.go @@ -106,6 +106,7 @@ type PendingDeploymentsRequest struct { Comment string `json:"comment"` } +// ReferencedWorkflow represents a referenced workflow in a workflow run. type ReferencedWorkflow struct { Path *string `json:"path,omitempty"` SHA *string `json:"sha,omitempty"` diff --git a/github/apps.go b/github/apps.go index 3dd392d0833..658c6410c86 100644 --- a/github/apps.go +++ b/github/apps.go @@ -56,6 +56,8 @@ type InstallationTokenOptions struct { Permissions *InstallationPermissions `json:"permissions,omitempty"` } +// InstallationTokenListRepoOptions allow restricting a token's access to a list of all repositories in an installation. +// It differs from InstallationTokenListRepoOptions as a parameter which does not omit RepositoryIDs if that field is nil or an empty array. type InstallationTokenListRepoOptions struct { // The IDs of the repositories that the installation token can access. // Providing repository IDs restricts the access of an installation token to specific repositories. diff --git a/github/copilot.go b/github/copilot.go index b4f21ad39aa..25f5969ebe8 100644 --- a/github/copilot.go +++ b/github/copilot.go @@ -185,6 +185,7 @@ type CopilotMetrics struct { CopilotDotcomPullRequests *CopilotDotcomPullRequests `json:"copilot_dotcom_pull_requests,omitempty"` } +// UnmarshalJSON implements the json.Unmarshaler interface. func (cp *CopilotSeatDetails) UnmarshalJSON(data []byte) error { // Using an alias to avoid infinite recursion when calling json.Unmarshal type alias CopilotSeatDetails diff --git a/github/dependency_graph.go b/github/dependency_graph.go index 0218c79054f..8d9a263138f 100644 --- a/github/dependency_graph.go +++ b/github/dependency_graph.go @@ -10,6 +10,10 @@ import ( "fmt" ) +// DependencyGraphService handles communication with the dependency graph +// related methods of the GitHub API. +// +// GitHub API docs: https://docs.github.com/rest/dependency-graph type DependencyGraphService service // SBOM represents a software bill of materials, which describes the diff --git a/github/git_commits.go b/github/git_commits.go index e4fcc94ff10..4da15bb0d1d 100644 --- a/github/git_commits.go +++ b/github/git_commits.go @@ -37,6 +37,7 @@ type MessageSigner interface { // MessageSignerFunc is a single function implementation of MessageSigner. type MessageSignerFunc func(w io.Writer, r io.Reader) error +// Sign implements the MessageSigner interface for MessageSignerFunc. func (f MessageSignerFunc) Sign(w io.Writer, r io.Reader) error { return f(w, r) } @@ -110,6 +111,8 @@ type createCommit struct { Signature *string `json:"signature,omitempty"` } +// CreateCommitOptions specifies optional parameters to creates +// a new commit in a repository. type CreateCommitOptions struct { // CreateCommit will sign the commit with this signer. See MessageSigner doc for more details. // Ignored on commits where Verification.Signature is defined. diff --git a/github/git_trees.go b/github/git_trees.go index 3107bf73fb7..2b701a3c658 100644 --- a/github/git_trees.go +++ b/github/git_trees.go @@ -58,6 +58,7 @@ type treeEntryWithFileDelete struct { URL *string `json:"url,omitempty"` } +// MarshalJSON implements the json.Marshaler interface. func (t *TreeEntry) MarshalJSON() ([]byte, error) { if t.SHA == nil && t.Content == nil { return json.Marshal(struct { diff --git a/github/github.go b/github/github.go index bb81b00c104..42aa380f09b 100644 --- a/github/github.go +++ b/github/github.go @@ -1390,6 +1390,7 @@ func (e *Error) Error() string { e.Code, e.Field, e.Resource) } +// UnmarshalJSON implements the json.Unmarshaler interface. func (e *Error) UnmarshalJSON(data []byte) error { type aliasError Error // avoid infinite recursion by using type alias. if err := json.Unmarshal(data, (*aliasError)(e)); err != nil { @@ -1492,6 +1493,7 @@ func parseBoolResponse(err error) (bool, error) { return false, err } +// RateLimitCategory represents the enumeration of rate limit categories. type RateLimitCategory uint8 const ( diff --git a/github/orgs_audit_log.go b/github/orgs_audit_log.go index 10b3afa9bff..8aae4ef3811 100644 --- a/github/orgs_audit_log.go +++ b/github/orgs_audit_log.go @@ -56,6 +56,7 @@ type AuditEntry struct { AdditionalFields map[string]any `json:"-"` } +// UnmarshalJSON implements the json.Unmarshaler interface. func (a *AuditEntry) UnmarshalJSON(data []byte) error { type entryAlias AuditEntry var v entryAlias @@ -89,6 +90,7 @@ func (a *AuditEntry) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaler interface. func (a *AuditEntry) MarshalJSON() ([]byte, error) { type entryAlias AuditEntry v := entryAlias(*a) diff --git a/github/repos_tags.go b/github/repos_tags.go index b6dc36e2a34..0a5a5d477d3 100644 --- a/github/repos_tags.go +++ b/github/repos_tags.go @@ -22,8 +22,8 @@ type tagProtectionRequest struct { Pattern string `json:"pattern"` } -// Deprecated: ListTagProtection lists tag protection of the specified repository. -// Deprecation notice: This operation is deprecated and will be removed after August 30, 2024. Use the "Repository Rulesets" endpoint instead: https://docs.github.com/rest/repos/rules#get-all-repository-rulesets +// ListTagProtection lists tag protection of the specified repository. +// Deprecated: This operation is deprecated and will be removed after August 30, 2024. Use the "Repository Rulesets" endpoint instead: https://docs.github.com/rest/repos/rules#get-all-repository-rulesets // // GitHub API docs: https://docs.github.com/rest/repos/tags#closing-down---list-tag-protection-states-for-a-repository // @@ -45,8 +45,8 @@ func (s *RepositoriesService) ListTagProtection(ctx context.Context, owner, repo return tagProtections, resp, nil } -// Deprecated: CreateTagProtection creates the tag protection of the specified repository. -// Deprecation notice: This operation is deprecated and will be removed after August 30, 2024. Use the "Repository Rulesets" endpoint instead: https://docs.github.com/rest/repos/rules#create-a-repository-ruleset +// CreateTagProtection creates the tag protection of the specified repository. +// Deprecated: This operation is deprecated and will be removed after August 30, 2024. Use the "Repository Rulesets" endpoint instead: https://docs.github.com/rest/repos/rules#create-a-repository-ruleset // // GitHub API docs: https://docs.github.com/rest/repos/tags#closing-down---create-a-tag-protection-state-for-a-repository // @@ -68,8 +68,8 @@ func (s *RepositoriesService) CreateTagProtection(ctx context.Context, owner, re return tagProtection, resp, nil } -// Deprecated: DeleteTagProtection deletes a tag protection from the specified repository. -// Deprecation notice: This operation is deprecated and will be removed after August 30, 2024. Use the "Repository Rulesets" endpoint instead: https://docs.github.com/rest/repos/rules#delete-a-repository-ruleset +// DeleteTagProtection deletes a tag protection from the specified repository. +// Deprecated: This operation is deprecated and will be removed after August 30, 2024. Use the "Repository Rulesets" endpoint instead: https://docs.github.com/rest/repos/rules#delete-a-repository-ruleset // // GitHub API docs: https://docs.github.com/rest/repos/tags#closing-down---delete-a-tag-protection-state-for-a-repository // diff --git a/github/search.go b/github/search.go index 71b5ae51e9b..a8d8a62cdcd 100644 --- a/github/search.go +++ b/github/search.go @@ -92,6 +92,7 @@ type TopicsSearchResult struct { Topics []*TopicResult `json:"items,omitempty"` } +// TopicResult represents a topic search result. type TopicResult struct { Name *string `json:"name,omitempty"` DisplayName *string `json:"display_name,omitempty"` diff --git a/github/security_advisories.go b/github/security_advisories.go index b5a43f1aac8..d783345de86 100644 --- a/github/security_advisories.go +++ b/github/security_advisories.go @@ -11,6 +11,10 @@ import ( "fmt" ) +// SecurityAdvisoriesService handles communication with the security advisories +// related methods of the GitHub API. +// +// GitHub API docs: https://docs.github.com/rest/security-advisories type SecurityAdvisoriesService service // SecurityAdvisorySubmission represents the Security Advisory Submission. From eabdef55734744c4747c3f5c8034ca07411107ec Mon Sep 17 00:00:00 2001 From: zyfy29 Date: Sat, 16 Aug 2025 22:09:37 +0900 Subject: [PATCH 3/5] docs: add godoc comments to enhance code documentation in the sliceofpointers package --- tools/sliceofpointers/sliceofpointers.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/sliceofpointers/sliceofpointers.go b/tools/sliceofpointers/sliceofpointers.go index 75519996a7c..75b14d068dc 100644 --- a/tools/sliceofpointers/sliceofpointers.go +++ b/tools/sliceofpointers/sliceofpointers.go @@ -21,6 +21,7 @@ func init() { register.Plugin("sliceofpointers", New) } +// SliceOfPointersPlugin is a custom linter plugin for golangci-lint. type SliceOfPointersPlugin struct{} // New returns an analysis.Analyzer to use with golangci-lint. @@ -28,6 +29,7 @@ func New(_ any) (register.LinterPlugin, error) { return &SliceOfPointersPlugin{}, nil } +// BuildAnalyzers builds the analyzers for the SliceOfPointersPlugin. func (f *SliceOfPointersPlugin) BuildAnalyzers() ([]*analysis.Analyzer, error) { return []*analysis.Analyzer{ { @@ -38,6 +40,7 @@ func (f *SliceOfPointersPlugin) BuildAnalyzers() ([]*analysis.Analyzer, error) { }, nil } +// GetLoadMode returns the load mode for the SliceOfPointersPlugin. func (f *SliceOfPointersPlugin) GetLoadMode() string { return register.LoadModeSyntax } From 59e9a5f01ed10cff452e74265fc7f970772f9869 Mon Sep 17 00:00:00 2001 From: zyfy29 Date: Sat, 16 Aug 2025 22:24:52 +0900 Subject: [PATCH 4/5] docs: reference the correct comparison type name --- github/apps.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/apps.go b/github/apps.go index 658c6410c86..441a64fb14f 100644 --- a/github/apps.go +++ b/github/apps.go @@ -57,7 +57,7 @@ type InstallationTokenOptions struct { } // InstallationTokenListRepoOptions allow restricting a token's access to a list of all repositories in an installation. -// It differs from InstallationTokenListRepoOptions as a parameter which does not omit RepositoryIDs if that field is nil or an empty array. +// It differs from InstallationTokenOptions as a parameter which does not omit RepositoryIDs if that field is nil or an empty array. type InstallationTokenListRepoOptions struct { // The IDs of the repositories that the installation token can access. // Providing repository IDs restricts the access of an installation token to specific repositories. From af88e9378c7d169ac5969cc2b989262cfefd24c4 Mon Sep 17 00:00:00 2001 From: zyfy29 Date: Mon, 18 Aug 2025 20:51:58 +0900 Subject: [PATCH 5/5] docs: add an empty line before Deprecated annotation --- github/repos_tags.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/github/repos_tags.go b/github/repos_tags.go index 0a5a5d477d3..9c789cc82b6 100644 --- a/github/repos_tags.go +++ b/github/repos_tags.go @@ -23,6 +23,7 @@ type tagProtectionRequest struct { } // ListTagProtection lists tag protection of the specified repository. +// // Deprecated: This operation is deprecated and will be removed after August 30, 2024. Use the "Repository Rulesets" endpoint instead: https://docs.github.com/rest/repos/rules#get-all-repository-rulesets // // GitHub API docs: https://docs.github.com/rest/repos/tags#closing-down---list-tag-protection-states-for-a-repository @@ -46,6 +47,7 @@ func (s *RepositoriesService) ListTagProtection(ctx context.Context, owner, repo } // CreateTagProtection creates the tag protection of the specified repository. +// // Deprecated: This operation is deprecated and will be removed after August 30, 2024. Use the "Repository Rulesets" endpoint instead: https://docs.github.com/rest/repos/rules#create-a-repository-ruleset // // GitHub API docs: https://docs.github.com/rest/repos/tags#closing-down---create-a-tag-protection-state-for-a-repository @@ -69,6 +71,7 @@ func (s *RepositoriesService) CreateTagProtection(ctx context.Context, owner, re } // DeleteTagProtection deletes a tag protection from the specified repository. +// // Deprecated: This operation is deprecated and will be removed after August 30, 2024. Use the "Repository Rulesets" endpoint instead: https://docs.github.com/rest/repos/rules#delete-a-repository-ruleset // // GitHub API docs: https://docs.github.com/rest/repos/tags#closing-down---delete-a-tag-protection-state-for-a-repository