From 76e736f572323394aeb99f080059f31556405156 Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Mon, 30 Oct 2023 13:28:29 +0300 Subject: [PATCH] [#3] dialer: Add `gopatch`s patch. Signed-off-by: Dmitrii Stepanov --- Makefile | 3 +++ README.md | 10 +++++++++- multinet.patch | 7 +++++++ testdata/patch_0.go | 19 +++++++++++++++++++ testdata/patch_1.go | 14 ++++++++++++++ 5 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 multinet.patch create mode 100644 testdata/patch_0.go create mode 100644 testdata/patch_1.go diff --git a/Makefile b/Makefile index 25f9279..b9bf237 100644 --- a/Makefile +++ b/Makefile @@ -4,3 +4,6 @@ integration-test: test: go test -count=1 -v ./... + +patch-example: + gopatch -d -p ./multinet.patch ./testdata/patch* \ No newline at end of file diff --git a/README.md b/README.md index b08a363..86c09c1 100644 --- a/README.md +++ b/README.md @@ -38,4 +38,12 @@ if err != nil { `Multidialer` exposes `UpdateInterface()` method for updating state of a single link. `NetlinkWatcher` can wrap `Multidialer` type and perform all updates automatically. -TODO: describe needed capabilities here. \ No newline at end of file +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 +``` \ No newline at end of file diff --git a/multinet.patch b/multinet.patch new file mode 100644 index 0000000..dcae3f2 --- /dev/null +++ b/multinet.patch @@ -0,0 +1,7 @@ +@@ +@@ ++import "git.frostfs.info/TrueCloudLab/multinet" +-import "net" + +-net.Dial(...) ++multinet.Dial(...) \ No newline at end of file diff --git a/testdata/patch_0.go b/testdata/patch_0.go new file mode 100644 index 0000000..0e1d610 --- /dev/null +++ b/testdata/patch_0.go @@ -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" +} diff --git a/testdata/patch_1.go b/testdata/patch_1.go new file mode 100644 index 0000000..42dccbe --- /dev/null +++ b/testdata/patch_1.go @@ -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) + } +}