Main function improved
- More explicit cli operation - Using ctx and os.Args injected for eventual later testing - Returning exit code - Cli code moved to cli package
This commit is contained in:
24
internal/cli/cli.go
Normal file
24
internal/cli/cli.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/qdm12/golibs/network/connectivity"
|
||||
)
|
||||
|
||||
func HealthCheck() error {
|
||||
// DNS, HTTP and HTTPs check on github.com
|
||||
connectivity := connectivity.NewConnectivity(3 * time.Second)
|
||||
errs := connectivity.Checks("github.com")
|
||||
if len(errs) > 0 {
|
||||
var errsStr []string
|
||||
for _, err := range errs {
|
||||
errsStr = append(errsStr, err.Error())
|
||||
}
|
||||
return fmt.Errorf("Multiple errors: %s", strings.Join(errsStr, "; "))
|
||||
}
|
||||
// TODO check IP address is in the right region
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user