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

Code before:
func (s *SubIssueService) Remove(ctx context.Context, owner string, repo string, subIssueNumber int, subIssue *SubIssueRequest) (*SubIssue, *Response, error) {
	u := fmt.Sprintf("repos/%v/%v/issues/%d/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 string, repo string, issueNumber int, 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.
//

Review comment (suggestion):
```suggestion
func (s *SubIssueService) ListByIssue(ctx context.Context, owner, repo string, issueNumber int64, opts *IssueListOptions) ([]*SubIssue, *Response, error) {
```

Code after:
func (s *SubIssueService) Remove(ctx context.Context, owner, repo string, subIssueNumber int64, subIssue SubIssueRequest) (*SubIssue, *Response, error) {
	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