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"`// RawPath is the path to the resource type (deprecated).// It is used by the GCS notifications shown in// https://cloud.google.com/storage/docs/pubsub-notifications,// which populate the resource field as a string containing the topic// rather than as the expected dictionary.// It is also used when triggering Cloud Functions by [Firebase Realtime Database// Triggers](https://cloud.google.com/functions/docs/calling/realtime-data).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 package, \u003ccode\u003ecloud.google.com/go/functions/metadata\u003c/code\u003e, is currently in alpha and subject to change, providing methods to create and access \u003ccode\u003econtext.Context\u003c/code\u003e objects with Google Cloud Functions metadata.\u003c/p\u003e\n"],["\u003cp\u003eThe latest version available is 1.19.4, with multiple previous versions listed down to 0.1.0, each with its corresponding documentation.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eMetadata\u003c/code\u003e struct contains information about events, including \u003ccode\u003eEventID\u003c/code\u003e, \u003ccode\u003eTimestamp\u003c/code\u003e, \u003ccode\u003eEventType\u003c/code\u003e, and \u003ccode\u003eResource\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eResource\u003c/code\u003e struct details the service, name, and type of the event trigger, and it also includes a \u003ccode\u003eRawPath\u003c/code\u003e for specific scenarios like GCS notifications or Firebase Realtime Database Triggers.\u003c/p\u003e\n"],["\u003cp\u003eFunctions like \u003ccode\u003eNewContext\u003c/code\u003e and \u003ccode\u003eFromContext\u003c/code\u003e facilitate the management of \u003ccode\u003eContext\u003c/code\u003e objects and the retrieval of \u003ccode\u003eMetadata\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,[]]