rakyll.org

Recent content on rakyll.org
https://rakyll.org/ (RSS)
visit blog
Generics facilitators in Go
20 Dec 2021 | original ↗

Go 1.18 is going to be released with generics support. Adding generics to Go was a multi-year effort and was a difficult one. Go type system is not a traditional type system and it was not possible just to bring an existing generics implementation from other language and be done. The current proposal was accepted after years of user research,...

Shardz
3 Dec 2021 | original ↗

Shard coordination has been one of the bigger challenges to design sharded systems especially for engineers with little experience in the subject. Companies like Facebook have been using general purpose shard coordinators, e.g. Shard Manager, and suggesting that general purpose sharding policies have been widely successful. A general purpose...

Spanner's SQL support
22 Jul 2020 | original ↗

Spanner is a distributed database Google initiated a while ago to build a highly available and highly consistent database for its own workloads. Spanner was initially built to be a key/value and was in a completely different shape than it is today and it had different goals. Since the beginning, it had transactional capabilities, external...

Notes on the Go generics proposal
17 Jun 2020 | original ↗

Update: The proposal draft has been revisited to use brackets instead of parenthesis. This article will be updated with the new syntax soon. Ian Lance Taylor and Robert Griesemer have been working on a generics proposal for Go for a while. Unlike other proposals, a highly significant language change as such generics will require experimentation...

Spanner's high availability writes
19 May 2020 | original ↗

Spanner is a relational database with 99.999% availability which is roughly 5 mins a year. Spanner is a distributed system and can span multiple machines, multiple datacenters (and even geographical regions when configured). It splits the records automatically among its replicas and provides automatic failover. Unlike traditional failover models,...

Go for Cloud
6 Feb 2020 | original ↗

Go has been continuously growing in the past decade, especially among the infrastructure teams and in the cloud ecosystem. In this article, we will go through some of the unique strengths of Go in this field. We will also cover some gotchas that may not be obvious to the users at the first sight. Build small binaries. Go builds small binaries....

Inlined defers in Go
20 Jan 2020 | original ↗

Go’s defer keyword allows us to schedule a function to run before a function returns. Multiple functions can be deferred from a function. defer is often used to cleanup resources, finish function-scoped tasks, and similar. Deferring functions are great for maintability. By deferring, for example, we reduce the risk of forgetting to close the file...

NUMA
18 Nov 2019 | original ↗

Non-uniform memory access (NUMA) is an approach to optimize memory access time in multi-processor architectures. In NUMA architectures, processors can access to the memory chips near them instead of going to the physically distant ones. In the distant past CPUs generally ran slower than the memory. Today, CPUs are quite faster than the memory...

The Go type system for newcomers
27 Dec 2017 | original ↗

It is real struggle to work with a new language, especially if the type doesn’t resemble what you have previously seen. I have been there with Go and lost my interest in the language when it first came out due to the reason I was pretending it is something I already knew. Go is considered as an object-oriented language even though it lacks type...

pprof user interface
10 Oct 2017 | original ↗

pprof now is coming with a Web UI. In order to try it out, go get the pprof tool: $ go get github.com/google/pprof The tool launches a web UI if -http flag is provided. For example, in order to launch the UI with an existing profile data, run the following command: $ pprof -http=:8080 profile.out You can focus, ignore, hide, and show with regexp....

The future of latency profiling in Go
18 Jul 2017 | original ↗

Note: This article contains non-finalized ideas; we may end up not implementing any of this but ideally we should do work towards the direction explained here. Go is the language to write servers, Go is the language to write microservices. Yet, we haven’t done much in the past for latency analysis and observability/diagnostics of request/RPC...

Go's work-stealing scheduler
16 Jul 2017 | original ↗

Go scheduler’s job is to distribute runnable goroutines over multiple worker OS threads that runs on one or more processors. In multi-threaded computation, two paradigms have emerged in scheduling: work sharing and work stealing. Work-sharing: When a processor generates new threads, it attempts to migrate some of them to the other processors with...

Profiler labels in Go
3 Jul 2017 | original ↗

