MCPcopy Index your code
hub / github.com/coder/coder / getHostname

Function getHostname

cli/cliutil/hostname.go:24–40  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

22}
23
24func getHostname() string {
25 h, err := os.Hostname()
26 if err != nil {
27 // Something must be very wrong if this fails.
28 // We'll just return localhost and hope for the best.
29 return "localhost"
30 }
31
32 // On some platforms, the hostname can be an FQDN. We only want the hostname.
33 if idx := strings.Index(h, "."); idx != -1 {
34 h = h[:idx]
35 }
36
37 // For the sake of consistency, we also want to lowercase the hostname.
38 // Per RFC 4343, DNS lookups must be case-insensitive.
39 return strings.ToLower(h)
40}

Callers 1

HostnameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected