Skip to content

Commit

Permalink
clean up, tests work
Browse files Browse the repository at this point in the history
  • Loading branch information
Jurgen Weber committed Jan 22, 2018
1 parent 8caa56b commit 20e8e5b
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ func failOnError(err error, msg string) {
}
}

func notApipe() {
fmt.Println("The command is intended to work with pipes.")
fmt.Println("Usage: echo mytext | stdin2rabbitmq")
os.Exit(1)
}

func read_in_stdin(debug bool) string {
// massive copy and paste
// https://flaviocopes.com/go-shell-pipes/
Expand All @@ -39,13 +33,12 @@ func read_in_stdin(debug bool) string {
fmt.Println("stdin buffer size = " + strconv.FormatInt(info.Size(), 10))
}

// removed the size test as this can return nothing but 0 on some OS's.
// if info.Mode()&os.ModeCharDevice != 0 || info.Size() <= 0 {
// ModeCharDevice works on a console where you have a terminal
if info.Mode()&os.ModeCharDevice == os.ModeCharDevice {
// ModeNamedPipe is when you are ssh'd into something
//if (info.Mode()&os.ModeNamedPipe == os.ModeNamedPipe || info.Size() <= 0) {
notApipe()
//}
fmt.Println("The command is intended to work with pipes.")
fmt.Println("Usage: echo mytext | stdin2rabbitmq")
os.Exit(1)
}

reader := bufio.NewReader(os.Stdin)
Expand Down

0 comments on commit 20e8e5b

Please sign in to comment.