In Go language if we want to add single record/list of records we can use the append() method. But here is the trick adding the single item is pretty much forward and while adding the list/set of records we might face some issue.
Now we will discuss how to handle both the scenarios
Adding a single item/record to list/array:
package main func main() { var finalItemList []string var singleItem string finalItemList = append(finalItemList, singleItem) }
Adding multiple items/list to another list/array:
To add list of items to another list with help of append() we will receive an error as can not use variable of type of list/array as a data type value in argument to append.
To solve this simply we can just use Spread operator ... (3 dots) notation as shown below.
package main
func main() {
var finalItemList []string
var secondItemList []string
finalItemList = append(finalItemList, secondItemList...)
}
Please comment or write us if you have any queries/requirements.
Please like,follow,bookmark,subscribe this site to receive daily updates.
LinkedIn Group - Srinivas4sfdc (I Love Coding... You?)
FaceBook Page - I Love Coding. You?
Please comment or write us if you have any queries/requirements.
Please like,follow,bookmark,subscribe this site to receive daily updates.
LinkedIn Group - Srinivas4sfdc (I Love Coding... You?)
FaceBook Page - I Love Coding. You?
EDDEA0E707
ReplyDeleteBeğeni Satın Al
Telafili Takipçi
Instagram Takipçi Kasma
F0842F996A
ReplyDeleteTakipçi Satın Al
En İyi Korku Filmleri
Takipçi Satın Al
2E24992096
ReplyDeleteIn today's digital age, establishing a strong online presence is essential for success. For those looking to enhance their visibility, exploring various tools and resources can be beneficial. One such resource is the Website that offers valuable insights and solutions. Utilizing these platforms can significantly boost your digital strategy and reach.