Repository: google/go-github
File: github/sub_issue.go (Go)

Code before:
	u := fmt.Sprintf("repos/%v/%v/issues/%v/sub_issues", owner, repo, subIssueNumber)

	req, err := s.client.NewRequest("DELETE", u, subIssue)
	if err != nil {
		return nil, nil, err
	}

	// TODO: remove custom Accept header when this API fully launches.
	req.Header.Set("Accept", mediaTypeV3)

	si := new(SubIssue)
	resp, err := s.client.Do(ctx, req, si)
	if err != nil {
		return nil, resp, err
	}

	return si, resp, nil
}

// ListByIssue lists all sub-issues for the specified issue.
//
// GitHub API docs: https://docs.github.com/rest/issues/sub-issues#list-sub-issues
//
//meta:operation GET /repos/{owner}/{repo}/issues/{issue_number}/sub_issues
func (s *SubIssueService) ListByIssue(ctx context.Context, owner, repo string, issueNumber int64, opts *IssueListOptions) ([]*SubIssue, *Response, error) {
	u := fmt.Sprintf("repos/%v/%v/issues/%d/sub_issues", owner, repo, issueNumber)
	u, err := addOptions(u, opts)
	if err != nil {
		return nil, nil, err
	}

	req, err := s.client.NewRequest("GET", u, nil)
	if err != nil {
		return nil, nil, err
	}

	// TODO: remove custom Accept header when this API fully launches.
	req.Header.Set("Accept", mediaTypeV3)

	var subIssues []*SubIssue
	resp, err := s.client.Do(ctx, req, &subIssues)
	if err != nil {
		return nil, resp, err
	}

	return subIssues, resp, nil
}

// Add adds a sub-issue to the specified issue.
//
// The sub-issue to be added must belong to the same repository owner as the parent issue.

Review comment (suggestion):
In this repo, we use `%v` unless there is a really good reason not to, so that it is super-easy to find an endpoint just by searching through the code for something like `repos/%v/%v/issues/%v/sub_issues` since we know that we have been consistent with the usage of `%v`.

```suggestion
	u := fmt.Sprintf("repos/%v/%v/issues/%v/sub_issues", owner, repo, issueNumber)
```

Code after:
	u := fmt.Sprintf("repos/%v/%v/issues/%v/sub_issues", owner, repo, subIssueNumber)

	req, err := s.client.NewRequest("DELETE", u, subIssue)
	if err != nil {
		return nil, nil, err
	}

	si := new(SubIssue)
	resp, err := s.client.Do(ctx, req, si)
	if err != nil {
		return nil, resp, err
	}

	return si, resp, nil
}

// ListByIssue lists all sub-issues for the specified issue.
//
// GitHub API docs: https://docs.github.com/rest/issues/sub-issues#list-sub-issues
//
//meta:operation GET /repos/{owner}/{repo}/issues/{issue_number}/sub_issues
func (s *SubIssueService) ListByIssue(ctx context.Context, owner, repo string, issueNumber int64, opts *IssueListOptions) ([]*SubIssue, *Response, error) {
	u := fmt.Sprintf("repos/%v/%v/issues/%v/sub_issues", owner, repo, issueNumber)
	u, err := addOptions(u, opts)
	if err != nil {
		return nil, nil, err
	}

	req, err := s.client.NewRequest("GET", u, nil)
	if err != nil {
		return nil, nil, err
	}

	var subIssues []*SubIssue
	resp, err := s.client.Do(ctx, req, &subIssues)
	if err != nil {
		return nil, resp, err
	}

	return subIssues, resp, nil
}

// Add adds a sub-issue to the specified issue.
//
// The sub-issue to be added must belong to the same repository owner as the parent issue.
// To replace the existing parent of a sub-issue, set replaceParent to true.
//
// GitHub API docs: https://docs.github.com/rest/issues/sub-issues#add-sub-issue
//
//meta:operation POST /repos/{owner}/{repo}/issues/{issue_number}/sub_issues
func (s *SubIssueService) Add(ctx context.Context, owner, repo string, issueNumber int64, subIssue SubIssueRequest) (*SubIssue, *Response, error) {