mirror of
https://github.com/mudabbir-ahmad/LearningGo.git
synced 2026-10-07 17:50:20 +00:00
29 lines
496 B
Go
29 lines
496 B
Go
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()
|
|
|
|
}
|