瀏覽代碼

Implement #CZ2

Alois Mahdal 1 周之前
父節點
當前提交
8a0b99ead1
共有 1 個檔案被更改,包括 8 行新增0 行删除
  1. 8
    0
      app/main.go

+ 8
- 0
app/main.go 查看文件

1
 package main
1
 package main
2
 
2
 
3
 import (
3
 import (
4
+	"bufio"
4
 	"fmt"
5
 	"fmt"
6
+	"os"
5
 )
7
 )
6
 
8
 
7
 // Ensures gofmt doesn't remove the "fmt" import in stage 1 (feel free to remove this!)
9
 // Ensures gofmt doesn't remove the "fmt" import in stage 1 (feel free to remove this!)
9
 
11
 
10
 func main() {
12
 func main() {
11
 	fmt.Print("$ ")
13
 	fmt.Print("$ ")
14
+	command, err := bufio.NewReader(os.Stdin).ReadString('\n')
15
+	if err != nil {
16
+		fmt.Fprintln(os.Stderr, "Error reading input: ", err)
17
+		os.Exit(1)
18
+	}
19
+	fmt.Println(command[:len(command)-1] + ": command not found")
12
 }
20
 }