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

 PROGRAMMING


  New function signal.NotifyContext in GoLang 1.16

os/signal package in GoLang may not be frequently used but it provides some good features like Shutdown() which can be used to gracefully shutdown a running HTTP server.func (srv *Server) Shutdown(ctx context.Context) errorWith this function, there is no need to use third party library to gracefully shutdown HTTP server. How is it being used?package mainimport ( "context" "fmt" "net/http" "os" "os/signal" "time")func main() { server := http.Server{ Addr: ":8080", } http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { time.Sleep(time.Second * 10) fmt.Fprint(w, "Hello world!") ...

6,459 0       GRACEFUL SHUTDOWN NOTIFYCONTEXT GOLANG


  Install multiple versions of Go

As a developer, there might be need in some cases to have multiple versions of Go installed. One may test out some new features of the latest version of Go but also wanna maintain a stable version of Go for daily development purpose. How to maintain multiple versions of Go?The GoLang official website has provided a way to maintain multiple versions of Go by using go get to install the different versions of Go.Below are steps:Download a normal version of Go and install itGo to the Go release page to find out which version of go to installRun the go get command to download the version and instal...

5,184 0       GO VERSION GO BINARY MULTIPLE VERSION


  Different ways of handling concurrent job in GoLang

GoLang provides very good support of concurrency and the way to make some code to run concurrent is pretty simple and straightforward. Adding a simple go before a normal function call will make the function call asynchronous.In real cases normally people would concurrently run some jobs to improve the speed and efficiency. One important part of running jobs concurrently is about aggregating results so that the consequent function call would be able to proceed. There are multiple ways handling this scenarios.One of them is using WaitGroup from sync package. The pattern is like:var wg sync.WaitG...

2,524 0       COMPARISON WORKER POOL WAITGROUP CONCURRENT


  Run code with multiple files in the same main package in GoLang

To run a GoLang program, there needs to be a main() function defined. In some cases when developing some demo program which has multiple files and just wanna put them in the same main package and this folder is not in GOPATH, how to run the program?Let's say we have following folder structure where the main() function is defined in main.go.If you just run below command, it would fail to start to run the program and gives some error if some struct is defined in other files and being used.PS D:\Project\Go\sourcecode_updater\v2> go run main.go# command-line-arguments.\main.go:35:11: undefined:...

20,162 0       GOLANG EXECUTABLE MAIN PACKAGE MULTIPLE FILE


  Understanding GoLang interface

If goroutine and channel are considered as the foundation for GoLang concurrency, interface would be the key for data types in GoLang. In practical Go programming, almost all data types are built/used around interfaces, interface is the core of GoLang data structures.Go is not a typical OOP language, it has no class and inheritance concept syntactically. But it doesn't mean that there cannot be polymorphism in GoLang. Because of interface, it achieves the same polymorphism effect as in C++, though syntactically different.Although Go doesn't have concept of class, it allows different data types...

7,426 1       INTERFACE GOLANG


  Error handling in GoLang

Error handling is one of the must talked topics for any programming language. The program would be more reliable and stable if errors are handled properly and timely. Each programming language has its own way to handle error, this applies to GoLang as well. This post will discuss more about GoLang's error handling mechanism.Error handlingBefore talking more about GoLang's error handling, we can see how different programming languages are handling errors.C's error checkThe most direct way of checking error is using error code, and this is also how error is being checked traditionally. In proced...

3,341 0       GOLANG ERROR HANDLING FLUENT INTERFACE


  Go 1.16 is released

Note: The post is authorized by original author to republish on our site. Original author is Stefanie Lai who is currently a Spotify engineer and lives in Stockholm, original post is published here.Last week, Go1.16 was released, bringing relatively more changes than version 1.15, which was influenced by the epidemic.The update is in many aspects, including compilation, deployment, standard library, etc. In the official Go document, all changes are classified based on Tools, Runtime, Complier, etc.It is undoubtedly good to dig into all the changes, but sometimes we understa...

901 0       GOLANG GO1.16 NEW FEATURES


  Top 10 reasons to use a low-code platform

Generally, as the best coding platforms, low code includes low code app development, process development solutions and software development tools. IT users utilize low code solutions as a source of the required building blocks for the building of workflows and applications. The building blocks make it easier to assemble apps and workflows without requiring hand-coding. The growth of low-code platforms therefore levels business grounds by reducing the time spent in coding among other benefits. Organizations now have access to more tools and technologies. For this reason, IT teams can handl...

892 0       LOW CODE PROGRAMMING