Tag:go
-
Go implementation bubble sort example code
Bubble sorting: the basic idea of bubble sorting is to compare the sorting codes of adjacent elements from the back to the front (starting from the element with larger subscript) of the sequence to be sorted. If the reverse order is found, it will be exchanged, so that the element with smaller sorting code will […]
-
Go obtains the SQL information executed by the current request based on Gorm (detailed idea)
preface In order to facilitate accurate troubleshooting, it is necessary to record the corresponding relationship between the current request information and the currently executed SQL information settings. The recorded SQL information includes: Current time of SQL execution; File address and line number of executing SQL; The time spent executing SQL; Number of rows affected by […]
-
A detail of go select deadlock
catalogue The following pair is aselect Deadlock problem ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 package main import “sync” func main() { var wg sync.WaitGroup foo := make(chan int) bar := make(chan int) wg.Add(1) go func() { defer wg.Done() select […]
-
Time in go Implementation of rfc3339 time format
During the development process, we sometimes encounter such problems. How can we solve this problem by changing 2020-11-08 t08:18:46 + 08:00 to 2020-11-08 08:18:46?To solve this problem, it’s best not to use string interception, or string interception is the most stupid method, which should be the problem of time formatting. Let’s first look at the […]
-
Understand addressable and non addressable in go
catalogue 1. What is addressable? 2. What are addressable? Variable: & X Pointer: & * x Array element index: & A [0] section Slice element index: & s [1] Combined literal: & struct {X type} {value} 3. What are not addressable? constant character string Function or method Basic type literal Elements in map array literal […]
-
A second to understand go to write the code of command-line tools
preface Recently, because the project needs to be written for a period of timeGo, relative toJavaThe grammar is simple and at the same time has some advantagesPythonGrammar candy like that makes people shout “really fragrant”. But at this stage, it is still relatively stablePythonWrite more. Sometimes I have to write backJava; Natural pairGoNot much familiar. […]
-
Copy between go struct, map, slice, etc
Original is not easy, please do not reprint without permission. When writing interfaces, we often encounter this situation. We need to convert a struct object into another struct object, but the two structs only have different struct names, but the attribute names are basically the same.For example, you need toUserObject conversionUserRespObject. Or you need to […]
-
Localization operating system Galaxy Kirin operating system V10 installation deployment go detailed explanation
1、 Go overview Go is an open source programming language that can easily build simple, reliable and efficient software. It is statically typed and generates compiled machine code binaries. Go language is a compiled language, which is very popular among developers, because it means that there is no need to compile source code to create […]
-
Time processing skills of carbon Library in go language
catalogue 1. Time zone 2. Time calculation 3. Time comparison 4. Format 5. Advanced features 6. Customize working days and weekends Carbon Library of go language Carbon is a time extension library that provides an easy-to-use interface. Simple example: package main import ( “fmt” “github.com/uniplaces/carbon” “time” ) func main() { //Print current time now :=carbon.Now().DateTimeString() […]
-
Can go achieve AOP?
Hello ~ Hello, I’m Xiaolou. Today’s topic isCan go achieve AOP? background Students who write java like to compare the two when they write go. They often see discussions in the technology group. For example, can go realize AOP like Java? It’s troublesome for go to write a transaction. Is there a @ transactional annotation […]
-
Complete centos7 in 30 minutes 6. Latest production environment configuration (git2.35.1 Python 3.10.2 golang1.18 docker nginx)
0. Server preparation & target Before that, the server mainly uses Ubuntu LTS, and the RH system has not been tried. It happens to be tested with an Alibaba cloud server that is about to expire. After running for 2 months to test the stability, take notes and install another one, it will be faster […]
-
go time. Sleep specified time (hours to nanoseconds)
The function used by go to specify the sleep time is time Sleep, interface: // Sleep pauses the current goroutine for at least the duration d. // A negative or zero duration causes Sleep to return immediately. func Sleep(d Duration) The incoming is a duration, so if you want to sleep for 5S, you can’t […]