forked from libp2p/zeroconf
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
57 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package zeroconf | ||
|
||
import "fmt" | ||
|
||
func ExampleNewType() { | ||
ty := NewType("_chat._tcp") | ||
fmt.Println(ty) | ||
// Output: _chat._tcp.local | ||
} | ||
|
||
func ExampleNewType_custom() { | ||
// Provides a custom domain and two subtypes (not recommended) | ||
ty := NewType("_foo._udp.custom.domain,_sub1,_sub2") | ||
fmt.Println(ty) | ||
fmt.Println(ty.Subtypes) | ||
|
||
// Output: | ||
// _foo._udp.custom.domain | ||
// [_sub1 _sub2] | ||
} | ||
|
||
func ExampleNewService() { | ||
ty := NewType("_chat._tcp") | ||
svc := NewService(ty, "bobs-laptop", 12345) | ||
fmt.Println(svc) | ||
|
||
// Output: | ||
// bobs-laptop._chat._tcp.local | ||
} |