Advanced path to the Go language-golang high-level data structure definition

Source: Internet
Author: User

Advanced path to the Go language-golang high-level data structure definition

Yun Zhengjie

Copyright Notice: Original works, declined reprint! Otherwise, the legal liability will be investigated.

  We've previously learned about Golang's basic data types, strings and Byte, and Rune, but it's possible that we're still not quite sure about the high-level data types, so learn these advanced data type data with my footsteps today. I believe that some people may have learned python, so I do not have to read this blog basically, because you will feel so easy. Because there are so many similarities, it's just a different notation. This chapter focuses on arrays, slices (scice), dictionaries (maps), structures (structs), and so on.

One. Arrays

1. Define an empty array

1 Package Main2 3 Import "FMT"4 5 Func Main () {6var num [3]int//indicates that an array with a capacity of 3 is defined, and if no initial value is assigned, the default is"0".7Fmt. Printf ("The first number of the array is:%d\n", num[0])8Fmt. Printf ("The last number of the array is:%d\n", Num[len (num)-1])9      forI,v: =Range num {TenFmt. Printf ("The subscript for the array is:%d, the initial value corresponding to the array's subscript is:%d\n", I,v) One     } A      for_,v: =Range num { -Fmt. Printf ("the initial value of the array is:%d\n", V) -     } the } -  -  -  + #The result of the above code execution is as follows: - The first number of the array is: 0 + The last number of the array is: 0 A The subscript of the array is: 0, the initial value corresponding to the array subscript is: 0 atThe subscript for the array is: 1, the initial value corresponding to the array's subscript is: 0 -The subscript for the array is: 2, the initial value corresponding to the array's subscript is: 0 - the initial value of the array is: 0 - the initial value of the array is: 0 -The initial value of the array is: 0

2.

Advanced path to the Go language-golang high-level data structure definition

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.