How is Go Error nesting implemented?

Go Error's design philosophy is "Errors Are Values". How should this sentence be understood? It's difficult to translate. However, from the perspective of source code, it seems easier to understand the meaning behind it. The source code of Go Error is very simple, just a few lines: // src/builtin/builtin.go type error interface { ...

Added by emceej on Sun, 16 Jan 2022 04:54:33 +0200

golang development: use of Error

Error is the most basic and important part of Go language development. It is basically the same as the role of try catch in other languages. Think about the fact that in PHP JAVA development, try catch can't be used or used flexibly, so you can't perceive what errors occur in program operation. It's a particularly terrible thing. Error basis ...

Added by am_25 on Sat, 15 Jan 2022 22:23:06 +0200

Share a wave of GO Crawlers

[TOC] Share a wave of GO Crawlers Let's review the last time we talked about using Google to send email Golang+chromedp+goquery simple crawling dynamic data Go theme month Shared email. What is emailWhat are the mail protocolsHow to send e-mail using GolfHow to send e-mail with plain text, HTML content, attachments, etcHow to send e-mail, ho ...

Added by wyred on Sat, 15 Jan 2022 18:31:24 +0200

Interview frequency: Go language deadlock and goroutine disclosure

Source location of this section https://github.com/golang-minibear2333/golang/blob/master/4.concurrent/4.4-deadlock/ When will deadlock occur In the principle of computer composition, it is said that there are three necessary conditions for Deadlock: Circular waiting, resource sharing and non preemptive. There are only two cases of channel ...

Added by raydenl on Sat, 15 Jan 2022 17:23:54 +0200

Comparison between Go Rust sorting and binary search

Author: Wang DongyangprefaceSorting and binary search are very common algorithms in computer science leveldb memdb source code analysis (Part 2): Rust implementation You can see that many methods use binary search. This paper will compare some characteristics and differences in sorting and search methods between Go and Rust. For Go, we mainly u ...

Added by suncore on Sat, 15 Jan 2022 11:24:57 +0200

How to write efficient unit tests in Go

Importance of single test Convenient debuggingFacilitate code refactoringImprove code qualityMake the whole process agile Go single test Basics Basic rules Usually our unit test code is placed in_ test. In the file ending with go, the file is generally placed in the same package as the object code.The Test method starts with Test and ha ...

Added by geo3d on Sat, 15 Jan 2022 05:31:59 +0200

Pit of incr+expire of redis

background The user needs to perform ocr identification. In order to prevent the interface from being brushed, there is a limit (the number of calls per minute cannot exceed xxx). After investigation, we decided to use the incr and expire of redis to implement this function Note: the following code is implemented using golang First edi ...

Added by aris1234 on Fri, 14 Jan 2022 16:30:01 +0200

Operator SDK: read relevant documents and explain some commands in combination with the official sample built based on GO

Operator SDK: read relevant documents and explain some commands in combination with the official sample built based on GO Read and translate some contents in the official document of operator SDK, and use go language to combine the contents in the official document Building Operators Sample of Quickstart for Go-based Operators : a set of simpl ...

Added by Avimander on Fri, 14 Jan 2022 11:29:35 +0200

See how the Gin framework is implemented

Basic use Gin is a high-performance golang web framework. Its code is actually very few. Compared with spring, understanding gin is really chopping melons and vegetables Let's take a look at the basic usage of gin import "github.com/gin-gonic/gin" func Init() { r := gin.Default() initRoute(r) r.Run() } func initRoute(r *gin.Engine) { r ...

Added by martin_g on Fri, 14 Jan 2022 11:29:42 +0200

Sorting and searching of go language

😶 ‍ 🌫️ go official Programming Guide: https://pkg.go.dev/std Go language official documents, learning notes are very complete, it is recommended to go to the official website to learn 😶 ‍ 🌫️ My study notes: github: https://github.com/3293172751/golang-rearn Blockchain Technology (also known as distributed ledger Technolo ...

Added by isurgeon on Thu, 13 Jan 2022 14:39:15 +0200