If you use this function in *_test.go
file throughout the project it's a good idea to move it to a utils package and import this package in your *_test.go
. Moreover since this util package is used only for testing purposes I suggest to save the output of the internal function of pkg1
in a support file and load it when you call the support package's function which should use the private function of pkg1
.