soh335/go-dnssd — pull request #3 by dapplebeforedawn (2014-02-01 18:18:01+00:00)
Title: Fix TXT Records Key Strings

The way TXT records keys are converted back into golang strings causes them to have too-long lengths, and they no longer == the original golang strings.

## Example:
`examples/test.go` has been modified like this:
```golang
func main() {
println("-----------------------")
print("real key length: ")
println(len("path"))
println("-----------------------")

ctx, err := RegisterService()
if err != nil{
panic(err)
}
defer ctx.Release()
Discover()
}

func Discover() {
//...

resolveReply, _ := <-rc
fmt.Println(resolveReply)

println("-----------------------")
print("after dnssd key length: ")
for key, _ := range resolveReply.TxtRecordMap {
println(len(key))
print("the string comparison works: ")
println(key == "path")
}
println("-----------------------")

//...
}
}
```

The current code outputs:
```golang
markjlorenz@BabyGoat:go-dnssd(master *|2403m) → go run example/test.go
-----------------------
real key length: 4
-----------------------
Register Reply: &{My Server _http._tcp. local.}
&{5 My Server _http._tcp. local.}
start resolve
&{5 My\032Server._http._tcp.local. BabyGoat.local. 3000 map[path:/path-to-page.html]}
-----------------------
after dnssd key length: 24
the string comparison works: false
-----------------------
&{5 My\032Server._http._tcp.local. 33 1 22 [0 0 0 0 184 11 8 66 97 98 121 71 111 97 116 5 108 111 99 97 108 0] 120}
&{0 0 47115 BabyGoat.local.}
&{5 BabyGoat.local. 10.0.1.5 120}
closed
```

With the code in the pull request:
```golang
markjlorenz@BabyGoat:go-dnssd(master *|2403m) → go run example/test.go
-----------------------
real key length: 4
-----------------------
Register Reply: &{My Server _http._tcp. local.}
&{5 My Server _http._tcp. local.}
start resolve
&{5 My\032Server._http._tcp.local. BabyGoat.local. 3000 map[path:/path-to-page.html]}
-----------------------
after dnssd key length: 4
the string comparison works: true
-----------------------
&{5 My\032Server._http._tcp.local. 33 1 22 [0 0 0 0 184 11 8 66 97 98 121 71 111 97 116 5 108 111 99 97 108 0] 120}
&{0 0 47115 BabyGoat.local.}
&{5 BabyGoat.local. 10.0.1.5 120}
closed
```

----
There's also a small change to the example file. We should check for errors _before_ `dnssd.Process(ctx)`