Skip to content

Commit

Permalink
Add executable check to doctor command
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Aug 18, 2021
1 parent 518cac6 commit 461ea4a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions internal/cmd/doctorcmd.go
Expand Up @@ -67,6 +67,9 @@ type dirCheck struct {
dirname string
}

// An executableCheck checks the executable.
type executableCheck struct{}

// A fileCheck checks that a file exists.
type fileCheck struct {
name string
Expand Down Expand Up @@ -116,6 +119,7 @@ func (c *Config) runDoctorCmd(cmd *cobra.Command, args []string) error {
versionStr: c.versionStr,
},
&osArchCheck{},
&executableCheck{},
&fileCheck{
name: "config-file",
filename: string(c.configFileAbsPath),
Expand Down Expand Up @@ -319,6 +323,18 @@ func (c *dirCheck) Run() (checkResult, string) {
return checkOK, fmt.Sprintf("%s is a directory", c.dirname)
}

func (c *executableCheck) Name() string {
return "executable"
}

func (c *executableCheck) Run() (checkResult, string) {
executable, err := os.Executable()
if err != nil {
return checkError, err.Error()
}
return checkOK, executable
}

func (c *fileCheck) Name() string {
return c.name
}
Expand Down

0 comments on commit 461ea4a

Please sign in to comment.