First, the methodWhen a function is declared, a variable is placed before its name, which is a method. This additional parameter attaches the function to this type, which is equivalent to defining an exclusive method for the type. Such as:Package
DeferAutomatically executes code when the function exits, regardless of whether the program has an exceptionPractical Example 1package mainimport ( "fmt")func main() { defer func() { fmt.Println("main defer") }() if err := test0();
There are only three types of reference in Golang: Slice (slice), map (dictionary), channel (pipeline);
Reference type
Reference type understood as (C language): pointer
Value type
Copy of the value
The following are examples of value
Recently in the development process encountered several goroutine communication problems, I think these questions are very representative, so take out and share with you.
Check if channel is closed
In the development process encountered such a
Insertion Sorting algorithm principle:The sequence takes a number from the sequence and compares it to the element on the left, and if the left element is larger than the number taken, move to the right until the number is inserted at a position not
Map must be familiar to everyone, below a simple record of today's development encountered pit.
Basic Concepts > dictionaries (MAP)
A dictionary is a set of unordered, key-value pairs. A dictionary is also called an associative array, because the
Usually the chat room architecture is divided into server-side and client:
Server-side:Accept the connection request from the client and establish the connection;All client connections are placed into the connection pool for broadcast
Linux (CentOS redhat) installation1. Access to the official address:https://golang.org/dl/Because of the relevant ZC you know, it's better to go through the wall.2. Download the 64-bit Green
have been concerned about Golang and Kotlin, just recently a small project, considered a, decided to use Golang try.Had to spit on the groove, Golang's reliance on management is really pretty rotten, and maven, NPM this completely can't be compared,
The Go language is a fast, static type of development language. Its main features include automatic garbage collection, concurrent programming, reflection, and so on.
Website
https://golang.org/
Download
Open https://golang.org/dl/ to view
The first two days, in the Drip interview, was asked to achieve priority in select, but know that the event in select is triggered randomly, did not think how to implement, the interviewer told you can use the default implementation, think of the
First, the Language foundation
Main.main function Execution procedureImage.png
Slice the underlying array part is passed by an implicit pointer (the pointer itself is a value, only pointing to the same data), and the callee modifies the data
What am I going to write?
"Understand each line of code-kubernetes" will contain k8s the entire project source code analysis, considering the threshold problem, before starting to analyze the k8s I will be in some of the less difficult Golang open
Project Address: Https://github.com/chenhg5/go ...
Sometimes in order to make better use of the computer resources, we can put some time-consuming task queuing asynchronous execution. To give a simple example of life is the majority of restaurants
说明
Write for the first time, do not know what is written, like to a praise, do not like to give me a message. --ants climb trees are not afraid of high, heart learning not afraid of old.
场景
The message is a bridge between the platform and
Linux and Windows 64-bit executables are compiled under MAC
Linux under Compile Mac and Windows 64-bit executable program
Windows compiles MAC and Linux 64-bit executables
SET CGO_ENABLED=0SET GOOS=darwinSET GOARCH=amd64 go build main.goSET
Through sync. Once instance to ensure that the do of a once instance is executed only once, regardless of whether the Func in do has multiple or one, using this feature to implement the singleton pattern in the design pattern, there is no such thing
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