Skip to content

Commit

Permalink
[UPDATED] Examples moved to their own directory
Browse files Browse the repository at this point in the history
Each example has been moved to its own directory (and .go file changed
to main.go, and build directive removed).
With this change, once you `go get` the library, you can intall
all examples with the following command:

```
go install github.com/nats-io/go-nats-streaming/examples/*
```

Also fixed some issues reported by megacheck.

Resolves #164
  • Loading branch information
Ivan authored and kozlovic committed Jan 15, 2018
1 parent 43723aa commit b024e8a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
File renamed without changes.
3 changes: 1 addition & 2 deletions examples/stan-pub.go → examples/stan-pub/main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Copyright 2012-2016 Apcera Inc. All rights reserved.
// +build ignore

package main

Expand Down Expand Up @@ -79,7 +78,7 @@ func main() {
ch <- true
}

if async != true {
if !async {
err = sc.Publish(subj, msg)
if err != nil {
log.Fatalf("Error during publish: %v\n", err)
Expand Down
7 changes: 3 additions & 4 deletions examples/stan-sub.go → examples/stan-sub/main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Copyright 2012-2016 Apcera Inc. All rights reserved.
// +build ignore

package main

Expand Down Expand Up @@ -106,9 +105,9 @@ func main() {

if startSeq != 0 {
startOpt = stan.StartAtSequence(startSeq)
} else if deliverLast == true {
} else if deliverLast {
startOpt = stan.StartWithLastReceived()
} else if deliverAll == true {
} else if deliverAll {
log.Print("subscribing with DeliverAllAvailable")
startOpt = stan.DeliverAllAvailable()
} else if startDelta != "" {
Expand Down Expand Up @@ -138,7 +137,7 @@ func main() {
cleanupDone := make(chan bool)
signal.Notify(signalChan, os.Interrupt)
go func() {
for _ = range signalChan {
for range signalChan {
fmt.Printf("\nReceived an interrupt, unsubscribing and closing connection...\n\n")
// Do not unsubscribe a durable on exit, except if asked to.
if durable == "" || unsubscribe {
Expand Down

0 comments on commit b024e8a

Please sign in to comment.