Go language common functions: Make

Source: Internet
Author: User

Creating an Array slice

The built-in function make () provided by the go language can be used to flexibly create array slices.
Create an array slice with an initial element number of 5, with an element initial value of 0:
MySlice1: = Make ([]int, 5)
Create an array slice with an initial element number of 5, an element with an initial value of 0, and a storage space of 10 elements:
MySlice2: = Make ([]int, 5, 10)

Create a map

MyMap = Make (map[string

A key was created map.//from:http://www.cnblogs.com/osfipin/of type string, value type Personinfo

MyMap = Make (map[string

You can also choose whether to specify the initial storage capacity of the map at creation time, creating an initial storage capability a map of 100.

MyMap = map[string] personinfo{   "1234": personinfo{"  1"Jack""101,... "

Create and initialize the code for the map.

Go language common functions: Make

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.