sampleconfig: Use embed with external files. #3185
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This updates the
sampleconfig
package to make use of Go's embed functionality introduced in Go 1.16 which is acceptable since the containing module requires Go 1.19.Embedded files are preferable because they bring the benefits of both external files in the repository that are easier to work with for external tools and the ability to access their content programmatically without having to deal with the various issues typically brought about by programmatically accessing external files.
Also, when this was last updated to change the exported variable for
dcrd
's sample config file over to a function (so it can't be mutated and the implementation details can be changed if needed), the case fordcrctl
was missed. Moreover, the existence of both configs makes the func nameFileContents
ambiguous.Unfortunately, those things can't be changed now without causing a major module version bump to the main
dcrd
module which we really want to avoid.So, in order to address those things without needing a major module version bump, this deprecates the
FileContents
func andDcrctlSampleConfig
variable and introduces two new functions namedDcrd
andDcrctl
that return the respective embedded sample configs.