M config.go => config.go +2 -7
@@ 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 {
M helper.go => helper.go +11 -0
@@ 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()
+}