Golang os.Hostname() function example
package os
Golang os.Hostname() function usage example
package main
import (
"fmt"
"os"
)
func main() {
name, err := os.Hostname()
if err != nil {
panic(err)
}
fmt.Println("Hostname reported by kernel : ", name)
}
Sample output :
Hostname reported by kernel : example.com
Reference :
Advertisement
Something interesting
Tutorials
+8.2k Golang : Qt splash screen with delay example
+4.8k Facebook : How to place save to Facebook button on your website
+7.1k Nginx : How to block user agent ?
+12.7k Golang : Sort and reverse sort a slice of bytes
+6.2k Golang : Process non-XML/JSON formatted ASCII text file example
+8.2k Golang : HttpRouter multiplexer routing example
+23.5k Golang : Read a file into an array or slice example
+25.4k Golang : Generate MD5 checksum of a file
+8.7k Golang : How to join strings?
+26.6k Golang : Encrypt and decrypt data with AES crypto
+10k Golang : Channels and buffered channels examples
+36.3k Golang : How to split or chunking a file to smaller pieces?