Original Golang var,const,struct, func sequence

Source: Internet
Author: User
This is a created article in which the information may have evolved or changed.
In the Go language. The order is not so important, accustomed to the complexity of C, for simple practices sometimes appear unreal feeling. A Go language source file structure: Package ***import  ***,***,***var|func|type|const write C program If each function is called. Be sure to see the form of the function where it is called, and for variables, macros are like this. To go language, no, this simple example, is the main function that can work refers to the following declaration but struct, func, var. No harm! Package Mainimport "FMT" Const (K1 = +) Func main () {var i = k1fmt.println ("i", i) var j = k2fmt.println ("J", J) P: = Point {3,4}fmt. Println (p.x, p.y) d: = Distance2 (P) fmt. Println ("D:", D) fmt. Println ("Z:", z)}const (K2 = $) func Distance2 (P point) int {return  p.x*p.x+p.y*p.y}type point struct {X inty Int}va R Z = 200

Src:

Http://www.ieyebrain.com:8080/devel/go/src/learn/var_order.go

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.