package main import "strings" func parse_smtp_line(line string) (cmd, param string) { line = strings.TrimSuffix(line, "\n") line = strings.TrimSuffix(line, "\r") cmd_end := strings.IndexByte(line, ' ') var param_start int if cmd_end == -1 { cmd_end = len(line) param_start = len(line) } else { param_start = cmd_end + 1 } cmd = strings.ToUpper(line[:cmd_end]) param = line[param_start:] return }