Skip to content

Instantly share code, notes, and snippets.

@ccnixon
Created December 8, 2016 01:22
Show Gist options
  • Save ccnixon/309e77e31c85096f8a723176a5e1bb5a to your computer and use it in GitHub Desktop.
Save ccnixon/309e77e31c85096f8a723176a5e1bb5a to your computer and use it in GitHub Desktop.
Simple Go Command Line prompt
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