{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/pulls/comments/37777352","id":37777352,"diff_hunk":"@@ -0,0 +1,69 @@\n+// Copyright [yyyy] [name of copyright owner]\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//\n+//     http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS,\n+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+// See the License for the specific language governing permissions and\n+// limitations under the License.\n+\n+package main\n+\n+import (\n+\t\"fmt\"\n+\t\"log\"\n+\t\"os\"\n+)\n+import (\n+\t\"golang.org/x/oauth2\"\n+\t\"golang.org/x/oauth2/google\"\n+\tstorage \"google.golang.org/api/storage/v1\"\n+)\n+\n+// ListBuckets returns a slice of all the buckets in the given projectId.\n+// [START listBuckets]\n+func ListBuckets(projectId string) ([]*storage.Bucket, error) {\n+\t// Create the client that uses Application Default Credentials\n+\tclient, err := google.DefaultClient(\n+\t\toauth2.NoContext,\n+\t\t\"https://www.googleapis.com/auth/devstorage.read_only\")\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\n+\t// Create the Google Cloud Storage service\n+\tservice, err := storage.New(client)\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\n+\t// Create the request to list buckets for the project id\n+\trequest := service.Buckets.List(projectId)\n+\n+\t// Execute the request\n+\tbuckets, err := request.Do()\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\n+\treturn buckets.Items, nil\n+}\n+\n+// [END listBuckets]\n+\n+// main will simply retrieve a list of buckets and print them.\n+func main() {\n+\tif buckets, err := ListBuckets(os.Getenv(\"TEST_PROJECT_ID\")); err == nil {\n+\t\t// Print out the results\n+\t\tfor _, bucket := range buckets {\n+\t\t\tfmt.Println(bucket.Name)\n+\t\t}\n+\t} else {\n+\t\tlog.Fatal(err.Error())\n+\t}\n+}","path":"storage/list_buckets.go","position":69,"original_position":69,"commit_id":"c8df28164be5d37b98fb110e4b7d3d0c420c1ebc","original_commit_id":"c8df28164be5d37b98fb110e4b7d3d0c420c1ebc","user":{"login":"jeffmendoza","id":771387,"avatar_url":"https://avatars.githubusercontent.com/u/771387?v=3","gravatar_id":"","url":"https://api.github.com/users/jeffmendoza","html_url":"https://github.com/jeffmendoza","followers_url":"https://api.github.com/users/jeffmendoza/followers","following_url":"https://api.github.com/users/jeffmendoza/following{/other_user}","gists_url":"https://api.github.com/users/jeffmendoza/gists{/gist_id}","starred_url":"https://api.github.com/users/jeffmendoza/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeffmendoza/subscriptions","organizations_url":"https://api.github.com/users/jeffmendoza/orgs","repos_url":"https://api.github.com/users/jeffmendoza/repos","events_url":"https://api.github.com/users/jeffmendoza/events{/privacy}","received_events_url":"https://api.github.com/users/jeffmendoza/received_events","type":"User","site_admin":false},"body":"change to err !=nil, put the log.Fatal first, and remove the else.","created_at":"2015-08-24T17:30:39Z","updated_at":"2015-08-24T17:30:39Z","html_url":"https://github.com/GoogleCloudPlatform/go-docs-samples/pull/2#discussion_r37777352","pull_request_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/pulls/comments/37777352"},"html":{"href":"https://github.com/GoogleCloudPlatform/go-docs-samples/pull/2#discussion_r37777352"},"pull_request":{"href":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/pulls/2","id":43096644,"html_url":"https://github.com/GoogleCloudPlatform/go-docs-samples/pull/2","diff_url":"https://github.com/GoogleCloudPlatform/go-docs-samples/pull/2.diff","patch_url":"https://github.com/GoogleCloudPlatform/go-docs-samples/pull/2.patch","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/issues/2","number":2,"state":"open","locked":false,"title":"Add cloud storage listBuckets sample.","user":{"login":"jerjou","id":913439,"avatar_url":"https://avatars.githubusercontent.com/u/913439?v=3","gravatar_id":"","url":"https://api.github.com/users/jerjou","html_url":"https://github.com/jerjou","followers_url":"https://api.github.com/users/jerjou/followers","following_url":"https://api.github.com/users/jerjou/following{/other_user}","gists_url":"https://api.github.com/users/jerjou/gists{/gist_id}","starred_url":"https://api.github.com/users/jerjou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jerjou/subscriptions","organizations_url":"https://api.github.com/users/jerjou/orgs","repos_url":"https://api.github.com/users/jerjou/repos","events_url":"https://api.github.com/users/jerjou/events{/privacy}","received_events_url":"https://api.github.com/users/jerjou/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-08-22T03:22:29Z","updated_at":"2015-08-24T17:30:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c7b06e1c861da22b49e254223163e6e59383cb81","assignee":{"login":"jeffmendoza","id":771387,"avatar_url":"https://avatars.githubusercontent.com/u/771387?v=3","gravatar_id":"","url":"https://api.github.com/users/jeffmendoza","html_url":"https://github.com/jeffmendoza","followers_url":"https://api.github.com/users/jeffmendoza/followers","following_url":"https://api.github.com/users/jeffmendoza/following{/other_user}","gists_url":"https://api.github.com/users/jeffmendoza/gists{/gist_id}","starred_url":"https://api.github.com/users/jeffmendoza/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeffmendoza/subscriptions","organizations_url":"https://api.github.com/users/jeffmendoza/orgs","repos_url":"https://api.github.com/users/jeffmendoza/repos","events_url":"https://api.github.com/users/jeffmendoza/events{/privacy}","received_events_url":"https://api.github.com/users/jeffmendoza/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/pulls/2/commits","review_comments_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/pulls/2/comments","review_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/issues/2/comments","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/statuses/c8df28164be5d37b98fb110e4b7d3d0c420c1ebc","head":{"label":"GoogleCloudPlatform:listBuckets","ref":"listBuckets","sha":"c8df28164be5d37b98fb110e4b7d3d0c420c1ebc","user":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"repo":{"id":35065898,"name":"go-docs-samples","full_name":"GoogleCloudPlatform/go-docs-samples","owner":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleCloudPlatform/go-docs-samples","description":"","fork":false,"url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples","forks_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/forks","keys_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/teams","hooks_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/hooks","issue_events_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/events","assignees_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/tags","blobs_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/languages","stargazers_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/stargazers","contributors_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/contributors","subscribers_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/subscribers","subscription_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/subscription","commits_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/merges","archive_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/downloads","issues_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/labels{/name}","releases_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/releases{/id}","created_at":"2015-05-04T23:26:58Z","updated_at":"2015-08-22T13:24:04Z","pushed_at":"2015-08-24T17:14:36Z","git_url":"git://github.com/GoogleCloudPlatform/go-docs-samples.git","ssh_url":"git@github.com:GoogleCloudPlatform/go-docs-samples.git","clone_url":"https://github.com/GoogleCloudPlatform/go-docs-samples.git","svn_url":"https://github.com/GoogleCloudPlatform/go-docs-samples","homepage":null,"size":168,"stargazers_count":1,"watchers_count":1,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"GoogleCloudPlatform:master","ref":"master","sha":"bc52aa78c401d7b8dc1c213f8e91c2a4d67b8cba","user":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"repo":{"id":35065898,"name":"go-docs-samples","full_name":"GoogleCloudPlatform/go-docs-samples","owner":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleCloudPlatform/go-docs-samples","description":"","fork":false,"url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples","forks_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/forks","keys_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/teams","hooks_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/hooks","issue_events_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/events","assignees_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/tags","blobs_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/languages","stargazers_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/stargazers","contributors_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/contributors","subscribers_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/subscribers","subscription_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/subscription","commits_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/merges","archive_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/downloads","issues_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/labels{/name}","releases_url":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/releases{/id}","created_at":"2015-05-04T23:26:58Z","updated_at":"2015-08-22T13:24:04Z","pushed_at":"2015-08-24T17:14:36Z","git_url":"git://github.com/GoogleCloudPlatform/go-docs-samples.git","ssh_url":"git@github.com:GoogleCloudPlatform/go-docs-samples.git","clone_url":"https://github.com/GoogleCloudPlatform/go-docs-samples.git","svn_url":"https://github.com/GoogleCloudPlatform/go-docs-samples","homepage":null,"size":168,"stargazers_count":1,"watchers_count":1,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/pulls/2"},"html":{"href":"https://github.com/GoogleCloudPlatform/go-docs-samples/pull/2"},"issue":{"href":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/issues/2"},"comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleCloudPlatform/go-docs-samples/statuses/c8df28164be5d37b98fb110e4b7d3d0c420c1ebc"}}}}