Skip to content

Instantly share code, notes, and snippets.

@JamsMendez
Last active September 29, 2015 17:32
Show Gist options
  • Save JamsMendez/679d3e4c12b4d3ff4f28 to your computer and use it in GitHub Desktop.
Save JamsMendez/679d3e4c12b4d3ff4f28 to your computer and use it in GitHub Desktop.
Leer información desde la terminal
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
messagesInput := []string{"Name(s): ", "First name: ", "Last name: ", "Age: "}
keysInput := []string{"name", "first_name", "last_name", "Age"}
user := make(map[string]string)
reader := bufio.NewReader(os.Stdin)
for i := 0; i < len(messagesInput); i++ {
fmt.Print(messagesInput[i])
text, err := reader.ReadString('\n')
if err == nil {
key := keysInput[i]
user[key] = text
}
}
fmt.Println(user)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment