Go language basics interview

1. What are the benefits of Go language programming?

It compiles and runs very quickly.

Supports parallel operations at the language level.

There is a garbage disposal.

Built-in strings and maps.

Function is the most basic programming unit of Go language.

2. Let’s talk about the select mechanism of go language

The select mechanism is used to handle asynchronous IO issues

The biggest limitation of the select mechanism is that each case statement must be an IO operation.

golang supports the select keyword at the language level

33.Explain the static type declaration in go language

The static type declaration tells the compiler that it does not need to pay too much attention to the details of this variable.
The declaration of static variables is only for compilation. When linking the program, the compiler will also make an actual declaration of this variable.

34.What is the interface of go?

In the Go language, interface is an interface, which is used to specify an object. The interface has the following elements:

a range of methods

In specific applications and used to represent a certain data type

Use interface to implement polymorphism in go

35. What is the type assertion in Go language?

Type assertions are used to read values ​​from an interface into a specific type variable. Type conversion refers to converting two different data types.

36.What are the default values ​​of local variables and global variables in go language?

The default value for global variables is the zero value associated with this type.

37.What are the benefits of Go language programming?

It compiles and runs very quickly.

Supports parallel operations at the language level.

There is a garbage disposal.

Built-in strings and maps.

Function is the most basic programming unit of Go language.

38.Explain the static type declaration in go language

The static type declaration tells the compiler that it does not need to pay too much attention to the details of this variable.
The declaration of static variables is only for compilation. When linking the program, the compiler will also make an actual declaration of this variable.

39. What is modular programming?

Modular programming refers to decomposing a large program into several small programs. The purpose of this is to reduce the complexity of the program, make it easier to maintain, and achieve the highest efficiency.

40.What’s special about Golang’s methods?

The function definition declares that there are no receivers.
The declaration of a method is similar to that of a function. The difference is that when a method is defined, a parameter is added between func and the method name. This parameter is the receiver, so the method we define is bound to the receiver. Together, call this receiver's method.
There are two types of receivers in Go language: value receivers and pointer receivers. Methods defined using a value type receiver actually use a copy of the value receiver when called, so any operation on the value will not affect the original type variable. ——-Equivalent to formal parameters.
If we use a pointer as the receiver, it will work, because the pointer receiver passes a copy of the pointer to the original value. The copy of the pointer still points to the value of the original type, so when it is modified, it will also Affects the value of the original type variable.

Guess you like

Origin blog.csdn.net/m0_73728511/article/details/133501609