Skip to content

Commit

Permalink
APP-34433: Small bug fix and bit cleaner example (#45)
Browse files Browse the repository at this point in the history
* fix: s/Fprintln/Fprint/ - don't add newline when printing

* chore: clean up example

* chore: update comment

* chore: update the version for the sake of patching
  • Loading branch information
tonsV2 authored Mar 3, 2023
1 parent d8c9e01 commit 48383f0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions examples/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ func main() {
if err != nil {
panic(err)
}
// Old default way, still works
//dumpExec := dump.Exec(pg.ExecOptions{StreamPrint: false})

// Note that any io.Writer could be assigned to StreamDestination. For simplicity, I'm just using stdout here.
// But we could write to a unix fifo file, a database, a RabbitMQ queue or whatever
dump.EnableVerbose()

// Default options
//dumpExec := dump.Exec(pg.ExecOptions{})

// Log to stdout
// Note that any io.Writer could be assigned to StreamDestination. I'm just using stdout here for brevity.
// But we could write to a file, a database, a RabbitMQ queue or whatever
// We could even write to all of the above using io.MultiWriter(...)
dumpExec := dump.Exec(pg.ExecOptions{StreamPrint: true, StreamDestination: os.Stdout})
if dumpExec.Error != nil {
Expand Down
2 changes: 1 addition & 1 deletion utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func streamExecOutput(out io.ReadCloser, options ExecOptions) (string, error) {
}

if options.StreamPrint {
_, err = fmt.Fprintln(options.StreamDestination, line)
_, err = fmt.Fprint(options.StreamDestination, line)
if err != nil {
return output, fmt.Errorf("error writing output: %w", err)
}
Expand Down

0 comments on commit 48383f0

Please sign in to comment.