       ;; If we have landed at an anonymous function, it is possible that we
       ;; were not inside it but below it. If we were not inside it, we should
       ;; go to the containing function.
-      (while (go--below-anonymous-function p)
+      (while (and (not (go--in-function-p p))
+                  (not (looking-at "^func")))
         (go-goto-function arg)))))
 
   (cond

          (display-buffer (current-buffer) `(,go-coverage-display-buffer-func))))))

(defun go-goto-function (&optional arg)
  "Go to the function defintion above point.

If we are on a docstring, follow the docstring down.
If no function is found, assume that we are at the top of a file
and search forward instead.

If we are inside an anonymous function, go to that.
If we are inside a function that has an anonymous function inside of it and we
are below that anonymous function, go to the root function.

If one prefix argument is given, anonymous functions are skipped."
  (interactive "P")
  (let ((p (point)))
    (cond

      (while (looking-at "^//")
        (forward-line 1))
      ;; If we are still not looking at a function, retry by calling self again.
      (when (not (looking-at "func"))
        (go-goto-function arg)))

     ;; If we're already looking at an anonymous func, look for the
     ;; surrounding function.
     ((and (looking-at "func")
           (not (looking-at "^func")))
      (re-search-backward "\\<func\\>" nil t))

     ((not (looking-at "func"))
      ;; If point is on the "func" keyword, step back a word and retry
      (if (string= (symbol-name (symbol-at-point)) "func")
          (backward-word)
        ;; If we are not looking at the beginning of a function line, do a regexp
        ;; search backwards
        (re-search-backward "\\<func\\>" nil t))

      ;; If nothing is found, assume that we are at the top of the file and
      ;; should search forward instead.
