# HG changeset patch # User Chris Jones # Date 1325104331 25200 # Node ID 7437d6eed2279443f274858a04be6fb5145a6fdf # Parent fff79efe06f6b0affa207939455ecdd555a3f190 Made JID.Node a string rather than *string. This is more appropriate and idiomatic Go. diff -r fff79efe06f6 -r 7437d6eed227 stream.go --- a/stream.go Wed Dec 28 13:28:45 2011 -0700 +++ b/stream.go Wed Dec 28 13:32:11 2011 -0700 @@ -383,10 +383,10 @@ // Begin building the response. Username is // user@domain or just domain. var username string - if cl.Jid.Node == nil { + if cl.Jid.Node == "" { username = cl.Jid.Domain } else { - username = *cl.Jid.Node + username = cl.Jid.Node } // Generate our own nonce from random data. diff -r fff79efe06f6 -r 7437d6eed227 structs.go --- a/structs.go Wed Dec 28 13:28:45 2011 -0700 +++ b/structs.go Wed Dec 28 13:32:11 2011 -0700 @@ -21,8 +21,7 @@ // entities. It looks like node@domain/resource. Node and resource are // sometimes optional. type JID struct { - // BUG(cjyar) Make this not a pointer. - Node *string + Node string Domain string Resource string } @@ -156,8 +155,8 @@ func (jid *JID) String() string { result := jid.Domain - if jid.Node != nil { - result = *jid.Node + "@" + result + if jid.Node != "" { + result = jid.Node + "@" + result } if jid.Resource != "" { result = result + "/" + jid.Resource @@ -171,11 +170,7 @@ if parts == nil { return false } - if parts[2] == "" { - jid.Node = nil - } else { - jid.Node = &parts[2] - } + jid.Node = parts[2] jid.Domain = parts[3] jid.Resource = parts[5] return true diff -r fff79efe06f6 -r 7437d6eed227 structs_test.go --- a/structs_test.go Wed Dec 28 13:28:45 2011 -0700 +++ b/structs_test.go Wed Dec 28 13:32:11 2011 -0700 @@ -23,7 +23,7 @@ if !jid.Set(str) { t.Errorf("Set(%s) failed\n", str) } - assertEquals(t, "user", *jid.Node) + assertEquals(t, "user", jid.Node) assertEquals(t, "domain", jid.Domain) assertEquals(t, "res", jid.Resource) assertEquals(t, str, jid.String()) @@ -32,8 +32,8 @@ if !jid.Set(str) { t.Errorf("Set(%s) failed\n", str) } - if jid.Node != nil { - t.Errorf("Node: %v\n", *jid.Node) + if jid.Node != "" { + t.Errorf("Node: %v\n", jid.Node) } assertEquals(t, "domain.tld", jid.Domain) if jid.Resource != "" {