Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
2 contributors

Users who have contributed to this file

@tbpg @grant
43 lines (36 sloc) 1.16 KB
// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// [START functions_helloworld_pubsub]
// [START functions_helloworld_background]
// Package helloworld provides a set of Cloud Functions samples.
package helloworld
import (
"context"
"log"
)
// PubSubMessage is the payload of a Pub/Sub event.
type PubSubMessage struct {
Data []byte `json:"data"`
}
// HelloPubSub consumes a Pub/Sub message.
func HelloPubSub(ctx context.Context, m PubSubMessage) error {
name := string(m.Data)
if name == "" {
name = "World"
}
log.Printf("Hello, %s!", name)
return nil
}
// [END functions_helloworld_background]
// [END functions_helloworld_pubsub]
You can’t perform that action at this time.