Compare commits
No commits in common. "c777bd25b06ab99791e0b001ec64e879d7c6c569" and "e6f2770869a8ae596cd77fcf3e5cda70bc015d9f" have entirely different histories.
c777bd25b0
...
e6f2770869
19
main.go
19
main.go
|
@ -1,8 +1,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
|
@ -29,7 +29,7 @@ func main() {
|
|||
}
|
||||
|
||||
var file []byte
|
||||
if (args.File != "") && (args.File != "-") {
|
||||
if args.File != "" {
|
||||
f, err := os.ReadFile(args.File)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
|
@ -40,13 +40,14 @@ func main() {
|
|||
}
|
||||
file = f
|
||||
} else {
|
||||
data, err := io.ReadAll(os.Stdin)
|
||||
|
||||
if err != nil {
|
||||
fmt.Printf("Coudln't read from stdin: %s", err.Error())
|
||||
os.Exit(1)
|
||||
scanner := bufio.NewScanner(os.Stdin)
|
||||
for scanner.Scan() {
|
||||
file = scanner.Bytes()
|
||||
}
|
||||
|
||||
if scanner.Err() != nil {
|
||||
panic(scanner.Err())
|
||||
}
|
||||
file = data
|
||||
}
|
||||
|
||||
code := string(file)
|
||||
|
@ -69,7 +70,7 @@ func main() {
|
|||
os.Exit(2)
|
||||
}
|
||||
|
||||
gen := shebang + "\n\n" + gencode(found) + "\n\n" + strings.Join(codelines[1:], "\n")
|
||||
gen := shebang + "\n\n" + gencode(found) + "\n" + strings.Join(codelines[1:], "\n")
|
||||
|
||||
if args.Outfile == "" {
|
||||
fmt.Printf("%s", gen)
|
||||
|
|
Loading…
Reference in New Issue