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

 GO


  Secure Your Go Code With Vulnerability Check Tool

Security vulnerabilities exist in any language and any code, some are written by ourselves, but more are from the upstream dependencies, even the underlying Linux. We have discussed the security protection methods for Go and Kubernetes Image in Path to a Perfect Go Dockerfile and Image Vulnerability Scanning for Optimal Kubernetes Security, in which the security scanning was performed based on generic.As the Go community grows, more and more open-source packages have caused more security vulnerabilities, which has raised the concern of Go officials, and then the security sc...

1,856 0       GOLANG GOSEC GOVULNCHECK


  When and How to Use the Go Channel

Go’s concise structure and powerful native library enable us to hit the ground running easily. It is more efficient than Java or Python when implementing the same functions, especially its concurrent programming, which is very handy and widely admired due to its goroutine and channel.goroutine and channel has much to dig into, and let’s start with channel, which I used to consider narrowly as a message queue to transfer data between goroutines and support data synchronization, but definitely owns a bigger stage.Channel == Semaphore + Buf...

1,385 0       GOLANG CONTEXT CHANNEL


  A Sip of Go Log

Logging is indispensable in any code that we need its support both in debugging and in statistics. However, a package that filled withfmt.Println/fmt.Printf printing various messages can never be considered a read-to-be-adopted package, which can be optimized by a simple change, using Golang’s native log package to print information to standard output or to a file.Then, how to apply the log package? Are there any limitations? If so, can we seek open-source packages? Let’s find the answers together.Golang logpackage mainimport "log"func main() { log.Println("Log pri...

1,364 0       GOLANG LOGGING


  Publish Your Go Package on pkg.go.dev

go.dev is a site where various resources for Go developers are shared, such as “Get Started”, Tutorial, Packages (pkg.go.dev), and all the official blogs. Among them, Packages is where I visit most, which allows free access to all the open-source Go packages submitted by communities including the native Golang packages. Thanks to all the contributors, I enjoy the great benefit, and sometimes I want to be a contributor myself.Let’s submit a “complete” package to pkg.go.dev today.Came pkg.go.dev into beingBefore pkg.go.dev’s birth...

2,099 0       GOLANG PUBLISH PACKAGE GO.DEV


  When and Where to Use Pointers in Go

When declaring variables in Go, we usually have two syntax options: In some scenarios, pointers; in others, reference; sometimes, either. It’s great to have choices, but it is also confusing sometimes as to which one in which scenario.To be more reasonable in choice-making, I started from pointers, walked through their natures, and summarized some rules in using them in Go.from unsplash, Jordan LadikosPointersGo has pointers. A pointer holds the memory address of a value.— from A Tour of GoThe data is stored in the memory when the program runs and each has a num...

2,343 0       POINTER GOLANG


  Our Go Cache Library Choices

In Build a Go KV Cache from Scratch in 20 minutes, I walked you through what matters when writing a local cache, and eventually implemented one, whose performance was beaten badly by that of the popular go-cache on Github though. However, the bright side is that we can learn a lot from those excellent Github Go cache products, studying their features, applicable scenarios, and implementations, and extracting what we need.In this article, I will mainly analyze and compare the four cache libraries of go-cache, bigcache, golang-lru, and groupcache, which are all...

1,534 0       CACHE GOLANG GO-CACHE BIGCACHE GOURPCACHE


  golangci-lint to enable comment check for exported functions

golangci-lint is a command line tool which aggregates a list of different go linters to check whether the source code is in correct condition from different aspects. It is built to run during the CI pipeline so that there is no obvious coding issues before compiling and building the program.It is easy to run it with just below command$ golangci-lint run -vINFO [config_reader] Config search paths: [./ /Users /] INFO [config_reader] Used config file .golangci.yml INFO [lintersdb] Active 10 linters: [deadcode errcheck gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck] I...

6,584 1       GOLANG GOLANGCI-LINT REVIVE GOLINT EXPORTED COMMENT


  The magic of go:linkname

When writing Go program, there is frequent need on using time.Sleep() function to pause the logic for some time. And if jumping to the definition of this function, can see below definition:// 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)I's strange that there is no function body defined here. What happened? The actual definition of the function body is residing at runtime/time.go indeed.// timeSleep puts the current goroutine to sleep for at least ns nanoseconds.//go:linkname tim...

12,117 0       TRICKS GOLANG GO:LINKNAME