This is a creation in Article, where the information may have evolved or changed.
Package Main
Import "FMT"
Func Main () {
Fmt. Pritln ("Hello word!" )
}
The function name of our program is main. Although there is no limit to the name, the main function of the main package is the entry for each executable program. The "package" then wraps the relevant functions, variables, and constants to be imported with import before they can be used. For example, if we import a FMT package, we can use its println function.
The "Hello word!" in double quotes "is the string constant of go. Unlike the C string, the Go program can not change the contents of a string, but simply copies its address and length as a string value to the parameter. It can also be said that the go parameter pass, is the value of the pass, and no other language of the kind of indirect reference parameters.
The Go language enforces code styles , such as the go language requires public variables to start with uppercase letters and private variables to start with lowercase letters, which not only exempts the public, private keywords, but more importantly unifies the naming style. In addition, the go language is mandatory for {}, for example, the following styles are correct:
If expression {
......
}
But the following wording is wrong:
If expression
{
......
}