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 - dev
paths-ignore: paths-ignore:
- '**.md' - '**.md'
pull_request:
branches:
- dev
paths-ignore:
- '**.md'
jobs: jobs:
compile: compile:

View File

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