golang-exercises/golangr/between-1-10-checker/nameget.go

29 lines
804 B
Go
Raw Permalink Normal View History

package main
import (
"bufio"
"fmt"
//"log"
"os"
)
func nameget() {
fmt.Println("Welcome to this simple program, may I know your name?\n(You can use spaces now, I figured out how to use the bufio library)")
fmt.Printf("Name: ")
reader := bufio.NewReader(os.Stdin)
name, _ = reader.ReadString('\n')
// Hold that thought, I'm pretty sure bufio might be infinitely better, scan keeps bothering me by not
// accepting spaced out words
// It has come to my attention that scan actually spits out two values, default and err
// _, err := fmt.Scanln(&name)
// nil is literally the equivalent of null, we're just checking here if err is not null,
// and if it isn't, it means an error has ocurred so we're just gonna panic and kill the program
// if err != nil {
// log.Fatal(err)
// }
}