summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEyal Posener <[email protected]>2018-09-10 11:07:58 +0300
committerGitHub <[email protected]>2018-09-10 11:07:58 +0300
commit0d98d7ee195f007b3453c002780ed80c76e7c806 (patch)
tree1d2acfc7e9f4a028a0e05aebaf71e7ad1dde77e9
parentc43123851dc34b5c712ef0298118ae2da47e1365 (diff)
parent6db5f134c9885f9dcecf30c4ffba42bd182ccb58 (diff)
Merge pull request #70 from posener/lint
fix lint issues
-rw-r--r--cmd/install/fish.go18
-rw-r--r--cmd/install/install.go2
-rw-r--r--cmd/install/utils.go5
3 files changed, 17 insertions, 8 deletions
diff --git a/cmd/install/fish.go b/cmd/install/fish.go
index 6b588db..6467196 100644
--- a/cmd/install/fish.go
+++ b/cmd/install/fish.go
@@ -16,7 +16,10 @@ type fish struct {
func (f fish) Install(cmd, bin string) error {
completionFile := filepath.Join(f.configDir, "completions", fmt.Sprintf("%s.fish", cmd))
- completeCmd := f.cmd(cmd, bin)
+ completeCmd, err := f.cmd(cmd, bin)
+ if err != nil {
+ return err
+ }
if _, err := os.Stat(completionFile); err == nil {
return fmt.Errorf("already installed at %s", completionFile)
}
@@ -33,10 +36,10 @@ func (f fish) Uninstall(cmd, bin string) error {
return os.Remove(completionFile)
}
-func (f fish) cmd(cmd, bin string) string {
+func (f fish) cmd(cmd, bin string) (string, error) {
var buf bytes.Buffer
params := struct{ Cmd, Bin string }{cmd, bin}
- template.Must(template.New("cmd").Parse(`
+ tmpl := template.Must(template.New("cmd").Parse(`
function __complete_{{.Cmd}}
set -lx COMP_LINE (string join ' ' (commandline -o))
test (commandline -ct) = ""
@@ -44,7 +47,10 @@ function __complete_{{.Cmd}}
{{.Bin}}
end
complete -c {{.Cmd}} -a "(__complete_{{.Cmd}})"
-`)).Execute(&buf, params)
-
- return buf.String()
+`))
+ err := tmpl.Execute(&buf, params)
+ if err != nil {
+ return "", err
+ }
+ return buf.String(), nil
}
diff --git a/cmd/install/install.go b/cmd/install/install.go
index 4a70624..dfa1963 100644
--- a/cmd/install/install.go
+++ b/cmd/install/install.go
@@ -51,7 +51,7 @@ func Uninstall(cmd string) error {
for _, i := range is {
errI := i.Uninstall(cmd, bin)
if errI != nil {
- multierror.Append(err, errI)
+ err = multierror.Append(err, errI)
}
}
diff --git a/cmd/install/utils.go b/cmd/install/utils.go
index bb709bc..d34ac8c 100644
--- a/cmd/install/utils.go
+++ b/cmd/install/utils.go
@@ -115,7 +115,10 @@ func removeContentToTempFile(name, content string) (string, error) {
if str == content {
continue
}
- wf.WriteString(str + "\n")
+ _, err = wf.WriteString(str + "\n")
+ if err != nil {
+ return "", err
+ }
prefix = prefix[:0]
}
return wf.Name(), nil