Racing program Rental Go Language Basics 01

Source: Internet
Author: User

General structure of Go program: Basic_structure.go
• Racing program Rental "Enterprise E: 217 1793 408"
go programs are organized through the package
• Only packages with a package name called Main can contain the main function
• One executable program has and only one main package

• Importing other non-main packages via the Import keyword
• Define constants by using the Const keyword
• Declare a global variable by using the var keyword outside the body of the function to assign a value
• Declaration of a struct (struct) or interface (interface) by using the Type keyword
• via the Func keyword

Visibility rules

go language, use casing to determine the constant, variable, type, interface, structure,
or whether the function can be called by an external package
• The function name is private if the first letter is lowercase

The first letter of the function name is public

Package Main
The package name of the current program

Import "FMT"
To import additional packages

Const PI = 3.13
Constants are defined with a const modifier, with names all capitalized

var a string = "Hello"
var b = 123//Automatic type recognition
Declaration and assignment of global variables, global variables can be used throughout the package

Type name int
Basic type declaration

Type Gopher struct {
Age int
Sex int
Declaration of the}//structure

Type Golang Interface {}
Definition of the interface

Func Main () {
Fmt. Println ("Hello,word")
}

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.