1, go scheduling 2, GO struct can be compared

Because it is a strongly typed language, structures of different types cannot be compared, but instance values of the same type can be compared. Instances cannot be compared because they are pointer typesCopy the code

3. Please go defer (for defer)

func b() {
    for i := 0; i < 4; i++ {
        defer fmt.Print(i)
    }
}
Copy the code

4. What is the common term Gorotine (S) used in SELECT

Golang's SELECT is a case of listening for an IO operation. When an IO operation occurs, the corresponding action is triggered. Each case statement must contain an IO operation, specifically, a channel-oriented IO operationCopy the code

Context is usually translated as context. It is an abstract concept, and its essence is that there is a transfer between upper and lower levels, which passes the content to the next level. In Go, a program unit is a Goroutine

6. How does the client implement long connection

Server is set timeout, for loop is iteratedCopy the code

7. How does the main coroutine wait for the rest of the coroutines to complete before operating

Using channels to communicate, context,selectCopy the code

Slice, len, Cap, Share, expand

The append function, since slice's underlying data structure is composed of array, len, cap, so when using append to expand the array, it will check whether there is continuous memory fast, if there is, it will add later, and if there is not, it will generate a large element groupCopy the code

9. How to read map in sequence

Map cannot be read sequentially because it is unordered. To read sequentially, the first problem to be solved is to change the key into order, so you can put the key into the slice, sort the slice, traverse the slice, and value by the key.Copy the code

10. Implement set

type inter interface{}
type Set struct {
    m map[inter]bool
    sync.RWMutex
}
 
func New() *Set {
    return &Set{
    m: map[inter]bool{},
    }
}
func (s *Set) Add(item inter) {
    s.Lock()
    defer s.Unlock()
    s.m[item] = true
}
Copy the code

Implement message queues (multi-producer, multi-consumer)

This can be done using slice lockingCopy the code

12. Sort large files

Merge sort, divide and conquer, split into small files, sortCopy the code

HTTP get and head

HEAD and GET are essentially the same, except that HEAD contains no render data, only HTTP headers. Some people may think that this method is useless, but it is not. Imagine a business situation: To determine whether a resource exists, we usually use GET, but HEAD makes more sense.Copy the code

15, HTTP 401403

401 Unauthorized requests require HTTP authentication information. 403 Forbidden The access to the requested resources is denied by the server. 404 Not Found The requested resource was not found on the serverCopy the code

16, HTTP keep alive

The Connection:keep-alive field must be added to the HTTP request header sent by the client. The Web Server must recognize the Connection:keep-alive field. The Connection:keep-alive field is specified in the HTTP response to tell the client that I can provide the keep-alive service and "promise" the client that I will not close the socket Connection for the time beingCopy the code

HTTP can connect multiple requests at a time, and not return from the back end

HTTP is essentially a socket connection, so sending requests and writing to the TCP buffer can be multiple times, which is why HTTP is statelessCopy the code

18, TCP and UDP differences, UDP advantages, application scenarios

TCP transmits data streams, while UDP packets. TCP passes the three-way handshake. Udp does notCopy the code

19. The role of time-wait

20, how to build an index database

Git file version, use sequence, merge and rebase. Git file version: merge and rebase. Git file version: merge and rebase

