FAQ
You can do multiple assignments in one line with the comma operator e.g.
user, pass := r.FormValue("user"), r.FormValue("pass"), but that doesn't
seem very idiomatic. Just initialize the variables and then check them:

func PrintUser(w http.ResponseWriter, r *http.Request) {
         user := r.FormValue("user")
         pass := r.FormValue("pass")
         if user == "" || pass == "" {
                 fmt.Fprintf(w, "Missing username or password")
                 return
         }
         fmt.Fprintf(w, "Hi %s!", user) //I doubt you want to print the
password.
}


On Monday, December 1, 2014 9:17:18 AM UTC-8, amir-taghavi wrote:

thanks my problem solved
func Printuser(w http.ResponseWriter,r *http.Request){
if user:=r.FormValue("user");user!=""{
user = r.FormValue("name")
pass := r.FormValue("pass")
fmt.Fprintf(w,"Hi %s - %s",user,pass)
}
}

and one other question

if i want check 2 parameters example follow
func Printuser(w http.ResponseWriter,r *http.Request){
if user:=r.FormValue("user"),pass:=r.FormValue("pass");user!="" &&
pass!=""{
user = r.FormValue("name")
pass = r.FormValue("pass")
fmt.Fprintf(w,"Hi %s - %s",user,pass)
}
}


how is it possible ?
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 6 of 7 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedDec 1, '14 at 4:35p
activeDec 1, '14 at 5:38p
posts7
users3
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase