gh actions, ping command for windows

pull/739/head
hunterlong 2020-07-10 09:25:56 -07:00
parent 2037359fad
commit 759798e1da
2 changed files with 8 additions and 3 deletions

View File

@ -5,6 +5,11 @@ on:
- dev
paths-ignore:
- '**.md'
pull_request:
branches:
- dev
paths-ignore:
- '**.md'
jobs:
compile:

View File

@ -29,14 +29,14 @@ func DirWritable(path string) (bool, error) {
func Ping(address string, secondsTimeout int) (int64, error) {
ping, err := exec.LookPath("ping")
if err != nil {
return err
return 0, err
}
out, _, err := Command(ping, address, "-n", "1", "-w", strconv.Itoa(secondsTimeout*1000))
if err != nil {
return err
return 0, err
}
if strings.Contains(out, "Destination Host Unreachable") {
return errors.New("destination host unreachable")
return 0, errors.New("destination host unreachable")
}
r := regexp.MustCompile(`Average = (.*)ms`)
strs := r.FindStringSubmatch(out)