In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what is the use scene of Go Type". In the daily operation, I believe that many people have doubts about what the use scene of Go Type is. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubt of "what is the use scene of Go Type?" Next, please follow the editor to study!
Go Type usage scenario
Type usage scenario
1. Define the structure
/ / define the trademark structure / / define Brand as the following structure type type Brand struct {} / / add the Show () method func (t Brand) Show () {} to the trademark structure
two。 As an alias
The code that defines built-in types prior to Go 1.9 is written as follows:
Type byte uint8type rune int32
After Go 1.9, it becomes:
Type byte = uint8type rune = int32
Distinguish between type aliases and type definitions
/ / define NewInt as int type type NewInt int// will int have an alias IntAliastype IntAlias = intfunc main () {/ / declare an as NewInt type var a NewInt / / View a type name fmt.Printf ("a type:% T\ n", a) / / declare a2 as IntAlias type var a2 IntAlias / / View a2 type name fmt.Printf ("a2 type:% T\ n" A2)} a type: main.NewInta2 type: int
Define structures in batch
Type (/ / A PrivateKeyConf is a private key config. PrivateKeyConf struct {Fingerprint string KeyFile string} / / A SignatureConf is a signature config. SignatureConf struct {Strict bool `json: ", default=false" `Expiry time.Duration `json: ", default=1h" `PrivateKeys [] PrivateKeyConf})
Single definition structure
Type PrivateKeyConf struct {Fingerprint string KeyFile string} type SignatureConf struct {Strict bool `json: ", default=false" `Expiry time.Duration `json: ", default=1h" `PrivateKeys [] PrivateKeyConf} at this point, the study of "what is the usage scenario of Go Type" is over. I hope to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.