forked from blek/bshchk
use a different stdin read method
This commit is contained in:
parent
e6f2770869
commit
4842b4ad52
15
main.go
15
main.go
|
@ -1,8 +1,8 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -40,14 +40,13 @@ func main() {
|
||||||
}
|
}
|
||||||
file = f
|
file = f
|
||||||
} else {
|
} else {
|
||||||
scanner := bufio.NewScanner(os.Stdin)
|
data, err := io.ReadAll(os.Stdin)
|
||||||
for scanner.Scan() {
|
|
||||||
file = scanner.Bytes()
|
|
||||||
}
|
|
||||||
|
|
||||||
if scanner.Err() != nil {
|
if err != nil {
|
||||||
panic(scanner.Err())
|
fmt.Printf("Coudln't read from stdin: %s", err.Error())
|
||||||
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
file = data
|
||||||
}
|
}
|
||||||
|
|
||||||
code := string(file)
|
code := string(file)
|
||||||
|
@ -70,7 +69,7 @@ func main() {
|
||||||
os.Exit(2)
|
os.Exit(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
gen := shebang + "\n\n" + gencode(found) + "\n" + strings.Join(codelines[1:], "\n")
|
gen := shebang + "\n\n" + gencode(found) + "\n\n" + strings.Join(codelines[1:], "\n")
|
||||||
|
|
||||||
if args.Outfile == "" {
|
if args.Outfile == "" {
|
||||||
fmt.Printf("%s", gen)
|
fmt.Printf("%s", gen)
|
||||||
|
|
Loading…
Reference in New Issue