Last active
July 2, 2022 08:21
-
-
Save Abelkrijgtalles/5dab128cc5af97676ff1794d75d43e7c to your computer and use it in GitHub Desktop.
A simple way to get input in Go (Golang)
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" | |
"strings" | |
) | |
func input(p string) (string) { | |
var r = bufio.NewReader(os.Stdin) | |
fmt.Print(p) | |
var i, err = r.ReadString('\n') | |
if err != nil { | |
panic(err) | |
} | |
return strings.TrimSpace(i) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment