package input_parser import ( "bufio" "log" "os" "strings" ) type Input struct { // The instruction a.k.a first argument Instruction string // The args, currently just the string after the instruction Args string } func Parse() Input { reader := bufio.NewReader(os.Stdin) input, err := reader.ReadString('\n') if err != nil { log.Fatal(err.Error()) } split := strings.SplitN(string(input), " ", 2) instruction := strings.TrimSpace(split[0]) var arg string if len(split) == 2 { arg = strings.TrimSpace(split[1]) } else { arg = "" } return Input { Instruction: instruction, Args: arg, } }