go implementation of revisit