connected components - determining "groups" in Go
To count connected groups

Form an undirected graph, with one vertex per location on the board, and an edge between each two locations are are adjacent (horizontally or vertically).  Then, use any standard algorithm for connected components.  See https://en.wikipedia.org/wiki/Connected_component_%28graph_theory%29 or your favorite CS algorithms textbookk.

You'll probably want to run the algorithm twice: once for x's (build a graph where you retain just the vertices with x's on them, and find all connected components), and once for o's (build a graph where you retain just the vertices with o's on them, and find all connected components).

To count liberties

If I understand the definition, this looks like a simple matter of programming.  Find a connected component of x's, look at each cell which is adjacent to it, and count how many are empty.  That's straightforward programming -- no fancy algorithms needed.  Programming questions are better on StackOverflow, but make sure you show your effort.