Some grammatical problems encountered in go learning

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.
1. Variable parameters, incoming array of hungry time, must add three ... func sums (nums ...int) {}nums := []int{1, 2, 3, 4,  5}sums (Nums ...) 2. If the func  with the return value must be specified later in the return value type Func plus (a int, b int)  int {      return a + b}3. When using closures, the function name, the return value is the func ()   return value   format declaration func intseq ()   Func ()  int {     i := 0     return  Func ()  int {         i += 1          return i     }}4.  in Go, * flag a pointer,& The indicator points to a variable *PTRI&NBSP;:=&NBSP;&AMP;PTR5. The way to use in go, the more interesting place, the feeling is injected (yy) type user struct{     name} func  (u *user )  getName string{    return  U.name}func main () {    u := user{name: "Zhangsan"}&NBSP;&NBSP;&NBSP;&NBSp;fmt. Println (U.getname)}6. Use go  in go to do this self-execution (the first time the correct execution, the future has not been successful.) ) Go func (msg string)  {    fmt. PRINTLN (MSG)} ("Going") 7. Use channel  in go to use the go  keyword,make  can only be applied to Slice,map,channel8. <-chan   is ready to receive the sent value, chan<-is only receiving


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.