github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/cli/cli-plugins/manager/suffix_windows.go (about)

     1  package manager
     2  
     3  import (
     4  	"path/filepath"
     5  	"strings"
     6  
     7  	"github.com/pkg/errors"
     8  )
     9  
    10  // This is made slightly more complex due to needing to be case insensitive.
    11  func trimExeSuffix(s string) (string, error) {
    12  	ext := filepath.Ext(s)
    13  	if ext == "" {
    14  		return "", errors.Errorf("path %q lacks required file extension", s)
    15  	}
    16  
    17  	exe := ".exe"
    18  	if !strings.EqualFold(ext, exe) {
    19  		return "", errors.Errorf("path %q lacks required %q suffix", s, exe)
    20  	}
    21  	return strings.TrimSuffix(s, ext), nil
    22  }
    23  
    24  func addExeSuffix(s string) string {
    25  	return s + ".exe"
    26  }