Click here to Skip to main content
15,889,116 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
type List struct {
	Success  bool
}

func Home(w http.ResponseWriter, r *http.Request) error {
	if r.URL.Path != "/" {
		return PageError(w, r)
	}
	var user List
	user = List{
		Success: true,
	}
	if r.Method == "GET" {
		return HomeTmpl.Execute(w, user)
	} 
	} else if r.Method == "POST" {
		Newsletter(w, r)
		return HomeTmpl.Execute(w, user)
	}
	return nil
}


base.html

{{if.Success}}
    <li>
        <h4><a href="/signout">Sign Out</a></h4>
    </li>
{{else}}
    <li>
        <h4><a href="/login">Log In</a></h4>
    </li>
{{end}}


What I have tried:

Hey there. In this code, I want to show the sign-out option whenever the user logs in and the login option whenever the user signs out. But it is just giving me the sign-out option even if I am logout.

How to deal with this conditional statement?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900