Created
December 8, 2016 01:22
-
-
Save ccnixon/309e77e31c85096f8a723176a5e1bb5a to your computer and use it in GitHub Desktop.
Simple Go Command Line prompt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"fmt" | |
"os" | |
) | |
const PROMPT = "go>> " | |
func main() { | |
scanner := bufio.NewScanner(os.Stdin) | |
for { | |
fmt.Printf(PROMPT) | |
scanned := scanner.Scan() | |
if !scanned { | |
return | |
} | |
line := scanner.Text() | |
fmt.Println(line) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment