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
+5k Fix ERROR 2003 (HY000): Can't connect to MySQL server on 'IP address' (111)
+13.5k Golang : Accurate and reliable decimal calculations
+8k Golang : Serving HTTP and Websocket from different ports in a program example
+2.2k Golang : Switch Redis database redis.NewClient
+8.4k Golang : Get all countries currencies code in JSON format
+6.3k Golang : Check to see if *File is a file or directory
+5.7k PHP : Shuffle to display different content or advertisement
+8.4k Facebook : Getting the friends list with PHP return JSON format
+15.5k Golang : Merge video(OpenCV) and audio(PortAudio) into a mp4 file
+18.2k Golang : Compare floating-point numbers
+3.7k JavaScript: Add marker function on Google Map