Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address non-Close errors identified by errcheck #107

Merged
merged 3 commits into from
May 26, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix errcheck errors in probe
  • Loading branch information
peterbourgon committed May 26, 2015
commit 8f6b9895acb6cd1567149ded1f4cb898171f84ab
2 changes: 1 addition & 1 deletion probe/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func main() {
log.Printf("exposing Prometheus endpoint at %s%s", *httpListen, *prometheusEndpoint)
http.Handle(*prometheusEndpoint, makePrometheusHandler())
}
go http.ListenAndServe(*httpListen, nil)
go func(err error) { log.Print(err) }(http.ListenAndServe(*httpListen, nil))
}

if *spyProcs && os.Getegid() != 0 {
Expand Down
12 changes: 9 additions & 3 deletions probe/process_mapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestCgroupMapper(t *testing.T) {
"/netscape/notify_on_release": "0\n",
"/weirdfile": "",
})
defer os.RemoveAll(tmp)
defer removeAll(t, tmp)

m := newCgroupMapper(tmp, 1*time.Second)
for pid, want := range map[uint]string{
Expand All @@ -44,14 +44,20 @@ func setupTmpFS(t *testing.T, fs map[string]string) string {
for file, content := range fs {
dir := path.Dir(file)
if err := os.MkdirAll(filepath.Join(tmp, dir), 0777); err != nil {
os.RemoveAll(tmp)
removeAll(t, tmp)
t.Fatalf("MkdirAll: %v", err)
}

if err := ioutil.WriteFile(filepath.Join(tmp, file), []byte(content), 0655); err != nil {
os.RemoveAll(tmp)
removeAll(t, tmp)
t.Fatalf("WriteFile: %v", err)
}
}
return tmp
}

func removeAll(t *testing.T, path string) {
if err := os.RemoveAll(path); err != nil {
t.Error(err)
}
}