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

21 lines
597 B
Go

package main
import (
"fmt"
"log"
)
func nameget() {
fmt.Println("Welcome to this simple program, may I know your name?\n(Please don't use spaces, I still haven't figured out how to parse them all together into a string)")
fmt.Printf("Name: ")
// 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)
}
}