mirror of
https://github.com/restic/restic.git
synced 2026-08-05 21:33:16 +00:00
Apply go fix -any ./...
This commit is contained in:
@@ -16,7 +16,7 @@ type Options map[string]string
|
||||
var opts []Help
|
||||
|
||||
// Register allows registering options so that they can be listed with List.
|
||||
func Register(ns string, cfg interface{}) {
|
||||
func Register(ns string, cfg any) {
|
||||
opts = appendAllOptions(opts, ns, cfg)
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ func List() (list []Help) {
|
||||
}
|
||||
|
||||
// appendAllOptions appends all options in cfg to opts, sorted by namespace.
|
||||
func appendAllOptions(opts []Help, ns string, cfg interface{}) []Help {
|
||||
func appendAllOptions(opts []Help, ns string, cfg any) []Help {
|
||||
for _, opt := range listOptions(cfg) {
|
||||
opt.Namespace = ns
|
||||
opts = append(opts, opt)
|
||||
@@ -39,7 +39,7 @@ func appendAllOptions(opts []Help, ns string, cfg interface{}) []Help {
|
||||
}
|
||||
|
||||
// listOptions returns a list of options of cfg.
|
||||
func listOptions(cfg interface{}) (opts []Help) {
|
||||
func listOptions(cfg any) (opts []Help) {
|
||||
// resolve indirection if cfg is a pointer
|
||||
v := reflect.Indirect(reflect.ValueOf(cfg))
|
||||
|
||||
@@ -145,7 +145,7 @@ func (o Options) Extract(ns string) Options {
|
||||
|
||||
// Apply sets the options on dst via reflection, using the struct tag `option`.
|
||||
// The namespace argument (ns) is only used for error messages.
|
||||
func (o Options) Apply(ns string, dst interface{}) error {
|
||||
func (o Options) Apply(ns string, dst any) error {
|
||||
v := reflect.ValueOf(dst).Elem()
|
||||
|
||||
fields := make(map[string]reflect.StructField)
|
||||
|
||||
@@ -247,7 +247,7 @@ func TestListOptions(t *testing.T) {
|
||||
}{}
|
||||
|
||||
tests := []struct {
|
||||
cfg interface{}
|
||||
cfg any
|
||||
opts []Help
|
||||
}{
|
||||
{
|
||||
@@ -298,11 +298,11 @@ func TestListOptions(t *testing.T) {
|
||||
|
||||
func TestAppendAllOptions(t *testing.T) {
|
||||
tests := []struct {
|
||||
cfgs map[string]interface{}
|
||||
cfgs map[string]any
|
||||
opts []Help
|
||||
}{
|
||||
{
|
||||
map[string]interface{}{
|
||||
map[string]any{
|
||||
"local": struct {
|
||||
Foo string `option:"foo" help:"bar text help"`
|
||||
}{},
|
||||
|
||||
Reference in New Issue
Block a user