// Copyright 2013 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 githubimport ()// RepositoryListForksOptions specifies the optional parameters to the// RepositoriesService.ListForks method.typeRepositoryListForksOptionsstruct {// How to sort the forks list. Possible values are: newest, oldest, // watchers. Default is "newest". Sort string`url:"sort,omitempty"`ListOptions}// ListForks lists the forks of the specified repository.//// GitHub API docs: https://docs.github.com/rest/repos/forks#list-forks////meta:operation GET /repos/{owner}/{repo}/forksfunc ( *RepositoriesService) ( context.Context, , string, *RepositoryListForksOptions) ([]*Repository, *Response, error) { := fmt.Sprintf("repos/%v/%v/forks", , ) , := addOptions(, )if != nil {returnnil, nil, } , := .client.NewRequest("GET", , nil)if != nil {returnnil, nil, }// TODO: remove custom Accept header when topics API fully launches. .Header.Set("Accept", mediaTypeTopicsPreview)var []*Repository , := .client.Do(, , &)if != nil {returnnil, , }return , , nil}// RepositoryCreateForkOptions specifies the optional parameters to the// RepositoriesService.CreateFork method.typeRepositoryCreateForkOptionsstruct {// The organization to fork the repository into. Organization string`json:"organization,omitempty"` Name string`json:"name,omitempty"` DefaultBranchOnly bool`json:"default_branch_only,omitempty"`}// CreateFork creates a fork of the specified repository.//// This method might return an *AcceptedError and a status code of// 202. This is because this is the status that GitHub returns to signify that// it is now computing creating the fork in a background task. In this event,// the Repository value will be returned, which includes the details about the pending fork.// A follow up request, after a delay of a second or so, should result// in a successful request.//// GitHub API docs: https://docs.github.com/rest/repos/forks#create-a-fork////meta:operation POST /repos/{owner}/{repo}/forksfunc ( *RepositoriesService) ( context.Context, , string, *RepositoryCreateForkOptions) (*Repository, *Response, error) { := fmt.Sprintf("repos/%v/%v/forks", , ) , := .client.NewRequest("POST", , )if != nil {returnnil, nil, } := new(Repository) , := .client.Do(, , )if != nil {// Persist AcceptedError's metadata to the Repository object.if , := .(*AcceptedError); {if := json.Unmarshal(.Raw, ); != nil {return , , }return , , }returnnil, , }return , , nil}
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.