docs: Change Example_webHandler to show variables inline

Currently, users looking at Example_webHandler in godoc do not see the
responsewriter, request, or pagetemplate because only code within in the
function block itself is shown (not the signature, not vars outside).

This CL moves those variables into the code block to attempt to make it
a bit easier to grok at first blush.

Change-Id: I394b369c82253ef6cb0c0bf2f5553377571aeea0
Reviewed-on: https://code-review.googlesource.com/c/38010
Reviewed-by: Tyler Bui-Palsulich <tbp@google.com>
Reviewed-by: kokoro <noreply+kokoro@google.com>
1 file changed
tree: 64e838f0feff24946a0ecf8e26d4753b93432f5c
  1. .gitignore
  2. .hgtags
  3. AUTHORS
  4. CONTRIBUTING.md
  5. CONTRIBUTORS
  6. GettingStarted.md
  7. LICENSE
  8. NOTES
  9. README.md
  10. TODO
  11. abusiveexperiencereport/
  12. acceleratedmobilepageurl/
  13. accesscontextmanager/
  14. adexchangebuyer/
  15. adexchangebuyer2/
  16. adexchangeseller/
  17. adexperiencereport/
  18. admin/
  19. adsense/
  20. adsensehost/
  21. alertcenter/
  22. analytics/
  23. analyticsreporting/
  24. androiddeviceprovisioning/
  25. androidenterprise/
  26. androidmanagement/
  27. androidpublisher/
  28. api-list.json
  29. appengine/
  30. appsactivity/
  31. appstate/
  32. bigquery/
  33. bigquerydatatransfer/
  34. bigtableadmin/
  35. binaryauthorization/
  36. blogger/
  37. books/
  38. calendar/
  39. chat/
  40. civicinfo/
  41. classroom/
  42. cloudasset/
  43. cloudbilling/
  44. cloudbuild/
  45. clouddebugger/
  46. clouderrorreporting/
  47. cloudfunctions/
  48. cloudidentity/
  49. cloudiot/
  50. cloudkms/
  51. cloudprofiler/
  52. cloudresourcemanager/
  53. cloudscheduler/
  54. cloudsearch/
  55. cloudshell/
  56. cloudtasks/
  57. cloudtrace/
  58. composer/
  59. compute/
  60. consumersurveys/
  61. container/
  62. containeranalysis/
  63. content/
  64. customsearch/
  65. dataflow/
  66. dataproc/
  67. datastore/
  68. deploymentmanager/
  69. dfareporting/
  70. dialogflow/
  71. digitalassetlinks/
  72. discovery/
  73. dlp/
  74. dns/
  75. docs/
  76. doubleclickbidmanager/
  77. doubleclicksearch/
  78. drive/
  79. driveactivity/
  80. examples/
  81. file/
  82. firebasedynamiclinks/
  83. firebasehosting/
  84. firebaseremoteconfig/
  85. firebaserules/
  86. firestore/
  87. fitness/
  88. fusiontables/
  89. games/
  90. gamesconfiguration/
  91. gamesmanagement/
  92. genomics/
  93. gensupport/
  94. gmail/
  95. go.mod
  96. go.sum
  97. google-api-go-generator/
  98. googleapi/
  99. groupsmigration/
  100. groupssettings/
  101. iam/
  102. iamcredentials/
  103. iap/
  104. identitytoolkit/
  105. indexing/
  106. integration-tests/
  107. internal/
  108. iterator/
  109. jobs/
  110. key.json.enc
  111. kgsearch/
  112. language/
  113. lib/
  114. libraryagent/
  115. licensing/
  116. logging/
  117. manufacturers/
  118. mirror/
  119. ml/
  120. monitoring/
  121. oauth2/
  122. option/
  123. oslogin/
  124. pagespeedonline/
  125. partners/
  126. people/
  127. photoslibrary/
  128. playcustomapp/
  129. playmoviespartner/
  130. plus/
  131. plusdomains/
  132. poly/
  133. prediction/
  134. proximitybeacon/
  135. pubsub/
  136. qpxexpress/
  137. redis/
  138. remotebuildexecution/
  139. replicapool/
  140. replicapoolupdater/
  141. reseller/
  142. runtimeconfig/
  143. safebrowsing/
  144. script/
  145. searchconsole/
  146. servicebroker/
  147. serviceconsumermanagement/
  148. servicecontrol/
  149. servicemanagement/
  150. servicenetworking/
  151. serviceusage/
  152. serviceuser/
  153. sheets/
  154. siteverification/
  155. slides/
  156. sourcerepo/
  157. spanner/
  158. spectrum/
  159. speech/
  160. sqladmin/
  161. storage/
  162. storagetransfer/
  163. streetviewpublish/
  164. support/
  165. surveys/
  166. tagmanager/
  167. tasks/
  168. testing/
  169. texttospeech/
  170. toolresults/
  171. tpu/
  172. tracing/
  173. translate/
  174. transport/
  175. urlshortener/
  176. vault/
  177. videointelligence/
  178. vision/
  179. webfonts/
  180. webmasters/
  181. websecurityscanner/
  182. youtube/
  183. youtubeanalytics/
  184. youtubereporting/
README.md

Google APIs Client Library for Go

Getting Started

$ go get google.golang.org/api/tasks/v1
$ go get google.golang.org/api/moderator/v1
$ go get google.golang.org/api/urlshortener/v1
... etc ...

and using:

package main

import (
	"net/http"

	"google.golang.org/api/urlshortener/v1"
)

func main() {
	svc, err := urlshortener.New(http.DefaultClient)
	// ...
}

Status

GoDoc

These are auto-generated Go libraries from the Google Discovery Service's JSON description files of the available “new style” Google APIs.

Due to the auto-generated nature of this collection of libraries, complete APIs or specific versions can appear or go away without notice. As a result, you should always locally vendor any API(s) that your code relies upon.

These client libraries are officially supported by Google. However, the libraries are considered complete and are in maintenance mode. This means that we will address critical bugs and security issues but will not add any new features.

If you're working with Google Cloud Platform APIs such as Datastore or Pub/Sub, consider using the Cloud Client Libraries for Go instead. These are the new and idiomatic Go libraries targeted specifically at Google Cloud Platform Services.

The generator itself and the code it produces are beta. Some APIs are alpha/beta, and indicated as such in the import path (e.g., “google.golang.org/api/someapi/v1alpha”).

Application Default Credentials Example

Application Default Credentials provide a simplified way to obtain credentials for authenticating with Google APIs.

The Application Default Credentials authenticate as the application itself, which make them great for working with Google Cloud APIs like Storage or Datastore. They are the recommended form of authentication when building applications that run on Google Compute Engine or Google App Engine.

Default credentials are provided by the golang.org/x/oauth2/google package. To use them, add the following import:

import "golang.org/x/oauth2/google"

Some credentials types require you to specify scopes, and service entry points may not inject them. If you encounter this situation you may need to specify scopes as follows:

import (
        "context"
        "golang.org/x/oauth2/google"
        "google.golang.org/api/compute/v1"
)

func main() {
        // Use oauth2.NoContext if there isn't a good context to pass in.
        ctx := context.Background()

        client, err := google.DefaultClient(ctx, compute.ComputeScope)
        if err != nil {
                //...
        }
        computeService, err := compute.New(client)
        if err != nil {
                //...
        }
}

If you need a oauth2.TokenSource, use the DefaultTokenSource function:

ts, err := google.DefaultTokenSource(ctx, scope1, scope2, ...)
if err != nil {
        //...
}
client := oauth2.NewClient(ctx, ts)

See also: golang.org/x/oauth2/google package documentation.