google / google/styleguide

[Go] advice about testing/synctest

Open
#870 0 comments 0 reactions 0 assignees View on GitHub
lang:go
Dominant language
HTML
Stars
39.6k
Forks
12.9k
Avg merge
42m
Merged PRs (30d)
15

Description

Reference: https://github.com/golang/go/issues/67434

In the cases where it is necessary for testing, historically (inside Google) gophers have been advised to pass around values such as `func() time.Time`, or some similar fake-able clock, instead of calling `time.Now()`. With synctest it seems like a new strategy is to simply rely on the new primitives rather than bothering with that plumbing.

Does the Google Go style guide have an opinion on this?

(@matttproud @gaal)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.