float32 -> float64

This commit is contained in:
crusader 2018-09-22 00:14:35 +09:00
parent ac5e1d0bd3
commit 59e3ff19a7

View File

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