Registry / messaging / go-pubsub

go-pubsub

JSON →
library1.50.2gogounverified

Package pubsub provides an easy way to publish and receive Google Cloud Pub/Sub messages, hiding the details of the underlying server RPCs.

go get cloud.google.com/go/pubsub
INSTALL
IMPORT
SIG · GO-PUBSUB
G
go-pubsub
messaginggov1.50.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

pubsub
cloud.google.com/go/pubsub

Publishes a message to a Google Cloud Pub/Sub topic.

package main import ( "context" "fmt" "cloud.google.com/go/pubsub" ) func main() { ctx := context.Background() client, err := pubsub.NewClient(ctx, "my-project") if err != nil { panic(err) } defer client.Close() topic := client.Topic("my-topic") result := topic.Publish(ctx, &pubsub.Message{Data: []byte("hello")}) id, _ := result.Get(ctx) fmt.Printf("Published message with ID: %s\n", id) }
Debug
Known issues
gotchaRequires Google Cloud authentication and billing setup.
fix
Set up application default credentials or use a service account key.
affects: all
Upgrade
Version history
1.50.2latest on pkg.go.dev
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
10
Resources
go-pubsub — go get go-pubsub · libregistry