Golang---Some of the wrong places.

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Summarize oneself in the study not to know very much place.
Record here, if you can provide help, but the best!

Import

This package name, and the functions in this package, are available only after you import a package.
A package contains (the public):

    • Public functions (only accessible by package name)
    • Method of the object (called by the object)
    • Public type (accessed by package name)

So when calling a method in a package, there must be a point in front of "." (the signature of the point may be the package name or the object name)

Types and methods of public

Remember, it must be capitalized!

Fmt. Println (A, B, c)

When you print A, B, C, it is automatically separated by a "space".

Slice and map can be traversed using the range keyword

When using byte arrays, note the length of the byte array. Especially when passing a byte array to a function

 PackageMainImport("bytes"    "FMT"    "OS")funcMain () {varNumintBUF: = Make([]byte,2048) F, _: = OS. Open ("Golang")deferF.close () n, _: = F.read (BUF) fmt. Println (string(Buf[:n]), N)//This is not buf, but Buf[:n]    //Here is also buf[:n], you can see the return value n,_: = F.read (BUF) the use of N.      for_, Sentence: =Rangebytes. Fieldsfunc (Buf[:n], F1) { for_, Words: =Rangebytes. Fields (sentence) {num++ fmt. Printf ("%q", words)}} fmt. Println () fmt. Println ("File", F.name (),"In total"Num"a word.")}funcF1 (rRune)BOOL{ifr = =','|| r = ='!'|| r = ='.'{return true}Else{return false}}

In a function that has a return value, you can no longer use return in the IF statement.

It seems that the rules have been exhausted ... I can use it after the test anyway.
Control Statement article: http://www.cnblogs.com/howDo/archive/2013/06/01/golang-control.html

Function

First refer to the article: http://www.cnblogs.com/howDo/archive/2013/06/04/GoLang-function.html

Interface

Staging stack (segmented stack)

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.