1
0
mirror of https://github.com/golang/go synced 2024-11-21 22:04:39 -07:00

os: change Waitmsg String method to use pointer receiver

Fixes #1851.

R=rsc
CC=golang-dev
https://golang.org/cl/4628045
This commit is contained in:
Graham Miller 2011-06-20 15:42:17 -04:00 committed by Russ Cox
parent c2784340a7
commit cf201ed6a0
3 changed files with 16 additions and 2 deletions

View File

@ -123,6 +123,9 @@ func FindProcess(pid int) (p *Process, err Error) {
return newProcess(pid, 0), nil
}
func (w Waitmsg) String() string {
func (w *Waitmsg) String() string {
if w == nil {
return "<nil>"
}
return "exit status: " + w.Msg
}

View File

@ -128,7 +128,10 @@ func itod(i int) string {
return string(b[bp:])
}
func (w Waitmsg) String() string {
func (w *Waitmsg) String() string {
if w == nil {
return "<nil>"
}
// TODO(austin) Use signal names when possible?
res := ""
switch {

View File

@ -1042,3 +1042,11 @@ func TestStatDirWithTrailingSlash(t *testing.T) {
t.Fatal("stat failed:", err)
}
}
func TestNilWaitmsgString(t *testing.T) {
var w *Waitmsg
s := w.String()
if s != "<nil>" {
t.Errorf("(*Waitmsg)(nil).String() = %q, want %q", s, "<nil>")
}
}