mirror of
https://github.com/mudabbir-ahmad/LearningGo.git
synced 2026-10-08 01:50:20 +00:00
read terminal then output as text file...oooo
This commit is contained in:
1 parent
b55e4c503f
commit
757fc804ac
2 files changed
+31
No files matched your search
@@ -0,0 +1,28 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bufio"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
|
||||||
|
reader := bufio.NewReader(os.Stdin)
|
||||||
|
|
||||||
|
fmt.Println("To end the output Write . and then click enter")
|
||||||
|
fmt.Print("Enter text to write to file a file called \"OutputFromTerminal.txt\": \n")
|
||||||
|
|
||||||
|
input, _ := reader.ReadString('.')
|
||||||
|
|
||||||
|
path := filepath.Join("./", "OutputFromTerminal.txt")
|
||||||
|
file, _ := os.Create(path)
|
||||||
|
|
||||||
|
writer := bufio.NewWriter(file)
|
||||||
|
writer.WriteString(input)
|
||||||
|
|
||||||
|
defer file.Close()
|
||||||
|
defer writer.Flush()
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
func main() {}
|
||||||
Reference in new issue
Block a user