google / google/go-github

Refactor codebase to use value parameters instead of pointers where appropriate

Aperta
#3,644 24 commenti 4 reazioni 3 assegnatari Vedi su GitHub

@ManavSharma142 ci sta già lavorando.

Dal 5/8/2026.

Breaking API Change enhancement good first issue
Lingua principale
Go
Stelle
11.3k
Fork
2.5k
Merge medio
1g 20h
PR unite (30g)
53

Descrizione

Many methods in the codebase, such as:


func (s *RepositoriesService) CreateRelease(ctx context.Context, owner, repo string, release *RepositoryRelease) (*RepositoryRelease, *Response, error)

use pointer parameters (e.g. *RepositoryRelease) even when the function doesn't mutate the input. This appears to be a result of convention or copy-paste, not a performance-driven choice.

For instance, in CreateRelease, the RepositoryRelease struct is relatively large (~15+ fields), but most of its fields are pointers themselves. As such, passing it by value would have negligible performance impact in typical API usage. Moreover, value semantics would improve clarity, especially for required arguments that aren't modified.

To improve API design consistency and safety, we should:

  • Audit method signatures that accept pointer structs as input

  • Change them to accept values when:

    • The input is required (not optional)

    • The function does not modify the input

  • Optionally introduce dedicated input structs for specific operations (e.g. CreateRepositoryRelease with only the fields needed for creation)

Note: This would be a breaking change and should be handled carefully, possibly across multiple PRs.

Originally posted by @gmlewis in https://github.com/google/go-github/pull/3636#discussion_r2228429223

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.