[ GoLang ] underscore function

underscore ( _ ) avoids having to declare all the variables for the returns values.

Example

changeInfo, err := c.RemoveAll(query)

This will cause the compile error

$ go build mongo_connect.go
# command-line-arguments
./mongo_connect.go:104: changeInfo declared and not used

So, change it to underscore.

_, err := c.RemoveAll(query)

ref : https://stackoverflow.com/questions/27764421/what-is-in-a-golang-declaration

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s