如何在golang中将所有user_name与密码匹配?

Using a struct, I'm saving the data in the JSON form to collection like so:

type SignUp struct {
 Id           int      `json:"_id" bson:"_id"`
 UserName     string   `json:"user_name" bson:"user_name"`
 EmailId         string   `json:"email_id" bson:"email_id"`
 Password    string   `json:"password" bson:"password"`
}
type SignUps []SignUp

And retrieved the data from the collection of mongodb using function

func Login(c *gin.Context) {
 response := ResponseControllerList{}
 conditions := bson.M{}
 data, err := GetAllUser(conditions)
 fmt.Println(data)
 fmt.Println(err)
 Matching(data)
 return
}

func GetAllUser(blogQuery interface{}) (result SignUps, err error) {
 mongoSession := config.ConnectDb()
 sessionCopy := mongoSession.Copy()
 defer sessionCopy.Close()
 getCollection := mongoSession.DB("sign").C("signup")
 err = getCollection.Find(blogQuery).Select(bson.M{}).All(&result)
 if err != nil {
    return result, err
 }
 return result, nil
}

But the data retrieved without its keys like shown below:-

[{1 puneet puneet@gmail.com puneet} {2 Rohit abc@gmail.com puneet}]

Issue is that I want to collect all the existing EmailId and Password and match them with userid and password entered by the user in fucntion given bellow:-

func Matching(data Signups){
  userid="abc@gmail.com"
  password="puneet"
  //match?
 }

How can I match the userid and password with the EmailId and Password fields?

You can give an if condition to check if the userid or email is empty or not on your Matching function like:

....

if data.userid != "" {
    data.username = data.userid
} 

data.password

....

You can create new struct for the query and use it to create your Matching function.

    for _, signup := range data {
        if userId == signup.Id && password == signup.Password {
            println("Match!")
        }
    }

This is not answering your question directly, but is very important nonetheless. It seems that you are saving the passwords of your users in plain text in the database. This is very careless and you should add some encryption like bcrypt: https://godoc.org/golang.org/x/crypto/bcrypt

When you have added some encryption, your matching would be quite different than all given answers. This depends on the used encryption package. But please ignore the other answers. They might work, but only for plain text passwords.