Study on duang~ Golang learning

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

duang~ Golang Learning Preliminary experience, has always been to go language has a certain sense of joy, today took a little time to understand the next go, in fact, a lot of things to get a small example go run will understand a lot of things.

My development tool uses Gosublime to install this plugin in Sublime Text 2 .

To run the Go program, press ctrl+b and enter the go run file name. Go to view results

Here are some of the basics of Golang's demo

Package Mainimport ("FMT") const (PI = 3.14) func mains (a int) int {fmt. Print (H1 (1212)) return a}func H1 (b int) int {return B}func main () {var b int = 1c: = 2var p *int = &cfmt. Println (mains ()) fmt. Print (b >>) if d: = 2; D >= 2 {fmt. Println (*p)}//for Loop Several ways to use for {c++if c > 4 {break}fmt. Println (c)}m: = 5for m < 8 {m++fmt. Println (M)}for I: = 0; I < 5; i++ {fmt. Print (i)}//switch statement use x: = 3switch x {case 0:fmt. Print (0) case 1:fmt. Println ("X=1") case 2:fmt. PRINTLN (2) default:fmt. Println ("Www.sushou.me")}y: = 1switch {case y >= 0:fmt. Println ("0") Fallthrough//By not jumping out of case y >= 1:fmt. Println ("Www.yiicms.net") default:fmt. Println ("Www.sushou.me")}}

Need to run the effect please use go run one to know!


@author http://www.yiicms.net

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.