Created
June 13, 2017 02:40
-
-
Save Chen-tao/69421ba5252caba7a62fae9481bbf775 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var shortHostName = '' | |
func getShortHostname() string { | |
if shortHostName == "" { | |
host, _ := os.Hostname() | |
if index := strings.Index(host, "."); index > 0 { | |
shortHostName = host[:index] | |
} else { | |
shortHostName = host | |
} | |
} | |
return shortHostName | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment