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
+9.7k Golang : How to extract video or image files from html source code
+16.5k Golang : Check if a string contains multiple sub-strings in []string?
+4.9k Which content-type(MIME type) to use for JSON data
+5.7k Golang : Configure crontab to poll every two minutes 8am to 6pm Monday to Friday
+15.4k Golang : Get query string value on a POST request
+7k Golang : How to setup a disk space used monitoring service with Telegram bot
+38k Golang : Converting a negative number to positive number
+43.5k Golang : Convert []byte to image
+14.2k Golang : Fix cannot use buffer (type bytes.Buffer) as type io.Writer(Write method has pointer receiver) error
+7k Nginx : Password protect a directory/folder
+6.1k Golang : Missing Subversion command
+5.4k PHP : Hide PHP version information from curl