From ac5e1d0bd3551ae98e0866d9ddcc2a8c2fd421d2 Mon Sep 17 00:00:00 2001 From: crusader Date: Thu, 20 Sep 2018 14:12:13 +0900 Subject: [PATCH] Changed from Retry to Count --- net/ping/ping.go | 12 ++++++------ net/ping/ping_darwin.go | 2 +- net/ping/ping_darwin_test.go | 2 +- net/ping/ping_linux.go | 2 +- net/ping/ping_linux_test.go | 2 +- net/ping/ping_test.go | 4 ++-- net/ping/ping_windows.go | 2 +- net/ping/ping_windows_test.go | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/net/ping/ping.go b/net/ping/ping.go index da1be3e..601af6d 100644 --- a/net/ping/ping.go +++ b/net/ping/ping.go @@ -7,7 +7,7 @@ import ( ) type Option interface { - GetRetry() int + GetCount() int GetInterval() int GetDeadline() int Validate() @@ -35,13 +35,13 @@ type Result interface { } type PingOption struct { - Retry int `json:"retry,omitempty"` + Count int `json:"count,omitempty"` Interval int `json:"interval,omitempty"` Deadline int `json:"deadline,omitempty"` } -func (o *PingOption) GetRetry() int { - return o.Retry +func (o *PingOption) GetCount() int { + return o.Count } func (o *PingOption) GetInterval() int { return o.Interval @@ -50,8 +50,8 @@ func (o *PingOption) GetDeadline() int { return o.Deadline } func (o *PingOption) Validate() { - if 0 >= o.Retry { - o.Retry = 1 + if 0 >= o.Count { + o.Count = 1 } if 0 >= o.Interval { o.Interval = 1 diff --git a/net/ping/ping_darwin.go b/net/ping/ping_darwin.go index 84f6e39..cbe3120 100644 --- a/net/ping/ping_darwin.go +++ b/net/ping/ping_darwin.go @@ -10,7 +10,7 @@ func Ping(destination string, option Option) (Result, error) { params := make([]string, 0) params = append(params, destination) - params = append(params, fmt.Sprintf("-c %d", option.GetRetry())) + params = append(params, fmt.Sprintf("-c %d", option.GetCount())) params = append(params, fmt.Sprintf("-i %d", option.GetInterval())) pCmd := exec.Command("ping", params...) diff --git a/net/ping/ping_darwin_test.go b/net/ping/ping_darwin_test.go index 628e024..f9b9d25 100644 --- a/net/ping/ping_darwin_test.go +++ b/net/ping/ping_darwin_test.go @@ -21,7 +21,7 @@ func TestPing(t *testing.T) { args: args{ destination: "192.168.1.1", option: &PingOption{ - Retry: 4, + Count: 4, }, }, }, diff --git a/net/ping/ping_linux.go b/net/ping/ping_linux.go index 1fa731d..48eca88 100644 --- a/net/ping/ping_linux.go +++ b/net/ping/ping_linux.go @@ -11,7 +11,7 @@ func Ping(destination string, option Option) (Result, error) { params := make([]string, 0) params = append(params, destination) - params = append(params, fmt.Sprintf("-c %d", option.GetRetry())) + params = append(params, fmt.Sprintf("-c %d", option.GetCount())) params = append(params, fmt.Sprintf("-i %d", option.GetInterval())) pCmd := exec.Command("ping", params...) diff --git a/net/ping/ping_linux_test.go b/net/ping/ping_linux_test.go index 94a2053..df94742 100644 --- a/net/ping/ping_linux_test.go +++ b/net/ping/ping_linux_test.go @@ -18,7 +18,7 @@ func TestPing(t *testing.T) { args: args{ destination: "192.168.1.1", option: &PingOption{ - Retry: 4, + Count: 4, }, }, }, diff --git a/net/ping/ping_test.go b/net/ping/ping_test.go index 23da36f..8e9c46d 100644 --- a/net/ping/ping_test.go +++ b/net/ping/ping_test.go @@ -7,7 +7,7 @@ import ( func TestPingOptions_Validate(t *testing.T) { type fields struct { - Retry int + Count int Interval int Deadline int } @@ -21,7 +21,7 @@ func TestPingOptions_Validate(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { o := &PingOption{ - Retry: tt.fields.Retry, + Count: tt.fields.Count, Interval: tt.fields.Interval, Deadline: tt.fields.Deadline, } diff --git a/net/ping/ping_windows.go b/net/ping/ping_windows.go index 2c2b421..8a1e76d 100644 --- a/net/ping/ping_windows.go +++ b/net/ping/ping_windows.go @@ -10,7 +10,7 @@ func Ping(destination string, option Option) (Result, error) { params := make([]string, 0) params = append(params, "/C") - params = append(params, fmt.Sprintf("chcp 437 && ping %s -n %d -w %d", destination, option.GetRetry(), option.GetDeadline()*1000)) + params = append(params, fmt.Sprintf("chcp 437 && ping %s -n %d -w %d", destination, option.GetCount(), option.GetDeadline()*1000)) pCmd := exec.Command("cmd.exe", params...) output, err := pCmd.CombinedOutput() diff --git a/net/ping/ping_windows_test.go b/net/ping/ping_windows_test.go index 94a2053..df94742 100644 --- a/net/ping/ping_windows_test.go +++ b/net/ping/ping_windows_test.go @@ -18,7 +18,7 @@ func TestPing(t *testing.T) { args: args{ destination: "192.168.1.1", option: &PingOption{ - Retry: 4, + Count: 4, }, }, },