type Board [BOARD_SIZE]Space
func read_board_from_strings(in []string) (*Board, error) {
- if len(in) != BOARD_SIZE {
- return nil, fmt.Errorf("Please provide %d values", BOARD_SIZE)
- }
- var b Board
- for i, s := range in {
- num, err := strconv.Atoi(s)
- b[i] = Space(num)
- if err != nil {
- return nil, err
- }
- }
- return &b, nil
+ if len(in) != BOARD_SIZE {
+ return nil, fmt.Errorf("Please provide %d values", BOARD_SIZE)
+ }
+ var b Board
+ for i, s := range in {
+ num, err := strconv.Atoi(s)
+ b[i] = Space(num)
+ if err != nil {
+ return nil, err
+ }
+ }
+ return &b, nil
}
func main() {
- start, err := read_board_from_strings(os.Args[1:])
- if err != nil {
- panic(err)
- }
- fmt.Println(start)
+ start, err := read_board_from_strings(os.Args[1:])
+ if err != nil {
+ panic(err)
+ }
+ fmt.Println(start)
}