# go test

Published articles for go test.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Testing only changed Go packages

DevFeed: [Testing only changed Go packages](<https://devfeed.tech/articles/testing-only-changed-go-packages-37735.md>)

Original publisher: [Read original article](<https://carlosbecker.com/posts/go-test-changed/>)

Author: Carlos Alexandro Becker

Published: 2024-12-30T00:00:00Z

Content type: tutorial

Language: en

Sources: [Carlos Becker](<https://devfeed.tech/sources/carlos-becker.md>)

Topics: [Go Language](<https://devfeed.tech/topics/go-language.md>), [Testing](<https://devfeed.tech/topics/testing.md>), [go test](<https://devfeed.tech/topics/go-test.md>), [Shell](<https://devfeed.tech/topics/shell.md>), [Caching](<https://devfeed.tech/topics/caching.md>), [Command-line interface](<https://devfeed.tech/topics/cli.md>)

Tags: [caching](<https://devfeed.tech/tags/caching.md>), [go](<https://devfeed.tech/tags/go.md>), [go-test](<https://devfeed.tech/tags/go-test.md>), [shell-script](<https://devfeed.tech/tags/shell-script.md>), [testing](<https://devfeed.tech/tags/testing.md>)

### AI overview

A practical shell script tip for running tests only in changed Go packages, with an additional file-watching workflow for rerunning tests when files change. The article explains that this approach can be faster but is less correct than running the full test suite, which should always run in CI.

### Source excerpt

Sometimes, working on big projects, running all tests locally take too much time.

## Contextual logging in Kubernetes 1.29: Better troubleshooting and enhanced logging

DevFeed: [Contextual logging in Kubernetes 1.29: Better troubleshooting and enhanced logging](<https://devfeed.tech/articles/contextual-logging-in-kubernetes-1-29-better-troubleshooting-and-enhanced-logging-17570.md>)

Original publisher: [Read original article](<https://www.kubernetes.dev/blog/2023/12/20/contextual-logging/>)

Author: The Kubernetes Authors

Published: 2023-12-20T17:30:00Z

Content type: release

Language: en

Sources: [Kubernetes Contributors Blog](<https://devfeed.tech/sources/kubernetes-contributors-blog.md>)

Topics: [Kubernetes](<https://devfeed.tech/topics/kubernetes.md>), [Logging](<https://devfeed.tech/topics/logging.md>), [Instrumentation](<https://devfeed.tech/topics/instrumentation.md>), [telemetry](<https://devfeed.tech/topics/telemetry.md>)

Tags: [go-test](<https://devfeed.tech/tags/go-test.md>), [instrumentation](<https://devfeed.tech/tags/instrumentation.md>), [kubernetes](<https://devfeed.tech/tags/kubernetes.md>), [logging](<https://devfeed.tech/tags/logging.md>), [logs](<https://devfeed.tech/tags/logs.md>), [tests](<https://devfeed.tech/tags/tests.md>), [troubleshooting](<https://devfeed.tech/tags/troubleshooting.md>), [unit-tests](<https://devfeed.tech/tags/unit-tests.md>)

### AI overview

The article announces that Kubernetes contextual logging, introduced in Kubernetes v1.24, has been migrated to kube-scheduler, kube-controller-manager, and some directories. Based on the go-logr API, the feature passes logger instances through callers to support structured logs with additional context, improving troubleshooting and test output in parallel applications.

### Source excerpt

On behalf of the Structured Logging Working Group and SIG Instrumentation , we are pleased to announce that the contextual logging feature introduced in Kubernetes v1.24 has now been successfully migrated to two components (kube-scheduler and kube-controller-manager) as well as some directories. This feature aims to provide more useful logs for better troubleshooting of Kubernetes and to empower developers to enhance Kubernetes. What is contextual logging? Contextual logging is based on the go-logr API. The key idea is that libraries are passed a logger instance by their caller and use that for logging instead of accessing a global logger. The binary decides the logging implementation, not the libraries. The go-logr API is designed around structured logging and supports attaching additional information to a logger. This enables additional use cases: The caller can attach additional information to a logger: WithName adds a "logger" key with the names concatenated by a dot as value WithValues adds key/value pairs When passing this extended logger into a function, and the function uses it instead of the global logger, the additional information is then included in all log entries, without having to modify the code that generates the log entries. This is useful in highly parallel applications where it can become hard to identify all log entries for a certain operation, because the output from different operations gets interleaved. When running unit tests, log output can be associated with the current test. Then, when a test fails, only the log output of the failed test gets shown by go test. That output can also be more verbose by default because it will not get shown for successful tests. Tests can be run in parallel without interleaving their output. One of the design decisions for contextual logging was to allow attaching a logger as value to a context.Context. Since the logger encapsulates all aspects of the intended logging for the call, it is part of the context,

## Table driven tests in Go

DevFeed: [Table driven tests in Go](<https://devfeed.tech/articles/table-driven-tests-in-go-22198.md>)

Original publisher: [Read original article](<https://www.ardanlabs.com/blog/2023/01/table-driven-tests-in-go.html>)

Published: 2023-01-19T00:00:00Z

Content type: tutorial

Language: en

Sources: [William Kennedy](<https://devfeed.tech/sources/william-kennedy.md>)

Topics: [Go Language](<https://devfeed.tech/topics/go-language.md>), [test](<https://devfeed.tech/topics/test.md>)

Tags: [documentation](<https://devfeed.tech/tags/documentation.md>), [go](<https://devfeed.tech/tags/go.md>), [go-test](<https://devfeed.tech/tags/go-test.md>), [golang](<https://devfeed.tech/tags/golang.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [learn](<https://devfeed.tech/tags/learn.md>), [table-driven-tests](<https://devfeed.tech/tags/table-driven-tests.md>), [tests](<https://devfeed.tech/tags/tests.md>), [tips](<https://devfeed.tech/tags/tips.md>), [unit-tests](<https://devfeed.tech/tags/unit-tests.md>), [video](<https://devfeed.tech/tags/video.md>)

### AI overview

A video tutorial explains table-driven tests in Go and shows how sub-tests can make failing cases easier to identify when testing many inputs.

### Source excerpt

Introduction Table tests are a great way to test different inputs and associated outputs for a function in Go. To write a table test, you define a slice of some data struct with fields of the input data you'll need and the expected outcome. Then you can loop through this slice and pass the data stored for each element to your function. One disadvantage of table tests is as the data set in your slice grows, the harder it is to find the failing case. Luckily, Miki will share some tips to manage this with the Go test suite.

## go test -v streaming output

DevFeed: [go test -v streaming output](<https://devfeed.tech/articles/go-test-v-streaming-output-20828.md>)

Original publisher: [Read original article](<https://dave.cheney.net/2020/03/10/go-test-v-streaming-output>)

Author: Dave Cheney

Published: 2020-03-10T07:03:03Z

Content type: article

Language: en

Sources: [Dave Cheney](<https://devfeed.tech/sources/dave-cheney.md>)

Topics: [Go Language](<https://devfeed.tech/topics/go-language.md>), [Streaming](<https://devfeed.tech/topics/streaming.md>), [Testing](<https://devfeed.tech/topics/testing.md>), [Unit testing](<https://devfeed.tech/topics/unit-testing.md>)

Tags: [go](<https://devfeed.tech/tags/go.md>), [go-test](<https://devfeed.tech/tags/go-test.md>), [integration](<https://devfeed.tech/tags/integration.md>), [programming](<https://devfeed.tech/tags/programming.md>), [retry](<https://devfeed.tech/tags/retry.md>), [standard-library](<https://devfeed.tech/tags/standard-library.md>), [streaming](<https://devfeed.tech/tags/streaming.md>), [testing](<https://devfeed.tech/tags/testing.md>), [unit-test](<https://devfeed.tech/tags/unit-test.md>), [unit-testing](<https://devfeed.tech/tags/unit-testing.md>)

### AI overview

The article explains that Go 1.14 streams test output as it is produced when using -v, instead of buffering output until the test finishes. This improves visibility when debugging long-running or retrying integration tests.

### Source excerpt

The testing package is one of my favourite packages in the Go standard library, not just because of its low noise approach to unit testing, but, over the lifetime of Go, it has received a steady stream of quality of life improvements driven by real world usage. The most recent example of this is, in [...]

## Write Your Go Programs Using GEdit

DevFeed: [Write Your Go Programs Using GEdit](<https://devfeed.tech/articles/write-your-go-programs-using-gedit-22085.md>)

Original publisher: [Read original article](<https://www.ardanlabs.com/blog/2013/11/write-your-go-programs-using-gedit.html>)

Published: 2013-11-23T00:00:00Z

Content type: tutorial

Language: en

Sources: [William Kennedy](<https://devfeed.tech/sources/william-kennedy.md>)

Topics: [Go Language](<https://devfeed.tech/topics/go-language.md>), [Development](<https://devfeed.tech/topics/development.md>), [Tooling](<https://devfeed.tech/topics/tooling.md>), [Python](<https://devfeed.tech/topics/python.md>), [Linux](<https://devfeed.tech/topics/linux.md>)

Tags: [ardan-labs](<https://devfeed.tech/tags/ardan-labs.md>), [blog](<https://devfeed.tech/tags/blog.md>), [build](<https://devfeed.tech/tags/build.md>), [go](<https://devfeed.tech/tags/go.md>), [go-development](<https://devfeed.tech/tags/go-development.md>), [go-programming](<https://devfeed.tech/tags/go-programming.md>), [go-test](<https://devfeed.tech/tags/go-test.md>), [golang](<https://devfeed.tech/tags/golang.md>), [linux](<https://devfeed.tech/tags/linux.md>), [programming](<https://devfeed.tech/tags/programming.md>), [python](<https://devfeed.tech/tags/python.md>), [tooling](<https://devfeed.tech/tags/tooling.md>), [ubuntu](<https://devfeed.tech/tags/ubuntu.md>)

### AI overview

This guest post describes using GEdit for Go development and introduces GoBuild, a Python plug-in for GEdit 3.x that runs go build when Go source files are saved and runs go test for test files.

### Source excerpt

This is a guest post from Tad Vizbaras from Etasoft in South Florida. There are a number of editors and IDEs for Go development. LiteIde, Vim, Emacs and GEdit just to name a few. Each developer has their own favorite editor for each language they work with. Some like full featured IDE environments while others prefer speed over features. My personal favorite editors for Go development at the moment are Vim and GEdit. GEdit comes as part of many Linux distros. If you use Ubuntu, it is part of the operating system. GEdit has some decent features like: * Syntax Highlighting * Split Windows * Word Wrapping Advanced features are left to be handled by external plug-ins. I prefer project-less development. That means there are no formal project files and projects are preserved via a workspace bound to a directory structure. Go has excellent support for project-less development. When building and installing your projects, the Go tooling, in conjunction with the way Go packages code, can minimize the need for external scripts and makefiles. GEdit is a decent editor but I could not find any good Plug-ins that would allow me to perform a Go build right from the editor. The "External Tools" Plug-in has worked for me. I was able to set up shortcuts and get "go build" to execute. When you click on errors, displayed in the bottom pane of GEdit, the cursor jumps to exact error location. When I started programming in Go, the "External Tools" Plug-in worked for me for quite some time. But after awhile, I started to wish that "go build" would run similar to how Linters ran. With Linters, you can run a command after the file is saved. Since Go usually takes only few seconds to build, the Plug-in could execute a "go build" on save and then jump to the error location if there were any. I wrote a GEdit Plug-in that is developed in Python. Depending on the version of Python you have installed, you may require some small adjustments. This is covered in the Known Issues section below. Ops, I