forked from TrueCloudLab/multinet
[#3] dialer: Add gopatch
s patch.
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
ee601a7b5f
commit
76e736f572
5 changed files with 52 additions and 1 deletions
3
Makefile
3
Makefile
|
@ -4,3 +4,6 @@ integration-test:
|
||||||
|
|
||||||
test:
|
test:
|
||||||
go test -count=1 -v ./...
|
go test -count=1 -v ./...
|
||||||
|
|
||||||
|
patch-example:
|
||||||
|
gopatch -d -p ./multinet.patch ./testdata/patch*
|
10
README.md
10
README.md
|
@ -38,4 +38,12 @@ if err != nil {
|
||||||
`Multidialer` exposes `UpdateInterface()` method for updating state of a single link.
|
`Multidialer` exposes `UpdateInterface()` method for updating state of a single link.
|
||||||
`NetlinkWatcher` can wrap `Multidialer` type and perform all updates automatically.
|
`NetlinkWatcher` can wrap `Multidialer` type and perform all updates automatically.
|
||||||
|
|
||||||
TODO: describe needed capabilities here.
|
TODO: describe needed capabilities here.
|
||||||
|
|
||||||
|
## Patch
|
||||||
|
|
||||||
|
To perform refactoring (use `multinet.Dial` instead of `net.Dial`) using [gopatch](https://github.com/uber-go/gopatch):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
gopatch -p ./multinet.patch <project directory>
|
||||||
|
```
|
7
multinet.patch
Normal file
7
multinet.patch
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
@@
|
||||||
|
@@
|
||||||
|
+import "git.frostfs.info/TrueCloudLab/multinet"
|
||||||
|
-import "net"
|
||||||
|
|
||||||
|
-net.Dial(...)
|
||||||
|
+multinet.Dial(...)
|
19
testdata/patch_0.go
vendored
Normal file
19
testdata/patch_0.go
vendored
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"net"
|
||||||
|
)
|
||||||
|
|
||||||
|
const addr = "s01.frostfs.devenv:8080"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
_, err := net.Dial(getNetwork(), addr)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getNetwork() string {
|
||||||
|
return "tcp"
|
||||||
|
}
|
14
testdata/patch_1.go
vendored
Normal file
14
testdata/patch_1.go
vendored
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"net"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
ip := net.IPv4(192, 168, 0, 10)
|
||||||
|
_, err := net.Dial("tcp", ip.String()+":8080")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue