package manager

import (
	"strings"

	"github.com/pkg/errors"
)

func trimExeSuffix(s string) (string, error) {
	exe := ".exe"
	if !strings.HasSuffix(s, exe) {
		return "", errors.Errorf("lacks required %q suffix", exe)
	}
	return strings.TrimSuffix(s, exe), nil
}

func addExeSuffix(s string) string {
	return s + ".exe"
}

package manager

import (
	"path/filepath"
	"strings"

	"github.com/pkg/errors"
)

// This is made slightly more complex due to needing to be case insensitive.
func trimExeSuffix(s string) (string, error) {
	ext := filepath.Ext(s)
	if ext == "" {
		return "", errors.Errorf("path %q lacks required file extension", s)
	}

	exe := ".exe"
	if !strings.EqualFold(ext, exe) {
		return "", errors.Errorf("path %q lacks required %q suffix", s, exe)
	}
	return strings.TrimSuffix(s, ext), nil
}

func addExeSuffix(s string) string {
	return s + ".exe"
}

Check for `.exe` case insensitively
Check for `.exe` case insensitively

On Windows `foo.exe`, `foo.eXe` and `foo.EXE` are equally executable.

Signed-off-by: Ian Campbell <a8db091655a7f47ecb9c39a2d278e9662e440dc0@docker.com>
