Skip to content

Instantly share code, notes, and snippets.

@Abelkrijgtalles
Last active July 2, 2022 08:21
Show Gist options
  • Save Abelkrijgtalles/5dab128cc5af97676ff1794d75d43e7c to your computer and use it in GitHub Desktop.
Save Abelkrijgtalles/5dab128cc5af97676ff1794d75d43e7c to your computer and use it in GitHub Desktop.
A simple way to get input in Go (Golang)
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