Go scripting basics Tutorial: Hello world!

Source: Internet
Author: User

First of all, let's talk about the Go statement of environmental security, from the http://golang.org/dl/ operating system is the operating system's security package, go1.3.1.linux-amd64.tar.gz this is a 64-bit Linux security package, go1.3.1.windows-amd64.msi this is a 64-bit Windows system security package. The security process is very simple. Just perform step by step as instructed, A similar article searches for a large film. if you can't ask go's website, let's say that our huge Changcheng fire prevention community has given you security protection. I want to skip this article.

After you have finished the go environment, you may have to select an IDE that fits your needs. In this example, you can select the desired one, of course, it is best to select a one that you are more familiar with, and the professional IDE is liteide, if you have not used a timer before, you can use it. I use editplus myself. In addition, there are notepad ++, sublime, Vim, emacs, and so on. If you choose to use Windows system self-contained event books, I will not translate it into anything else.

After selecting the IDE plugin, let's take a look at my next generation:

 
// Package name package main // package import ("FMT") func main () {FMT. println ("Hello world, Hello world, traditional Chinese! ① ③ ④ ⑤ 7⑦ ⊙ ◎ ");}

For the generation of the upper limit, I will explain it as follows:

The entry to the Go statement is the main method in the main package. This is very important and must be clear, just as we need to create an index when developing a website using PHP. PHP (unless you change the definition of the first delimiter file name)

In this case, I set the package name to main in the first line. Next, I will import an external package FMT using import commands, this is because I will use the method in this package to help me with content delivery, therefore, before using this method, I must first import this package into the container. In fact, you can use the PHP require or include to understand it, however, the difference is that you must use the package imported by go. If the package is imported, the package will never be used again. I like it very much.

The term func is used to define the function, similar to the function of PHP. In this main () in the method, the println method of the FMT package is used to generate the internal volume action. Here, we can simply state that the go statement does not have a public or private fix, whether the method is public depends on whether the first letter of the method name is large. If the first letter is large, the method is public, then he can be used externally. We can see that the println method name in the FMT package is a large margin P, so he is public sensitive, similar to the public function println () {} of PHP, this method can be used externally.

In addition, you may have noticed that the string I want to extract contains some special characters, or you may wonder whether it can be printed correctly, in fact, this attention is a lot of attention, because the go statement is inherently supportive of UTF-8, in fact, if you like it, you can define your changes in Chinese. You will know more about these changes, let's see how to change the quota in my workshop.

 
// Package name package main // package import (export "FMT") func main () {export. println ("Hello world, Hello world, traditional Chinese! ① ③ ④ ⑤ 7⑦ ⊙ ◎ ");}

The output result of this generation is exactly the same as that of the previous generation. The difference is that when I import the FMT package, I rename the package, then, when I use the main () method, the output is generated. println () is not very interesting. this actually benefits from Go's support for UTF-8. it is rarely used in normal development, because it is very simple, I don't want to switch between Chinese and English languages during development.

I hope that my friends can leave an article out, http://see7di.cnblogs.com is grateful here!

I have set up a QQ group. If you are interested in commenting on the go statement, you can join: 195112

Related Article

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.