func part1And2(input string, part int) int {
	coordsToRooms := generateRoomMap(input)
	var furthest int              
	var countFarRooms int         
	queue := [][3]int{{0, 0, 0}}  
	roomsVisited := make(map[[2]int]bool, len(coordsToRooms))
	for len(queue) != 0 {
		front := queue[0]
		currentCoords := [2]int{front[0], front[1]}
		currentDistance := front[2]
		currentRoom := coordsToRooms[currentCoords]
		if roomsVisited[currentCoords] {
			queue = queue[1:]
			continue
		}
		if furthest < currentDistance {
			furthest = currentDistance
		}
		if currentDistance >= 1000 {
			countFarRooms++
		}
		roomsVisited[currentCoords] = true
		if currentRoom.northDoor {
			queue = append(queue, [3]int{currentCoords[0] - 1, currentCoords[1], currentDistance + 1})
		}
		if currentRoom.southDoor {
			queue = append(queue, [3]int{currentCoords[0] + 1, currentCoords[1], currentDistance + 1})
		}
		if currentRoom.eastDoor {
			queue = append(queue, [3]int{currentCoords[0], currentCoords[1] + 1, currentDistance + 1})
		}
		if currentRoom.westDoor {
			queue = append(queue, [3]int{currentCoords[0], currentCoords[1] - 1, currentDistance + 1})
		}
		queue = queue[1:]
	}
	if part == 1 {
		return furthest
	}
	return countFarRooms
}
The code is nearly identical for both, so part # is passed in as an arg
package main
import (
	"flag"
	"fmt"
	"github.com/alexchao26/advent-of-code-go/util"
)
func main() {
	var part int
	flag.IntVar(&part, "part", 1, "part 1 or 2")
	flag.Parse()
	fmt.Println("Running part", part)
	ans := part1And2(util.ReadFile("./input.txt"), part)
	fmt.Println("Output:", ans)
}