Go 1.9 is introducing profiler labels, a way to add arbitrary key-values to the samples collected by the CPU profiler. CPU profilers collect and output hot spots where the CPU spent most time in when executing. A typical CPU profiler output is primarily reports the location of these spots as function name, source file/line, etc. By looking at the...

Custom pprof profiles
30 Jun 2017 | original ↗

Go provides several pprof profiles out of thet box to gather profiling data from Go programs. The builtin profiles provided by the runtime/pprof package: profile: CPU profile determines where a program spends its time while actively consuming CPU cycles (as opposed while sleeping or waiting for I/O). heap: Heap profile reports the currently live...

Debugging Go core dumps
22 May 2017 | original ↗

Debugging is highly useful to examine the execution flow and to understand the current state of a program. A core file is a file that contains the memory dump of a running process and its process status. It is primarily used for post-mortem debugging of a program, as well as to understand a program’s state while it is still running. These two...

Automatic Stackdriver Tracing for gRPC
22 Mar 2017 | original ↗

In monolithic systems, it is relatively easy to collect diagnostic data from the building blocks of a program. All modules live within one process and share common resources to report logs and errors. Once you are distributing your system into microservices, it becomes harder to follow a call starting from the user’s entry point until a response...

Naming tests to self-document
3 Feb 2017 | original ↗

Go doesn’t specifically enforce you how you choose your test names. Tests are a significant contributors for the maintainability of your code. Tests not just providing correctness checking but also are useful in self documenting your code and its usage. On top of that, tests are the single best source to read about responsibilities of a type,...

Style guideline for Go packages
14 Jan 2017 | original ↗

Go is about naming and organization as much as everything else in the language. Well-organized Go code is easy to discover, use and read. Well-organized code is as critical as well designed APIs. The location, name, and the structure of your packages are the first elements your users see and interact with. This document’s goal is to guide you...

Go 1.8 development stats
11 Jan 2017 | original ↗

Go 1.8 is going to to launched in February 2017. There is a sizable list of new features and improvements on the release notes. While these notes is the best summary to see what has happened in the last 6 months, I will try to give you some stats to give you a sense of the size of the work. I have examined all the changes merged into the tree...

Mutex profile
19 Dec 2016 | original ↗

Go 1.8 introduces a new profile, the contended mutex profile, that allows you to capture a fraction of the stack traces of goroutines with contended mutexes. You need to set the sampling fraction by calling runtime.SetMutexProfileFraction to a value above zero to enable collection. Consider the following program: import _ "net/http/pprof" var mu...

The default GOPATH
14 Dec 2016 | original ↗

Go 1.8 will set a default GOPATH if the GOPATH env variable is not set. The requirement of setting a GOPATH has been a major issue for Go users who installed the Go tools for the first time and got the “you have to set a GOPATH” error in their initial experience with the tools. Explaining the GOPATH is and instructing how to set this env variable...

HTTP/2 Server Push
10 Dec 2016 | original ↗

Go 1.8 is going to feature support for HTTP/2 server push. HTTP/2 has many features designed to make the Web faster. One of those features is the server push, the ability to send resources before the client asks for it. This feature enables websites to push assets like JavaScript and CSS files before waiting for the web page to be loaded and...

Deprecation notices in Go
8 Dec 2016 | original ↗

In Go, for a long time, we didn’t have a convention to label the deprecated APIs. In the past years, there is new convention emerged to add deprecation notices to the docs. Today, standard library uses this specific format. As an example, Go 1.8 deprecates sql/driver.Execer and adds a deprecation notice to its godoc. // Execer is an optional...

Using contexts to avoid leaking goroutines
25 Oct 2016 | original ↗

The context package makes it possible to manage a chain of calls within the same call path by signaling context’s Done channel. In this article, we will examine how to use the context package to avoid leaking goroutines. Assume, you have a function that starts a goroutine internally. Once this function is called, the caller may not be able to...

Debugging code generation in Go
15 Oct 2016 | original ↗

Last week, I was at dotGo. I gave a very short lightning talk about inspection of code generation with the tools already available in the toolchain. This post goes through the talk for those who didn’t have the privilege to be at the conference. Slides are also available at go-talks. Throughout this article, we will use the following program:...

