-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
54 lines (45 loc) · 835 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package main
import (
"bufio"
"fmt"
"io"
"os"
"strings"
)
var (
vowels = []string{"a", "e", "i", "o", "u"}
)
func main() {
info, err := os.Stdin.Stat()
if err != nil {
panic(err)
}
if info.Mode()&os.ModeCharDevice != 0 || info.Size() <= 0 {
fmt.Println("The command is intended to work with pipes.")
fmt.Println("Usage: echo 'herp derpus' | fewer")
return
}
reader := bufio.NewReader(os.Stdin)
var output []rune
for {
input, _, err := reader.ReadRune()
if err != nil && err == io.EOF {
break
}
output = append(output, input)
}
for j := 0; j < len(output); j++ {
if !(isVowel(output[j])) {
fmt.Printf("%c", output[j])
}
}
}
func isVowel(val rune) bool {
for _, item := range vowels {
check := strings.ToLower(string(val))
if item == check {
return true
}
}
return false
}