From 8b30110ec35e1a3d9a4e0f68444dbaa25fca973d Mon Sep 17 00:00:00 2001 From: Sven Greb Date: Sat, 24 Apr 2021 21:03:13 +0200 Subject: [PATCH] Remove `ExecName` method from `Exec` interface again (#88) In GH-79 [1] a new `ExecName() string` method has been added to the `Exec` interface [2] to improve the way how `RunnerExec` [3] handles the name of the executable file, but it turned out that this is not useful at all and also broke the separation of concern between the `Task` and `Runner` interfaces. Therefore the method has been removed again. [1]: https://github.com/svengreb/wand/issues/79 [2]: https://pkg.go.dev/github.com/svengreb/wand/pkg/task#Exec [3]: https://pkg.go.dev/github.com/svengreb/wand/pkg/task#RunnerExec Closes GH-87 --- pkg/task/gofumpt/gofumpt.go | 7 +------ pkg/task/gofumpt/options.go | 16 +--------------- pkg/task/goimports/goimports.go | 5 ----- pkg/task/goimports/options.go | 16 +--------------- pkg/task/golangcilint/golangcilint.go | 5 ----- pkg/task/golangcilint/options.go | 16 +--------------- pkg/task/gox/gox.go | 5 ----- pkg/task/gox/options.go | 16 +--------------- pkg/task/task.go | 3 --- 9 files changed, 5 insertions(+), 84 deletions(-) diff --git a/pkg/task/gofumpt/gofumpt.go b/pkg/task/gofumpt/gofumpt.go index fda85ad..5dc7b2d 100644 --- a/pkg/task/gofumpt/gofumpt.go +++ b/pkg/task/gofumpt/gofumpt.go @@ -77,11 +77,6 @@ func (t *Task) Env() map[string]string { return t.opts.env } -// ExecName returns the executable name. -func (t *Task) ExecName() string { - return t.opts.execName -} - // ID returns the identifier of the Go module. func (t *Task) ID() *project.GoModuleID { return t.opts.goModule @@ -94,7 +89,7 @@ func (t *Task) Kind() task.Kind { // Name returns the task name. func (t *Task) Name() string { - return t.opts.execName + return t.opts.name } // Options returns the task options. diff --git a/pkg/task/gofumpt/options.go b/pkg/task/gofumpt/options.go index 73c406c..be5a30f 100644 --- a/pkg/task/gofumpt/options.go +++ b/pkg/task/gofumpt/options.go @@ -13,9 +13,6 @@ import ( ) const ( - // DefaultExecName is the default name of the module executable. - DefaultExecName = "gofumpt" - // DefaultGoModulePath is the default module import path. DefaultGoModulePath = "mvdan.cc/gofumpt" @@ -34,9 +31,6 @@ type Options struct { // env is the task specific environment. env map[string]string - // execName is the unique executable name. - execName string - // extraArgs are additional arguments passed to the command. extraArgs []string @@ -79,8 +73,7 @@ func NewOptions(opts ...Option) (*Options, error) { } opt := &Options{ - env: make(map[string]string), - execName: DefaultExecName, + env: make(map[string]string), goModule: &project.GoModuleID{ Path: DefaultGoModulePath, Version: version, @@ -101,13 +94,6 @@ func WithEnv(env map[string]string) Option { } } -// WithExecName sets the name of the executable. -func WithExecName(execName string) Option { - return func(o *Options) { - o.execName = execName - } -} - // WithExtraArgs sets additional arguments to pass to the command. func WithExtraArgs(extraArgs ...string) Option { return func(o *Options) { diff --git a/pkg/task/goimports/goimports.go b/pkg/task/goimports/goimports.go index 366a8c1..df51f74 100644 --- a/pkg/task/goimports/goimports.go +++ b/pkg/task/goimports/goimports.go @@ -75,11 +75,6 @@ func (t *Task) Env() map[string]string { return t.opts.env } -// ExecName returns the executable name. -func (t *Task) ExecName() string { - return t.opts.execName -} - // ID returns the identifier of the Go module. func (t *Task) ID() *project.GoModuleID { return t.opts.goModule diff --git a/pkg/task/goimports/options.go b/pkg/task/goimports/options.go index c2620cd..dca9abd 100644 --- a/pkg/task/goimports/options.go +++ b/pkg/task/goimports/options.go @@ -13,9 +13,6 @@ import ( ) const ( - // DefaultExecName is the default name of the module executable. - DefaultExecName = "goimports" - // DefaultGoModulePath is the default module import path. DefaultGoModulePath = "golang.org/x/tools/cmd/goimports" @@ -34,9 +31,6 @@ type Options struct { // env is the task specific environment. env map[string]string - // execName is the unique executable name. - execName string - // extraArgs are additional arguments passed to the command. extraArgs []string @@ -78,8 +72,7 @@ func NewOptions(opts ...Option) (*Options, error) { } opt := &Options{ - env: make(map[string]string), - execName: DefaultExecName, + env: make(map[string]string), goModule: &project.GoModuleID{ Path: DefaultGoModulePath, Version: version, @@ -100,13 +93,6 @@ func WithEnv(env map[string]string) Option { } } -// WithExecName sets the name of the executable. -func WithExecName(execName string) Option { - return func(o *Options) { - o.execName = execName - } -} - // WithExtraArgs sets additional arguments to pass to the command. func WithExtraArgs(extraArgs ...string) Option { return func(o *Options) { diff --git a/pkg/task/golangcilint/golangcilint.go b/pkg/task/golangcilint/golangcilint.go index 67eb738..60c38cc 100644 --- a/pkg/task/golangcilint/golangcilint.go +++ b/pkg/task/golangcilint/golangcilint.go @@ -32,11 +32,6 @@ func (t *Task) Env() map[string]string { return t.opts.env } -// ExecName returns the executable name. -func (t *Task) ExecName() string { - return t.opts.execName -} - // ID returns the identifier of the Go module. func (t *Task) ID() *project.GoModuleID { return t.opts.goModule diff --git a/pkg/task/golangcilint/options.go b/pkg/task/golangcilint/options.go index de61fef..929ff86 100644 --- a/pkg/task/golangcilint/options.go +++ b/pkg/task/golangcilint/options.go @@ -13,9 +13,6 @@ import ( ) const ( - // DefaultExecName is the default name of the module executable. - DefaultExecName = "golangci-lint" - // DefaultGoModulePath is the default module import path. DefaultGoModulePath = "github.com/golangci/golangci-lint/cmd/golangci-lint" @@ -40,9 +37,6 @@ type Options struct { // env is the task specific environment. env map[string]string - // execName is the unique executable name. - execName string - // goModule is the Go module identifier. goModule *project.GoModuleID @@ -64,8 +58,7 @@ func NewOptions(opts ...Option) (*Options, error) { } opt := &Options{ - env: make(map[string]string), - execName: DefaultExecName, + env: make(map[string]string), goModule: &project.GoModuleID{ Path: DefaultGoModulePath, Version: version, @@ -98,13 +91,6 @@ func WithEnv(env map[string]string) Option { } } -// WithExecName sets the name of the executable. -func WithExecName(execName string) Option { - return func(o *Options) { - o.execName = execName - } -} - // WithModulePath sets the module import path. // Defaults to DefaultGoModulePath. func WithModulePath(path string) Option { diff --git a/pkg/task/gox/gox.go b/pkg/task/gox/gox.go index 24fd024..9aa959e 100644 --- a/pkg/task/gox/gox.go +++ b/pkg/task/gox/gox.go @@ -71,11 +71,6 @@ func (t *Task) Env() map[string]string { return t.opts.env } -// ExecName returns the executable name. -func (t *Task) ExecName() string { - return t.opts.execName -} - // ID returns the identifier of the Go module. func (t *Task) ID() *project.GoModuleID { return t.opts.goModule diff --git a/pkg/task/gox/options.go b/pkg/task/gox/options.go index a657b86..7f52752 100644 --- a/pkg/task/gox/options.go +++ b/pkg/task/gox/options.go @@ -15,9 +15,6 @@ import ( ) const ( - // DefaultExecName is the default name of the module executable. - DefaultExecName = "gox" - // DefaultGoModulePath is the default module import path. DefaultGoModulePath = "github.com/mitchellh/gox" @@ -55,9 +52,6 @@ type Options struct { // env is the task specific environment. env map[string]string - // execName is the unique executable name. - execName string - // goCmd is the path to the Go toolchain executable. goCmd string @@ -91,8 +85,7 @@ func NewOptions(opts ...Option) (*Options, error) { } opt := &Options{ - env: make(map[string]string), - execName: DefaultExecName, + env: make(map[string]string), goModule: &project.GoModuleID{ Path: DefaultGoModulePath, Version: version, @@ -127,13 +120,6 @@ func WithEnv(env map[string]string) Option { } } -// WithExecName sets the name of the executable. -func WithExecName(execName string) Option { - return func(o *Options) { - o.execName = execName - } -} - // WithGoBuildOptions sets Go toolchain "build" command task options. func WithGoBuildOptions(goBuildOpts ...taskGoBuild.Option) Option { return func(o *Options) { diff --git a/pkg/task/task.go b/pkg/task/task.go index 0ea5fca..04e95b8 100644 --- a/pkg/task/task.go +++ b/pkg/task/task.go @@ -24,9 +24,6 @@ type Exec interface { // Env returns the task specific environment. Env() map[string]string - - // ExecName returns the executable name. - ExecName() string } // GoModule is a task for a Go module command.