package main import ( "bufio" "fmt" "log" "os" "strings" ) // Setup authentication credentials for the user. func setupAuth() (*Config, error) { // Yikes here we go input := bufio.NewReaderSize(os.Stdin, 256) // Reads user input. Fatal if there's an error. readInput := func(line string) string { fmt.Println(line) in, err := input.ReadString('\n') if err != nil { log.Fatalf("Couldn't read user input; %v\n", err) } return strings.TrimSuffix(in, "\n") } clientId := readInput("Please input client id.") clientSecret := readInput("Please input client secret.") userName := readInput("Input username you use to login to twitch.") // TODO: Probably do some input validation. Maybe. if len(clientSecret) == 0 || len(clientId) == 0 || len(userName) == 0 { panic("An input was empty.") } // ID needs to be set by auth because twitch needs some auth to access it. conf := &Config{ ClientID: clientId, ClientSecret: clientSecret, UserName: userName, } return conf, nil }