Articles tagged "go"
Preserving comments when parsing and formatting code
Published on 2023-11-02
Some tools in the Bazel ecosystem can preserve comments when formatting a BUILD file, even after significant modifications. In this article, I'll compare Go's parser and formatter with the library used by the Bazel tools. Both libraries can preserve comments, but the Bazel library does it better.
Tagged:
bazel compilers go parsers
Goroutines: the concurrency model we wanted all along
Published on 2023-07-02, edited on 2023-07-07
Goroutines are the single feature that distinguishes Go from other languages. They look very much like threads, but they are cheap to create and manage. Go's runtime schedules goroutines onto real threads efficiently so you can easily create lots of goroutines.
Tagged:
concurrency go java
ctxio: A new Go package for cancellable I/O
Published on 2023-01-15, edited on 2023-01-16
ctxio is a small Go library that lets you cancel long-running I/O operations using context.Context. Say you're writing a command-line tool that copies large files, perhaps on a slow network file system. When the user presses ^C, you want to cancel ongoing copy operations and clean up partially written files.
Tagged:
go
Go Editor Support in Bazel Workspaces
Published on 2022-11-21, edited on 2022-11-26
The story of how Go editor support was implemented in Bazel workspaces. This article is the script I wrote for that talk, together with my slides.
Tagged:
bazel editors go
Curiosities of the Go testing package
Published on 2022-05-26, edited on 2022-06-10
go test and the testing package have a pretty unique way of doing things. Their implementations are clever, but far from obvious, and the answers weren't clear until I started working on the testing package itself.
Tagged:
go
Internals of Go's new fuzzing system
Published on 2022-02-17
Go 1.18 is coming out soon. It's a huge release, but native fuzzing has a special place in my heart. Not much has been written yet on how Go's fuzzing system actually works, so I'll talk a bit about that here.
Tagged:
fuzzing go
Leaving Google
Published on 2021-10-22
Last Friday was my last day at Google. This article is a reflection on the last seven years of my life, thinking about what was important and what I'll do differently in the future.
Tagged:
bazel career go
Life of a Go module
Published on 2021-03-26
Go's module system is decentralized. An author can publish a new version by simply creating a tag in the module's source repository. How exactly does that work? What does the go command download, and from where?
Tagged:
git go modules
Error handling guidelines for Go
Published on 2020-12-28
Error handling is one of the most ambiguous parts of programming. There are so many ways to do it. One approach is usually better than others, but it's not always clear what that is, especially in a new language or environment.
Tagged:
go
Accessing private GitHub repositories over HTTP
Published on 2020-05-10
This article provides instructions on configuring Git to authenticate with private GitHub repositories. This is helpful for downloading Go modules in a CI environment where HTTP is preferred, credentials can't be stored permanently, and typing a password or tapping a security key is not possible.
Tagged:
git go
Export data, the secret of Go's fast builds
Published on 2020-03-07
Each compiled Go package contains export data, a binary description of its exported definitions. When the compiler handles an import, it can quickly scan export data to learn about the imported package's definitions. This is much faster than parsing and type-checking sources for imported packages, so building large programs is very fast.
Tagged:
compilers go
Writing Bazel rules: data and runfiles
Published on 2020-02-01, edited on 2023-10-12
Bazel has a neat feature that can simplify a lot of work with tests and executables: the ability to make data files available at run-time using `data` attributes. This is useful for all kinds of things such as plugins, configuration files, certificates and keys, and resources.
Tagged:
bazel go
Writing Bazel rules: platforms and toolchains
Published on 2019-12-07, edited on 2020-02-01
Bazel can isolate a build from the host system using platforms and toolchains. In this article, we'll walk through the process of configuring our simple set of rules to use toolchains. When this is done, the rules will be almost completely independent from the host system.
Tagged:
bazel go
Writing Bazel rules: repository rules
Published on 2019-11-09, edited on 2020-02-01
In this article, we'll define a repository rule that downloads a Go toolchain and generates a custom build file. This lets us avoid depending on the host toolchain, which aids reproducibility and make remote execution possible.
Tagged:
bazel go
Writing Bazel rules: moving logic to execution
Published on 2018-12-26, edited on 2023-10-15
Bazel's execution phase has many advantages, and you should prefer to implement rule logic there if at all possible. Execution code has I/O access to source files. It can be written in any language. Work can be distributed across many machines, so it can be faster for everyone.
Tagged:
bazel go
Writing Bazel rules: library rule, depsets, providers
Published on 2018-08-15, edited on 2020-02-01
We'll define a go_library rule, which can be depended on by other libraries and binaries. We'll also cover structs, providers, and depsets. They are data structures used to pass information between rules, and we'll need them to gather information about dependencies.
Tagged:
bazel go
Writing Bazel rules: simple binary rule
Published on 2018-07-31, edited on 2023-09-10
Bazel lets you write rules in Starlark to support new languages. This time, we'll cover writing a simple rule that compiles and links a Go binary from sources. Bazel rules are highly structured, and learning this structure takes time. However, this structure helps you avoid introducing unnecessary complication in complex builds.
Tagged:
bazel go
Thoughts from GopherCon 2017
Published on 2017-07-17
Just got back from GopherCon 2017, my first Go conference. It was great to meet a lot of prominent people and hear some new ideas. I'm writing down some thoughts and ideas while they're still fresh.
Tagged:
go