| 🔗 Stories, Tutorials & Articles | | | | What’s New in Go 1.20 | | | The Go team has added an experimental arena package to the Go standard library in version 1.20. However, it cannot be imported by default and is not recommended for use. To enable it, users must set GOEXPERIMENT=arenas when calling the go tool. The arena package is a memory management technique used to allocate and deallocate large blocks of memory efficiently. It is typically used in situations where the program needs to frequently allocate and deallocate a large number of small objects. This can reduce the overhead associated with memory management and improve performance. However, it is important to note that the arena package is still experimental and may be removed or changed without warning. |
| | | | | | Designing Go Libraries ✅ | | | This is a long-form version of a talk byAbhinav Gupta they gave in 2018 providing guidance on designing libraries in Go. This post is discussing concerns and recommendations for good API design in Go. The primary concerns are usability, readability, flexibility, and testability. It also covers backwards compatibility, including breaking changes and semantic versioning. The recommendations include working backwards, minimizing surface area, avoiding unknown outputs, and avoiding global state. The post also covers best practices for accepting and returning types, upgrading with upcasting, using functional options, handling errors, using goroutines, reflection, naming, documentation, and keeping a changelog.
|
| | | | | | How to Work with SQL Databases in Go | Better Stack Community | | | The article discusses the use of the database/sql package in Go to connect to a database, execute SQL statements, and handle returned results. It also covers advanced topics like prepared statements, transactions, and connection pooling. The article discusses also a list of database tools.Go has a variety of database tools that can be used to improve the overall quality of life when working with SQL databases. These tools are built on top of the database/sql package. The three categories of tools include:- Database migration tools, which migrate data from one source database to another target database, and can also migrate data from one schema to another schema while preserving the original data. Examples include Goose, migrate, and darwin.
- Query builders, which generate functions for querying data based on a set of SQL queries written by the developer, and remove the boilerplate for writing database access queries. Examples include sqlc and jet.
- ORMs, which allow you to query and manipulate data from a database using an object-oriented paradigm.
|
| | | | | | How We Designed Our Scalable Microservice Architecture ✅ | | | Carted is building a universal commerce API that allows developers to embed commerce functionality into any app or website through a single API. They followed a process of defining their requirements, evaluating various approaches to find the best fit for their purposes. They have decided to use a microservice-based architecture, because of the flexibility to add, remove, and maintain multiple versions of similar functionality, ability to easily scale, cloud-native, ease of onboarding new team members, and alignment with a fully distributed team. They use gRPC as a method of inter-service communication, because it has support for their preferred languages, good performance, and a simple service definition. |
| | | | | | How to Use AVX512 in Golang via C Compiler | | | AVX512 is a set of SIMD (Single Instruction, Multiple Data) instructions that can process 512 bits of data in one instruction cycle, which can accelerate the training and inference process of recommendation models in Go. Unfortunately, the Go compiler does not automatically generate SIMD instructions. A toolkit called goat has been developed to convert C code to Go assembly functions, which allows for the use of AVX512 instructions in Go. The toolkit uses the C source code to generate Go assembly functions and Go function definitions, eliminating the need for manual assembly code writing. It also converts assembly instructions to machine code and handles function arguments and jump instructions to make the assembly code compatible with Go. The goat library also provides a collection of vectorized functions that can be used in Go applications. Overall, using goat allows for the use of AVX512 instructions in Go and can potentially bring significant performance improvements for vector computation tasks. |
| | | |
|
|