NewContext returns a new Context carrying m. If m is nil, NewContext returns
ctx. NewContext is only used for writing tests which rely on Metadata.
Metadata
typeMetadatastruct{// EventID is a unique ID for the event. For example: "70172329041928".EventIDstring`json:"eventId"`// Timestamp is the date/time this event was created.Timestamptime.Time`json:"timestamp"`// EventType is the type of the event. For example: "google.pubsub.topic.publish".EventTypestring`json:"eventType"`// Resource is the resource that triggered the event.Resource*Resource`json:"resource"`}
FromContext extracts the Metadata from the Context, if present.
Resource
typeResourcestruct{// Service is the service that triggered the event.Servicestring`json:"service"`// Name is the name associated with the event.Namestring`json:"name"`// Type is the type of event.Typestring`json:"type"`// Path is the path to the resource type (deprecated).// This is the case for some deprecated GCS// notifications, which populate the resource field as a string containing the topic// rather than as the expected dictionary.// See the Attributes section of https://cloud.google.com/storage/docs/pubsub-notifications// for more details.RawPathstring`json:"-"`}
Resource holds Google Cloud Functions resource metadata.
Resource values are dependent on the event type they're from.
MarshalJSON specializes the Resource marshalling to handle the case where the
value is a string instead of a map. See the comment above on RawPath for why this
needs to be handled.
UnmarshalJSON specializes the Resource unmarshalling to handle the case where the
value is a string instead of a map. See the comment above on RawPath for why this
needs to be handled.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003eThis page provides documentation for the \u003ccode\u003ecloud.google.com/go/functions/metadata\u003c/code\u003e package, which is currently in alpha and therefore subject to change and limited support.\u003c/p\u003e\n"],["\u003cp\u003eThe package offers methods for managing \u003ccode\u003econtext.Context\u003c/code\u003e objects that contain Google Cloud Functions metadata, such as event IDs, timestamps, event types, and associated resources.\u003c/p\u003e\n"],["\u003cp\u003eThe latest version of this package is 1.19.4, with multiple older versions also listed, going back to version 0.1.0, offering a wide range of releases.\u003c/p\u003e\n"],["\u003cp\u003eThe package includes \u003ccode\u003eMetadata\u003c/code\u003e and \u003ccode\u003eResource\u003c/code\u003e types to structure event and resource details, along with functions like \u003ccode\u003eNewContext\u003c/code\u003e and \u003ccode\u003eFromContext\u003c/code\u003e for handling metadata within contexts.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eResource\u003c/code\u003e type includes specialized JSON marshalling and unmarshalling to accommodate cases where resource data is represented as a string rather than a map, necessary for handling deprecated Google Cloud Storage notifications.\u003c/p\u003e\n"]]],[],null,[]]