Expand system error message

This commit is contained in:
mgaitonde
2022-03-09 13:17:04 -08:00
parent a38dc2f48f
commit f883e4d4b3
3 changed files with 4 additions and 4 deletions

View File

@@ -10,7 +10,7 @@ COPY . /go/src/github.com/mayuresh82/gocast
WORKDIR /go/src/github.com/mayuresh82/gocast WORKDIR /go/src/github.com/mayuresh82/gocast
RUN make RUN make linux
FROM alpine:latest FROM alpine:latest
RUN apk --no-cache add ca-certificates bash iptables netcat-openbsd sudo RUN apk --no-cache add ca-certificates bash iptables netcat-openbsd sudo

View File

@@ -13,4 +13,4 @@ test:
go test -v -race -short -failfast -mod=vendor ./... go test -v -race -short -failfast -mod=vendor ./...
linux: linux:
GOOS=linux GOARCH=amd64 go build -o gocast_linux -mod=vendor . CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o gocast -mod=vendor .

View File

@@ -23,7 +23,7 @@ func gateway() (net.IP, error) {
cmdList := getCmdList(cmd) cmdList := getCmdList(cmd)
out, err := exec.Command(execCmd, cmdList...).Output() out, err := exec.Command(execCmd, cmdList...).Output()
if err != nil { if err != nil {
return nil, fmt.Errorf("Failed to execute command: %s", cmd) return nil, fmt.Errorf("Failed to execute command: %s: %v", cmd, err)
} }
return net.ParseIP(strings.TrimSpace(string(out))), nil return net.ParseIP(strings.TrimSpace(string(out))), nil
} }
@@ -33,7 +33,7 @@ func via(dest net.IP) (net.IP, error) {
cmdList := getCmdList(cmd) cmdList := getCmdList(cmd)
out, err := exec.Command(execCmd, cmdList...).Output() out, err := exec.Command(execCmd, cmdList...).Output()
if err != nil { if err != nil {
return nil, fmt.Errorf("Failed to execute command: %s", cmd) return nil, fmt.Errorf("Failed to execute command: %s: %v", cmd, err)
} }
if string(out) == "" { if string(out) == "" {
// assume the provided dest is the next hop // assume the provided dest is the next hop