Keeping Go a human-first language
11 Oct 2016 | original ↗

Disclaimer: I forked my opinions on this one from a barely readable Twitter thread and wanted to write it down how I feel about keeping the language internals away from the users, especially from the newcomers. This is not a skill-level concern, it is a core goal of Go to provide a high-level programming language that saves users from excessive...

Go tooling essentials
25 Sept 2016 | original ↗

New to the Go tools? Or do you want to expand your knowledge? This article is about the flags for the Go tools everyone should know. Disclaimer: This article might be slightly biased. This is a collection of flags I personally use and flags people around me having trouble finding references for. If you have more ideas, ping me on Twitter. $ go...

Examples coverage
8 Sept 2016 | original ↗

Go programming language provides many unique good features to write and maintain examples for your packages backed by the testing tools. As an addition to the test coverage and test coverage report, go test also can provide coverage for testable examples. Use the following commands in your package to use the -run flag to only the match the...

Parallelize your table-driven tests
6 Sept 2016 | original ↗

With Go 1.7, testing package supports sub-tests that allows you to run multiple smaller tests from a test case. Each sub test is reported independently in the go test output. More information about these recent additions can be found at Marcel van Lohuizen’s recent talk from GolangUK 2016. These additions to Go 1.7 enabled reporting and other...

Using Instruments to profile Go programs
2 Sept 2016 | original ↗

Apple has a suite of instrumentation and tracing tools for performance analysis available as a part of their Xcode tooling set. In this article, we will use Instruments to record and analyze the CPU profile of a Go program. Instruments also provide a large set of macOS-specific tracing and profiling if you have performance issues specifically on...

Bidirectional gRPC streaming for Go
30 Aug 2016 | original ↗

Disclaimer: This article is not about a core Go package or tool but gRPC. gRPC provides support for implementing streaming endpoints as well as streaming support in their clients. Bidirectional streaming is useful if you want both server and client to be able to communicate to the other side independently in a full duplex fashion. In this...

Apply transformations to Go code with eg
27 Aug 2016 | original ↗

If you are willing to make large scale refactoring in your Go programs, automating the refactoring tasks is more desirable than manual editing. eg is a program that allows you to perform transformations based on template Go files. To install the tool, run the following: $ go get golang.org/x/tools/cmd/eg eg requires a template file to look for...

About
27 Aug 2016 | original ↗

This blog aims to fill the gaps in knowledge transmission and provide useful everyday tips about the Go programming language, its packages and tools. I started this blog when she was working on the Go team at Google and an trying my best to keep it alive. About the author I work at GitHub as a Distinguished Engineer, primarily focused on our...

Calling Go from Swift
3 Oct 2015 | original ↗

Note: Swift bindings are highly experimental and subject to change. This work must currently be classified as preliminary work and we will be improving APIs in the long term. As a part of the Go Mobile, we have announced tools and packages that make language bindings from Java to Go and Objective-C to Go available. A relatively new and less...

Go cross compilation
8 Sept 2015 | original ↗

Note: This article extends Dave Cheney’s Go 1.5 cross compilers post. Cross compilers got easier with Go 1.5. You don’t have to bootstrap the standard library and toolchain as you used to do prior to 1.5. If cgo is not required The go tool won’t require any bootstrapping if cgo is not required. That allows you to target the following program to...

Interface pollution in Go
18 Oct 2014 | original ↗

If there was a single powerful language feature in Go, it’d be the interfaces. The internals of Go contain strong combinations of useful ideas from various type systems and inevitably they ring the curiosity bells. I recently surveyed Github for Go interface declarations, and the results indicated that Go users pollute the environment with...

Archive
1 Jan 2001 | original ↗

Generics facilitators in GoGenerics facilitators in Go Dec 20, 2021Dec 20, 2021 ShardzShardz Dec 3, 2021Dec 3, 2021 Spanner's SQL supportSpanner's SQL support Jul 22, 2020Jul 22, 2020

↑ these items are from RSS. Visit the blog itself at https://rakyll.org/ to find other articles and to appreciate the author's digital home.