From 0e15d4aa46c198b0ae7d69e8ca1f466e1673ede4 Mon Sep 17 00:00:00 2001 From: Sean Hinchee Date: Wed, 26 Jul 2017 19:00:15 +0000 Subject: [PATCH] made GetCons() --- config.go | 9 ++------- helper.go | 11 +++++++++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/config.go b/config.go index 442440f96b573878b8b3ddfdfea84aa91f1b50ba..4e933846e290c58d87af1e73816e8e0b139db077 100644 --- a/config.go +++ b/config.go @@ -77,13 +77,8 @@ func CreateConfig() { password := ""; if plan9 { - cons, err := os.OpenFile("/dev/cons", os.O_RDWR, 0600) - if err != nil { - fmt.Println("Failed to open /dev/cons") - } - consScan := bufio.NewScanner(cons) - consScan.Scan() - password = consScan.Text() + + password = GetCons() err = RawOff(consctl) if err != nil { diff --git a/helper.go b/helper.go index d680f22e66e8f52473c2e38fe7ee22f8056fc815..176c2bd8f004f16eba7395fa299851c98bc826e9 100644 --- a/helper.go +++ b/helper.go @@ -8,6 +8,7 @@ import ( "time" "fmt" "bitbucket.org/henesy/disco/DiscordGo" + "bufio" ) //HexColor is a struct gives RGB values @@ -131,3 +132,13 @@ func RawOff(consctl *os.File) error { consctl.Close() return nil } + +func GetCons() string { + cons, err := os.OpenFile("/dev/cons", os.O_RDWR, 0600) + if err != nil { + fmt.Println("Failed to open /dev/cons") + } + consScan := bufio.NewScanner(cons) + consScan.Scan() + return consScan.Text() +}