Last active
September 29, 2015 17:32
-
-
Save JamsMendez/679d3e4c12b4d3ff4f28 to your computer and use it in GitHub Desktop.
Leer información desde la terminal
This file contains hidden or 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" | |
) | |
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