()
| 72 | } |
| 73 | |
| 74 | func ExampleRepositoriesService_CreateFile() { |
| 75 | // In this example we're creating a new file in a repository using the |
| 76 | // Contents API. Only 1 file per commit can be managed through that API. |
| 77 | |
| 78 | // Note that authentication is needed here as you are performing a modification |
| 79 | // so you will need to modify the example to provide authentication to |
| 80 | // github.NewClient(). See the following documentation for more information |
| 81 | // on how to authenticate with the client: |
| 82 | // https://pkg.go.dev/github.com/google/go-github/v88/github#hdr-Authentication |
| 83 | client, err := github.NewClient() |
| 84 | if err != nil { |
| 85 | log.Fatalf("Error creating GitHub client: %v", err) |
| 86 | } |
| 87 | |
| 88 | ctx := context.Background() |
| 89 | fileContent := []byte("This is the content of my file\nand the 2nd line of it") |
| 90 | |
| 91 | // Note: the file needs to be absent from the repository as you are not |
| 92 | // specifying a SHA reference here. |
| 93 | opts := &github.RepositoryContentFileOptions{ |
| 94 | Message: github.Ptr("This is my commit message"), |
| 95 | Content: fileContent, |
| 96 | Branch: github.Ptr("master"), |
| 97 | Committer: &github.CommitAuthor{Name: github.Ptr("FirstName LastName"), Email: github.Ptr("user@example.com")}, |
| 98 | } |
| 99 | if _, _, err := client.Repositories.CreateFile(ctx, "myOrganization", "myRepository", "myNewFile.md", opts); err != nil { |
| 100 | log.Fatalf("Error creating file: %v", err) |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | func ExampleUsersService_ListAll() { |
| 105 | client, err := github.NewClient() |
nothing calls this directly
no test coverage detected
searching dependent graphs…