Tag: Go 1.26
-
Post Views: 22 In the concurrent programming of Go language, goroutine is a lightweight thread implementation. However, if panic occurs in goroutine and is not captured, the entire program will crash. In this article, we will dive into two cases of using and not using Recover in depth through specific examples, and we will dive into how to properly handle…
-
Post Views: 23 In programming learning, judging prime numbers is a classic algorithm problem. When the amount of data is small, the traditional serial loop is enough to cope; but when the amount of data is expanded to hundreds of thousands or more, how to improve the computing efficiency has become the key. Based on the Go language, this paper…
-
Post Views: 36 In the concurrent programming of the Go language, the channel (channel) is the bridge connecting the goroutine. Many beginners often encounter “deadlock” errors when using unbuffered channels, or are confused about the blocking mechanism of the channel. This article will use a specific case to compare two different channel usage scenarios, and deeply analyze the blocking principle…
-
Post Views: 102 Preface In most programming languages, it is quite complex to check if two binary trees store the same sequence of values. It is usually necessary to write a recursive algorithm to traverse the two trees and then compare them by node. But in the Go language, we can use its powerful concurrent primitives and channel (channel) mechanisms…
-
Post Views: 45 In Go language concurrent programming, channel (pipe) is the core mechanism of communication between goroutines, which follows The design philosophy of communicating to share memory, rather than communicating through shared memory, fundamentally solves many hidden dangers of global variable lock synchronization. In the previous study, we understood the necessity of the channel through the factorial case. This…
-
Post Views: 94 In Go language concurrent programming, goroutine is the core of efficient concurrency, but the communication and synchronization between multiple goroutines is often a place for beginners to easily step on pits. This article will take ‘calculate the factorials of 1-200 and store them into Map’ as a case, and combine the problems encountered in the learning process,…
-
Post Views: 29 In Go language, errors are not an exception, but a value. By implementing the Error interface, we can create custom error types with rich context information. This article will combine Go Tour’s ‘exercise: errors’ exercise to explore how to implement a square root function that supports negative number detection, and reveal the ‘infinite recursion’ pit that is…
-
Post Views: 63 Following the previous articleMaps word counting exercisesAfter this, another classic exercise in the introduction of Go language – using closure to implement the Fibonacci sequence generator. This question can not only consolidate the core usage of closed packages, but also deeply understand the characteristics of ‘function as the return value’ in the Go language. This article will…
-
Post Views: 115 As a basic exercise for the entry of Go language, the use of MAPS (mapping) is one of the key knowledge points, and word counting exercise is a classic case of consolidating MAPS usage. This article will record in detail the implementation process, core ideas, code analysis, and key knowledge points involved in the exercise. 1. Description…
-
Post Views: 89 Recently, when I was doing the slices practice of the official go to the go, I encountered a series of dependencies download and running errors, and after tossing, I finally succeeded in running through. I have sorted out the complete stepping process and solutions, hoping to help those who practice Go Tour locally like me, and avoid…