Skip to content

Commit

Permalink
localhost hack for macOS 10.12.5
Browse files Browse the repository at this point in the history
  • Loading branch information
jmhodges committed Nov 14, 2018
1 parent 95df254 commit f1bb929
Showing 1 changed file with 0 additions and 26 deletions.
26 changes: 0 additions & 26 deletions go/httphelper/http_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import (
"net"
"net/http"
"net/url"
"os"
"sort"
"strings"
"time"
)
Expand Down Expand Up @@ -149,30 +147,6 @@ func (s longestToShortest) Less(i, j int) bool {
// FQDN returns the fully-qualified domain name (or localhost if lookup
// according to the hostname fails).
func FQDN() (string, error) {
hostname, err := os.Hostname()
if err != nil {
// Fail if the kernel fails to report a hostname.
return "", err
}

addrs, err := net.LookupHost(hostname)
if err != nil {
return "localhost", nil
}

for _, addr := range addrs {
if names, err := net.LookupAddr(addr); err == nil && len(names) > 0 {
sort.Sort(longestToShortest(names))
for _, name := range names {
name = strings.TrimRight(name, ".")
if strings.HasPrefix(name, hostname) {
return name, nil
}
}
return names[0], nil
}
}

return "localhost", nil
}

Expand Down

0 comments on commit f1bb929

Please sign in to comment.