docs(README): modify readme
This commit is contained in:
parent
d6ad8896de
commit
c7b4679a01
14
README.md
14
README.md
|
@ -73,9 +73,19 @@ m1.Protocols()
|
||||||
#### En/decapsulate
|
#### En/decapsulate
|
||||||
|
|
||||||
```go
|
```go
|
||||||
m.Encapsulate(ma.NewMultiaddr("/sctp/5678"))
|
import ma "github.com/multiformats/go-multiaddr"
|
||||||
|
|
||||||
|
m, err := ma.NewMultiaddr("/ip4/127.0.0.1/udp/1234")
|
||||||
|
// <Multiaddr /ip4/127.0.0.1/udp/1234>
|
||||||
|
|
||||||
|
sctpMA, err := ma.NewMultiaddr("/sctp/5678")
|
||||||
|
|
||||||
|
m.Encapsulate(sctpMA)
|
||||||
// <Multiaddr /ip4/127.0.0.1/udp/1234/sctp/5678>
|
// <Multiaddr /ip4/127.0.0.1/udp/1234/sctp/5678>
|
||||||
m.Decapsulate(ma.NewMultiaddr("/udp")) // up to + inc last occurrence of subaddr
|
|
||||||
|
udpMA, err := ma.NewMultiaddr("/udp/1234")
|
||||||
|
|
||||||
|
m.Decapsulate(udpMA) // up to + inc last occurrence of subaddr
|
||||||
// <Multiaddr /ip4/127.0.0.1>
|
// <Multiaddr /ip4/127.0.0.1>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue