MindMap Gallery GO basic syntax
Describes the syntax used when learning the GO language, with code attached. It can be used as an introduction to comparative learning of GO language. If there are any additions later, a new map will be published on the work page.
Edited at 2024-01-23 15:35:28This Valentine's Day brand marketing handbook provides businesses with five practical models, covering everything from creating offline experiences to driving online engagement. Whether you're a shopping mall, restaurant, or online brand, you'll find a suitable strategy: each model includes clear objectives and industry-specific guidelines, helping brands transform traffic into real sales and lasting emotional connections during this romantic season.
This Valentine's Day map illustrates love through 30 romantic possibilities, from the vintage charm of "handwritten love letters" to the urban landscape of "rooftop sunsets," from the tactile experience of a "pottery workshop" to the leisurely moments of "wine tasting at a vineyard"—offering a unique sense of occasion for every couple. Whether it's cozy, experiential, or luxurious, love always finds the most fitting expression. May you all find the perfect atmosphere for your love story.
The ice hockey schedule for the Milano Cortina 2026 Winter Olympics, featuring preliminary rounds, quarterfinals, and medal matches for both men's and women's tournaments from February 5–22. All game times are listed in Eastern Standard Time (EST).
This Valentine's Day brand marketing handbook provides businesses with five practical models, covering everything from creating offline experiences to driving online engagement. Whether you're a shopping mall, restaurant, or online brand, you'll find a suitable strategy: each model includes clear objectives and industry-specific guidelines, helping brands transform traffic into real sales and lasting emotional connections during this romantic season.
This Valentine's Day map illustrates love through 30 romantic possibilities, from the vintage charm of "handwritten love letters" to the urban landscape of "rooftop sunsets," from the tactile experience of a "pottery workshop" to the leisurely moments of "wine tasting at a vineyard"—offering a unique sense of occasion for every couple. Whether it's cozy, experiential, or luxurious, love always finds the most fitting expression. May you all find the perfect atmosphere for your love story.
The ice hockey schedule for the Milano Cortina 2026 Winter Olympics, featuring preliminary rounds, quarterfinals, and medal matches for both men's and women's tournaments from February 5–22. All game times are listed in Eastern Standard Time (EST).
GO basic syntax
basic grammar
main function
package declaration
Can be different from the name directory
The declaration of the test file can be added with the _test suffix
The declarations of .go files in the same directory must be consistent, and the declarations of test files must also be consistent.
Accessibility
Capitalized means it can be accessed outside the package.
Lowercase can only be accessed within the package
basic type
int family (can express positive and negative numbers)
int
The number of bytes used by int depends on the CPU
int8
1 byte
int16
2 bytes
int32
4 bytes
int64
8 bytes
unit family (unsigned integer) (can only express positive numbers)
uint
How many bytes are used by uint depends on the CPU
uint8
1 byte
uint16
2 bytes
uint32
4 bytes
uint64
8 bytes
float family
float32
4zijie
float64
8 bytes
string
For splicing
Auxiliary usage using strings package
The double quotes "" inside Println() need to be escaped, otherwise it will cause output errors. When escaping, you can write the content to be output and then copy it into the double quotes, so that the compiler can automatically escape
Println() can also use backticks ` `, and newlines can be added inside the backticks.
When splicing strings, you cannot connect numbers. You need to convert the numbers into strings first and then splice them. Use strconv.Itoa(123) to convert 123 into a string.
What you get using the function len() is the byte length of the string, not the number of characters. Use utf8.RuneCountInString() to get the number of characters
byte type
It is bytes, essentially uint8, which is also used to represent ASCII codes. The corresponding operations are in the bytes package.
[ ]byte slices can be converted to and from strings.
var a [ ]byte = 'a' When assigning a value using single quotes, you can only use a single character. At this time, the ASCII code value of a is 97.
var a [ ]byte = "hello" can be assigned to a string when using double quotes
bool type
And: (a && b)
OrOr:( a || b)
Negation: (!a)
computation
The math package has more auxiliary uses
Hold down the command and click on the package function to jump into the package to see the relevant explanations.
Both sides of the operation must be of the same type. Int and int64 cannot be operated together and must be converted to the same type before operation.
Integers and integer operation results are also integers. If you want to get accurate values, you need to convert them to floating point types and then calculate.
variable
var a int = 123
a := 123
declare and assign
GO type inference
Can only be used for local variables
constant
const a int = 123
You can infer it yourself without the type.
Cannot modify
iota usage
Control constant initialization
However, using iota’s mathematical operations, including displacement operations
function
definition
keyword func
Function name
parameter list
Parameters can have names or not.
Parameters of the same type that are close together can declare their types together.
return value
Allow multiple return values
The return value can have a name, and the scope of the name is the entire function
recursion
Getting Started with Functional Styles
function as variable
local function
function as return value
anonymous function
Closure
context function
functions as types
indefinite parameters
last parameter
Equivalent to using slices
defer
First in, last out
Principles for determining values
Passed as a parameter: determined when defining
Introduced as a closure: determined when used
Modify return value
Only named return values can be modified
Implementation principle
control structure
for
for range loop
for i loop
for condition loop
switch statement
There can be a default branch
No need to break
Compilation can be switched through instructions
1
Naming rules
Capitalization controls accessibility
camel case nomenclature
Support type inference
Recommended Use