Is there a way to watch what code is executing when your program runs?

I’m not even really sure what this would be called. I have an issue in my code shown here:

package controller

import (


type userLogOut struct {
	userLogOutTemplate *template.Template

func (h userLogOut) regRoutes() {
	http.HandleFunc("/logout", h.handleUserLogOut)
	http.HandleFunc("/logout/", h.handleUserLogOut)

func (h userLogOut) handleUserLogOut(w http.ResponseWriter, r *http.Request) {

	fmt.Println("In handleuserLogOut")
	viewModel := viewmodel.UserLogOutPage()
	h.userLogOutTemplate.Execute(w, viewModel)

When I call “/logout” the code runs fine, when I call “/logout/” the code redirects to my index page for some reason. I have no idea where it would be doing that from. I’ve searched through my controller that’s handling authentication and done print statements, but the code never executes. It’s like my "/logout/ route request is being hijacked.

Is there a way in any of the go tools to watch what methods are being called as you execute your program?

Thank you

Did you try delve? It has a trace mode that might be what you need…

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.