Go测试中的单元测试之间是否可以有共享的上下文?

I am implementing a trie in Go as a way of learning the language. I want to write tests from the get go as a way of getting a feel for Go's approach to things.

One problem I am having when testing my trie is that I have to rebuild it for every unit test. Is there a way to reuse the same instantiation of my trie across unit tests? Ideally, I'd like a way to do this without any external dependencies.

Yes: Just construct it in func init() in your trie_test.go. (Or even use a literal.)

If you don't mind the extra dependency, the gocheck package provides the ability to group tests into suites. You can then define SetUpSuite and TearDownSuite methods to perform initialisation and tear down of any resources shared by the tests in that suite.