About Go.

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

Here, I want to record, learn, use the Go language, for the go language uncomfortable places.

1. function return type after the parameter type, it is not easy to see clearly the return type of the function

As below, is not a kind of very flower feeling.

    Func Newreader (S string) *reader    func (R *reader) Len () int    func (r *reader) Read (b []byte) (n int, err error) 
  
   func (R *reader) ReadAt (b []byte, off Int64) (n int, err error)    func (R *reader) ReadByte () (b byte, err error)    F UNC (R *reader) readrune (Ch rune, size int, err error)    func (R *reader) Seek (offset int64, whence int) (Int64, Erro R)    func (R *reader) Size () Int64    func (R *reader) unreadbyte () Error    func (r *reader) Unreadrune () error
   
    func (R *reader) writeto (w io). Writer) (n Int64, err error)
   
  

2. The return type of the function declaration, and the returned value syntax are inconsistent

If the return type is multiple, you must use parentheses (), and you cannot use parentheses when returning in the body of the function

Func SAWP (a int, b int) (r1 int, R2 int) {    return R2, R1//cannot use return (R2, R1)}

3. Allow there is no semicolon behind the statement, resulting in a switch to C + + when it is customary without semicolons, compile errors

Of course, when writing python, there is no semicolon. But Python is completely formatted, not easily confused with C + +. Go switch is so used to.

# # # # Keep waiting for updates # #

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.