Sleeping in Go and how to pause execution and sleep for a number of seconds in Go (golang). We can use the time package from the standard library to sleep for a duration of time. You can use any duration of time, providing you use the constants provided.
In our example below we sleep for two seconds, and to illustrate the point, we print out the time before and after we do this.
This will only sleep the current goroutine, other parts will continue.
A Basic Web Scraper in Go
A basic web scraper usually involves a few steps, fetching the content, querying it for the data you’re after and then sometimes, using that data to go and find more as a loop.
In our example below, we use a package called goquery to do most of the heavy lifting for us. This library will go further than Go’s standard library by allowing us to do both the first and second steps a bit easier.
SHA3 Hash in Golang (256-bit)
You can use the golang.org/x/crypto/sha3 [docs] package to perform SHA-3 encoding on a string. We have an example function below, it will take your string and write it as a hash. Then convert that binary back into a hexadecimal string using Sprintf.
Advantages of Using SHA3 Security: SHA-3 was designed to provide higher security compared to SHA-2 by using a different construction called “sponge construction”, which makes it more resistant to various types of attacks, such as collision and preimage attacks.
Top Golang Books for Learning in 2023
1. Go Programming Language Google’s Go team member Alan A. A. Donovan and Brian Kernighan, co-author of The C Programming Language, provide hundreds of interesting and practical examples of well-written Go code to help programmers learn this flexible, and fast, language.
View on Amazon 2. Learning Go: An Idiomatic Approach to Real-World Go Programming Go is rapidly becoming the preferred language for building web services. While there are plenty of tutorials available that teach Go’s syntax to developers with experience in other programming languages, tutorials aren’t enough.