Go get Started

Source: Internet
Author: User
This is a created article in which the information may have evolved or changed.

Package main//define current packages name

Import "FMT"

Import "math"//above can be merged into import ("FMT" "math")

Func Main () {

Fmt. Println ("Hello", Math.) Pi, "World"); The first letter will be exported from the package, the other symbols are not visible.

}


The func add (a int, b int) int {//parameter type is placed after the parameter name, the return value type is put to the last, and the same parameter type can even be specified at the last same type declaration.

return a + B;

}


function can return any number of return values

Func Swap (A, B string) (string, String) {//return value to be enclosed in parentheses

return B, A;

}


Func split (sum int) (a int, b int) {//Name return value, return can not be specified

A = SUM/2;

b = Sum * 2;

Return

}

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.