Skip to content

Commit dac7319

Browse files
authored
Merge pull request #5495 from thaJeztah/opts_remove_ErrBadKey
opts: remove ErrBadKey as it's not used as a sentinel error
2 parents 7c85db6 + 95e221e commit dac7319

1 file changed

Lines changed: 2 additions & 11 deletions

File tree

opts/file.go

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,6 @@ import (
1212

1313
const whiteSpaces = " \t"
1414

15-
// ErrBadKey typed error for bad environment variable
16-
type ErrBadKey struct {
17-
msg string
18-
}
19-
20-
func (e ErrBadKey) Error() string {
21-
return "poorly formatted environment: " + e.msg
22-
}
23-
2415
func parseKeyValueFile(filename string, emptyFn func(string) (string, bool)) ([]string, error) {
2516
fh, err := os.Open(filename)
2617
if err != nil {
@@ -51,10 +42,10 @@ func parseKeyValueFile(filename string, emptyFn func(string) (string, bool)) ([]
5142
// trim the front of a variable, but nothing else
5243
variable = strings.TrimLeft(variable, whiteSpaces)
5344
if strings.ContainsAny(variable, whiteSpaces) {
54-
return []string{}, ErrBadKey{fmt.Sprintf("variable '%s' contains whitespaces", variable)}
45+
return []string{}, fmt.Errorf("variable '%s' contains whitespaces", variable)
5546
}
5647
if len(variable) == 0 {
57-
return []string{}, ErrBadKey{fmt.Sprintf("no variable name on line '%s'", line)}
48+
return []string{}, fmt.Errorf("no variable name on line '%s'", line)
5849
}
5950

6051
if hasValue {

0 commit comments

Comments
 (0)