float32 -> float64
This commit is contained in:
parent
ac5e1d0bd3
commit
59e3ff19a7
|
@ -15,7 +15,7 @@ type Option interface {
|
||||||
|
|
||||||
type Response interface {
|
type Response interface {
|
||||||
GetTTL() int
|
GetTTL() int
|
||||||
GetTime() float32
|
GetTime() float64
|
||||||
GetError() string
|
GetError() string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,9 +23,9 @@ type Summary interface {
|
||||||
GetSendCount() int
|
GetSendCount() int
|
||||||
GetReceiveCount() int
|
GetReceiveCount() int
|
||||||
GetLossPercent() float32
|
GetLossPercent() float32
|
||||||
GetMinTime() float32
|
GetMinTime() float64
|
||||||
GetMaxTime() float32
|
GetMaxTime() float64
|
||||||
GetAvgTime() float32
|
GetAvgTime() float64
|
||||||
}
|
}
|
||||||
|
|
||||||
type Result interface {
|
type Result interface {
|
||||||
|
@ -63,14 +63,14 @@ func (o *PingOption) Validate() {
|
||||||
|
|
||||||
type PingResponse struct {
|
type PingResponse struct {
|
||||||
TTL int `json:"ttl,omitempty"`
|
TTL int `json:"ttl,omitempty"`
|
||||||
Time float32 `json:"time,omitempty"`
|
Time float64 `json:"time,omitempty"`
|
||||||
Error string `json:"error,omitempty"`
|
Error string `json:"error,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *PingResponse) GetTTL() int {
|
func (r *PingResponse) GetTTL() int {
|
||||||
return r.TTL
|
return r.TTL
|
||||||
}
|
}
|
||||||
func (r *PingResponse) GetTime() float32 {
|
func (r *PingResponse) GetTime() float64 {
|
||||||
return r.Time
|
return r.Time
|
||||||
}
|
}
|
||||||
func (r *PingResponse) GetError() string {
|
func (r *PingResponse) GetError() string {
|
||||||
|
@ -81,9 +81,9 @@ type PingSummary struct {
|
||||||
SendCount int `json:"sendCount,omitempty"`
|
SendCount int `json:"sendCount,omitempty"`
|
||||||
ReceiveCount int `json:"receiveCount,omitempty"`
|
ReceiveCount int `json:"receiveCount,omitempty"`
|
||||||
LossPercent float32 `json:"lossPercent,omitempty"`
|
LossPercent float32 `json:"lossPercent,omitempty"`
|
||||||
MinTime float32 `json:"minTime,omitempty"`
|
MinTime float64 `json:"minTime,omitempty"`
|
||||||
MaxTime float32 `json:"maxTime,omitempty"`
|
MaxTime float64 `json:"maxTime,omitempty"`
|
||||||
AvgTime float32 `json:"avgTime,omitempty"`
|
AvgTime float64 `json:"avgTime,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *PingSummary) GetSendCount() int {
|
func (s *PingSummary) GetSendCount() int {
|
||||||
|
@ -95,13 +95,13 @@ func (s *PingSummary) GetReceiveCount() int {
|
||||||
func (s *PingSummary) GetLossPercent() float32 {
|
func (s *PingSummary) GetLossPercent() float32 {
|
||||||
return s.LossPercent
|
return s.LossPercent
|
||||||
}
|
}
|
||||||
func (s *PingSummary) GetMinTime() float32 {
|
func (s *PingSummary) GetMinTime() float64 {
|
||||||
return s.MinTime
|
return s.MinTime
|
||||||
}
|
}
|
||||||
func (s *PingSummary) GetMaxTime() float32 {
|
func (s *PingSummary) GetMaxTime() float64 {
|
||||||
return s.MaxTime
|
return s.MaxTime
|
||||||
}
|
}
|
||||||
func (s *PingSummary) GetAvgTime() float32 {
|
func (s *PingSummary) GetAvgTime() float64 {
|
||||||
return s.AvgTime
|
return s.AvgTime
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,26 +152,26 @@ LOOP:
|
||||||
|
|
||||||
times := strings.Split(fields[3], "/")
|
times := strings.Split(fields[3], "/")
|
||||||
|
|
||||||
minTime, err := strconv.ParseFloat(times[0], 32)
|
minTime, err := strconv.ParseFloat(times[0], 64)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
continue LOOP
|
continue LOOP
|
||||||
}
|
}
|
||||||
result.Summary.(*PingSummary).MinTime = float32(minTime)
|
result.Summary.(*PingSummary).MinTime = minTime
|
||||||
|
|
||||||
maxTime, err := strconv.ParseFloat(times[2], 32)
|
maxTime, err := strconv.ParseFloat(times[2], 64)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
continue LOOP
|
continue LOOP
|
||||||
}
|
}
|
||||||
result.Summary.(*PingSummary).MaxTime = float32(maxTime)
|
result.Summary.(*PingSummary).MaxTime = maxTime
|
||||||
|
|
||||||
avgTime, err := strconv.ParseFloat(times[1], 32)
|
avgTime, err := strconv.ParseFloat(times[1], 64)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
continue LOOP
|
continue LOOP
|
||||||
}
|
}
|
||||||
result.Summary.(*PingSummary).AvgTime = float32(avgTime)
|
result.Summary.(*PingSummary).AvgTime = avgTime
|
||||||
|
|
||||||
case 8:
|
case 8:
|
||||||
if "bytes" != fields[1] || "from" != fields[2] {
|
if "bytes" != fields[1] || "from" != fields[2] {
|
||||||
|
@ -191,7 +191,7 @@ LOOP:
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
continue LOOP
|
continue LOOP
|
||||||
}
|
}
|
||||||
_time, err := strconv.ParseFloat(times[1], 32)
|
_time, err := strconv.ParseFloat(times[1], 64)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
continue LOOP
|
continue LOOP
|
||||||
|
@ -199,7 +199,7 @@ LOOP:
|
||||||
|
|
||||||
result.Responses[seq] = &PingResponse{
|
result.Responses[seq] = &PingResponse{
|
||||||
TTL: ttl,
|
TTL: ttl,
|
||||||
Time: float32(_time),
|
Time: _time,
|
||||||
}
|
}
|
||||||
|
|
||||||
case 10:
|
case 10:
|
||||||
|
@ -294,7 +294,7 @@ LOOP:
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
continue LOOP
|
continue LOOP
|
||||||
}
|
}
|
||||||
_time, err := strconv.ParseFloat(times, 32)
|
_time, err := strconv.ParseFloat(times, 64)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
continue LOOP
|
continue LOOP
|
||||||
|
@ -302,7 +302,7 @@ LOOP:
|
||||||
|
|
||||||
result.Responses[seq] = &PingResponse{
|
result.Responses[seq] = &PingResponse{
|
||||||
TTL: ttl,
|
TTL: ttl,
|
||||||
Time: float32(_time),
|
Time: _time,
|
||||||
}
|
}
|
||||||
seq = seq + 1
|
seq = seq + 1
|
||||||
case 9:
|
case 9:
|
||||||
|
@ -312,29 +312,29 @@ LOOP:
|
||||||
|
|
||||||
minTimes := strings.Replace(fields[2], "ms", "", -1)
|
minTimes := strings.Replace(fields[2], "ms", "", -1)
|
||||||
minTimes = strings.Replace(minTimes, ",", "", -1)
|
minTimes = strings.Replace(minTimes, ",", "", -1)
|
||||||
minTime, err := strconv.ParseFloat(minTimes, 32)
|
minTime, err := strconv.ParseFloat(minTimes, 64)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
continue LOOP
|
continue LOOP
|
||||||
}
|
}
|
||||||
result.Summary.(*PingSummary).MinTime = float32(minTime)
|
result.Summary.(*PingSummary).MinTime = minTime
|
||||||
|
|
||||||
maxTimes := strings.Replace(fields[5], "ms", "", -1)
|
maxTimes := strings.Replace(fields[5], "ms", "", -1)
|
||||||
maxTimes = strings.Replace(maxTimes, ",", "", -1)
|
maxTimes = strings.Replace(maxTimes, ",", "", -1)
|
||||||
maxTime, err := strconv.ParseFloat(maxTimes, 32)
|
maxTime, err := strconv.ParseFloat(maxTimes, 64)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
continue LOOP
|
continue LOOP
|
||||||
}
|
}
|
||||||
result.Summary.(*PingSummary).MaxTime = float32(maxTime)
|
result.Summary.(*PingSummary).MaxTime = maxTime
|
||||||
|
|
||||||
avgTimes := strings.Replace(fields[8], "ms", "", -1)
|
avgTimes := strings.Replace(fields[8], "ms", "", -1)
|
||||||
avgTime, err := strconv.ParseFloat(avgTimes, 32)
|
avgTime, err := strconv.ParseFloat(avgTimes, 64)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
continue LOOP
|
continue LOOP
|
||||||
}
|
}
|
||||||
result.Summary.(*PingSummary).AvgTime = float32(avgTime)
|
result.Summary.(*PingSummary).AvgTime = avgTime
|
||||||
|
|
||||||
case 12:
|
case 12:
|
||||||
if "Packets:" != fields[0] {
|
if "Packets:" != fields[0] {
|
||||||
|
@ -399,26 +399,26 @@ LOOP:
|
||||||
|
|
||||||
times := strings.Split(fields[3], "/")
|
times := strings.Split(fields[3], "/")
|
||||||
|
|
||||||
minTime, err := strconv.ParseFloat(times[0], 32)
|
minTime, err := strconv.ParseFloat(times[0], 64)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
continue LOOP
|
continue LOOP
|
||||||
}
|
}
|
||||||
result.Summary.(*PingSummary).MinTime = float32(minTime)
|
result.Summary.(*PingSummary).MinTime = minTime
|
||||||
|
|
||||||
maxTime, err := strconv.ParseFloat(times[2], 32)
|
maxTime, err := strconv.ParseFloat(times[2], 64)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
continue LOOP
|
continue LOOP
|
||||||
}
|
}
|
||||||
result.Summary.(*PingSummary).MaxTime = float32(maxTime)
|
result.Summary.(*PingSummary).MaxTime = maxTime
|
||||||
|
|
||||||
avgTime, err := strconv.ParseFloat(times[1], 32)
|
avgTime, err := strconv.ParseFloat(times[1], 64)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
continue LOOP
|
continue LOOP
|
||||||
}
|
}
|
||||||
result.Summary.(*PingSummary).AvgTime = float32(avgTime)
|
result.Summary.(*PingSummary).AvgTime = avgTime
|
||||||
|
|
||||||
case 8:
|
case 8:
|
||||||
if "bytes" != fields[1] || "from" != fields[2] {
|
if "bytes" != fields[1] || "from" != fields[2] {
|
||||||
|
@ -438,7 +438,7 @@ LOOP:
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
continue LOOP
|
continue LOOP
|
||||||
}
|
}
|
||||||
_time, err := strconv.ParseFloat(times[1], 32)
|
_time, err := strconv.ParseFloat(times[1], 64)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
continue LOOP
|
continue LOOP
|
||||||
|
@ -446,7 +446,7 @@ LOOP:
|
||||||
|
|
||||||
result.Responses[seq] = &PingResponse{
|
result.Responses[seq] = &PingResponse{
|
||||||
TTL: ttl,
|
TTL: ttl,
|
||||||
Time: float32(_time),
|
Time: _time,
|
||||||
}
|
}
|
||||||
|
|
||||||
case 9:
|
case 9:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user