27. How to prevent repeated consumption (similar to the idempotence of interfaces) after receiving two identical payment notices from wechat after payment? 29. How to find the corresponding method for the Go reflection package (not to use DeepEqual). DeepEqual (DeepEqual (DeepEqual (DeepEqual)) (DeepEqual (DeepEqual)) (DeepEqual (DeepEqual)) How is it implemented at the bottom? Know but never used, don’t know how to realize 32, Mysql index has several, time complexity is 33, InnoDb table locks or row locks, why (why, answer not to come out here Said only that the row lock) 34, Go channel (with and without buffer buffer), 35, exit the program finished, how to prevent the channel no consumption here initially a bit not clear the interviewer asked, then say the interrupt signal monitoring, do processing for the exit, and then the interviewer said didn’t mean it, and then said told length before sending, What if I don’t know the length? Do you use any kind of message-oriented middleware or something like that? No, anything wrong with that? Evaluation? I have an interview later. I’ll ask you later

38, producer consumer mode, handwritten code (Go directly using channel implementation is very simple, but also think the interviewer will not allow channel implementation, not channel can use array plus conditional variables), how to determine the length of channel buffer, how to control the upstream production speed is too fast, there is no solution here, The length of the channel can be linearly proportional to the speed of the upstream and downstream. The interviewersaid that this is a solution. 41. After writing the code, the interviewer says you can answer the following questions. It doesn’t matter if you don’t know. 43, TimeWait and CloseWait 44, Line segment tree No, dictionary tree? 46. Do you use sync.Pool, why do you use sync.Pool, avoid frequent allocation of objects (GC related), are the objects in there fixed? Don’t know, haven’t read the source code of this 47, what’s the problem? Evaluation? Foundation is good, Linux is short of, Go understanding is not enough in-depth, advanced data structure does not understand, the advantage is the source of 48, behind the interviewer about the things they do, the main part is advertising, said at least more than millions of average daily volume of data, as many as hundreds of millions of, use Go to support high concurrency, with micro service, service management, said the things I need to learn a lot

50, Unique index and primary key index 51, smart pointer 52, string parsing to numbers (consider floating point type)

53, Single signon, TCP sticky packet 54, hand shuffle 55, processing sticky packet broken packet implementation, the interview thought it was related to negle algorithm, explained the next negle is related to confused window syndrome, and then the interview felt that other projects are CRUD, did not ask what system call is used in goroutine scheduling, this does not. 57, Process virtual space distribution, where is the global variable? 58, is there any network programming, yes, how to see the connection state? Netstat, what are they? ESTABLISHED, LISTEN, et cetera. Anything unusual? TIME_WAIT is a lot, why? A large number of short links 59, several basic sorting algorithms say, ask heap time complexity, stability, why not stability 60, topK problem, massive data topK (answer into a number of times to load memory, and then maintain k length of the ordered linked list, and then said that the time complexity is not good, the tip said that or use heap, Then oh, oh, oh, yes) the longest consecutive string and, here I say the solution does not use DP (not familiar with DP), the interviewer has been leading me dp, still not what is the primary key 62, joint index and unique index 62, the more indexes the better? What should I pay attention to when creating an index? 64, The difference between a process and a thread? 65. Deadlock? I said there was only one machine, so I used single-machine deployment. The interviewer said that a single machine can also deploy multiple, is there any method? I say docker, ask docker which network, not familiar, dockerfile keyword, only answer a few. Nginx forwarding, by the way.

70, Database isolation level, commit read will cause what 71, GO scheduling 72, Goroutine leak is not handled, set timeout, select plus timer

Mysql high availability solution 74, process thread difference

I/O model, synchronous blocking, synchronous non-blocking, asynchronous 79, cookie and session

What are the advantages and disadvantages of the internship programCopy the code

80, Interface KPS test 81, Redis leaderboard data structure (skip table), query time complexity 82, Redis distributed, how to reduce the synchronization delay 83, mysql can implement redis function 84, how to learn at normal times? What book to read? Cap theory, for example 90 LRU algorithm, LFU 91, Tell me how to understand network programming

93. Advantages and disadvantages of GO 95. Value passing and reference of GO 96. Slow query 97

99, all left leaf node and 100, and the size of the m a n orderly array, the beginning is 2 way merge, time complexity, and then merge, remind directly at your interviewer m road 101 time complexity, and the static keyword, 102, is there any other keyword hash table design, thread safe? Network programming process select epoll

105, how to implement the go lock, what CPU instruction is used 109, how to implement the GO runtime 110, see SQL connection pool implementation 111, CTX package understand? What’s the use? 112, When do GO memory leaks occur? 113. How do I implement a coroutine perfect exit? 114, intelligence question: 1000 bottles of wine there is a bottle of poison wine, 10 mice, 7 days after the poison just attack, the 8th day to sell, how to beg that bottle of poison wine? How many ways can n*n matrix go from the top left to the bottom right? (In fact, two coprograms are in the same step.) The scheduling model of GO is described

Operating system memory management? 119, implement a hashmap, resolve hash conflict, resolve hash tilt 120, how to understand go interface 121, 10 billion number choose top5, Redis 123, skip list, why skip list and not red black tree 126, what is involved after input URL 127, how can TCP find which socket 128, IPC mode, Where to allocate the stack of a shared memory 130, process virtual space layout 131, process state transition 132, where to allocate the stack of a shared memory 133, multiple threads read, one thread write a int32 will not have a problem, int64 Lru implementation 136, a large integer (in the form of a string), move the character to find the smallest of the numbers larger than it 137, like system design