Pure-go library for cross-platform thread-safe local peer discovery using UDP multicast. I needed to use peer discovery for croc and everything I tried had problems, so I made another one.
Make sure you have Go 1.5+.
go get -u github.com/schollz/peerdiscovery
The following is a code to find the first peer on the local network and print it out.
discoveries, _ := peerdiscovery.Discover(peerdiscovery.Settings{Limit: 1})
for _, d := range discoveries {
fmt.Printf("discovered '%s'\n", d.Address)
}
Here's the output when running on two computers. (Run these gifs in sync by hitting Ctl + F5).
Computer 1:
Computer 2:
For more examples, see the scanning example or the docs.
Pull requests are welcome. Feel free to...
- Revise documentation
- Add new features
- Fix bugs
- Suggest improvements
MIT