Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 GO


  Go是一门面向对象的编程语言吗

Golang已经开源了13年,在最近的TIOBE编程语言排名中,于2023年3月再次进入前十名,并比2022年底的排名上升了两个位置。Go在2022年底提高了2个排名许多第一次接触Go的开发者来自面向对象的编程语言,比如Java、Ruby等,他们在学习Go后第一个问题通常是:Go是一种面向对象的语言吗?在本文中,我们将探讨这个问题。追溯在广为人知的Go编程语言“圣经”《The Go Programming Language》中,有一个Go与其主要祖先编程语言之间的亲缘关系图表。Go与其主要祖...

1,007 0       OOP GOLANG CHINESE GO


  Understand GoLang WaitGroup internals and how it works

BackgroundBefore getting into the main content, let me give a brief introduction to WaitGroup and its related background knowledge. Here, the focus is on the basic usage of WaitGroup and the fundamental knowledge of system semaphores. For those who are familiar with these, you can skip this section directly.WaitGroupWaitGroup is one of the most common concurrency control techniques in Golang, and its function can be roughly compared to the join() in concurrency control of other languages' multithreading. The sample code is as follows:package mainimport ( "fmt" "sync" "time")func main(...

2,106 0       SOURCE CODE GOLANG WAITGROUP


  Mastering Go Channels: How to Build Concurrent Applications Like a Pro

IntroductionIn the world of concurrent programming, Go channels have quickly become a popular tool for building fast and efficient applications. Utilizing channels can help you take full advantage of the power of Go's lightweight threads, or goroutines, and enable you to easily and effectively manage data sharing and synchronization. In this article, we'll dive deep into the world of Go channels and show you how to build concurrent applications like a pro.Understanding Go ChannelsTo start, let's take a closer look at what Go channels are and how they work. In Go, channels are a way to communic...

629 0       CONCURRENCY GOLANG CHANNEL


  Understanding PGO in GoLang 1.20

BackgroundThe Go 1.20 version was officially released in February 2023, it introduced the PGO(Profile Guided Optimization) mechanism.The basic principle of PGO can be divided into the following two steps:First, profiling is performed on the program to collect data about the program's runtime and generate a profiling file.When compiling the program, enable the PGO option, and the compiler will optimize the program's performance based on the content in the .pgo file.When compiling a program, the compiler will perform many optimizations, including well-known optimizations such as inline optimizat...

2,428 0       GOLANG PGO GO 1.20


  A simple tutorial on GoLang connecting to Clickhouse

Go, also known as Golang, is a statically-typed, concurrent programming language created by Google. ClickHouse is a high-performance, column-oriented database management system that can be used for real-time data analysis.This tutorial will provide a deep dive into how to connect to ClickHouse from a Go program, including how to perform common database operations such as SELECT and INSERT statements.Before proceeding, it is assumed that you already have Go and ClickHouse installed on your machine. If not, you can download the latest version of Go from the official website and install it by fol...

4,371 0       TUTORIAL GOLANG CLICKHOUSE


  Introduction to GoLang generics and advanced usage

Generics in Go allow you to write code that can work with multiple types of data, without having to write separate versions of the code for each type. This can make your code more flexible and easier to maintain, as you only need to write and test the code once, rather than maintaining multiple versions.To use generics in Go, you first need to define a type parameter, which is a placeholder for the type that the code will work with. For example, you might define a type parameter called "T" like this:func MyFunction(x T) T { // code here}You can then use the type parameter "T" wherever you wou...

4,182 2       GOLANG GENERICS


  Go channel explained

In Go, a channel is a type of concurrent data structure that allows two or more goroutines (Go's term for lightweight threads) to communicate with each other. Channels provide a way for goroutines to send and receive values, and they are an essential part of Go's concurrency model.Here's a simple example that demonstrates how to use channels in Go:package mainimport ( "fmt")func main() { // Create a new channel with the `make` function ch := make(chan int) // Start a new goroutine that sends the value 5 to the channel go func() { ch <- 5 }() // Read the value fro...

1,734 0       GOLANG CHANNEL


  Go Lacks Ternary Operators. Here Are Some Equivalents

If you were like me, a pure Java developer before writing Go, you must be wondering why Go doesn’t support the ternary operator like return a > 1 ? 0 : 1.Most mainstream languages like C and Java are supportive of ternary operators; languages like Python and Ruby support the simplified if-else one-liner, such as a = 0 if a > 1. However, Go is not among them. And it is not only about adding operators but also a concept of coding in a more convenient way, such as the ?: expression can be perfectly replaced by if-else, but what if you are required to duplicate it dozens or hundred tim...

1,646 2       GOLANG TERNARY OPERATOR