Skip to content

Instantly share code, notes, and snippets.

@rickenharp
Created August 16, 2017 15:12
Show Gist options
  • Save rickenharp/55bdb6dc488e5c93d631e1ccff7f6ce8 to your computer and use it in GitHub Desktop.
Save rickenharp/55bdb6dc488e5c93d631e1ccff7f6ce8 to your computer and use it in GitHub Desktop.
Gogland EAP 12 type compatibility error
package main
import (
"log"
"os"
"fmt"
"cloud.google.com/go/pubsub"
"golang.org/x/net/context"
)
func main() {
os.Setenv("PUBSUB_EMULATOR_HOST", "localhost:8085")
ctx := context.Background()
ps, err := pubsub.NewClient(ctx, "alice-dev-160410")
if err != nil {
log.Fatal(err)
}
topic := ps.Topic("fnord")
message := pubsub.Message{Data: []byte("ping")}
sub := ps.Subscription("fnord-sub")
topic.Publish(ctx, &message)
cctx, cancel := context.WithCancel(ctx)
sub.Receive(cctx, func(cctx context.Context, msg *pubsub.Message) {
fmt.Println(msg.Data)
cancel()
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment