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
+19.5k Golang : Fix cannot download, $GOPATH not set error
+9.9k Golang : Format strings to SEO friendly URL example
+7.9k Golang : Scan files for certain pattern and rename part of the files
+16.5k Golang :Trim white spaces from a string
+21.6k Curl usage examples with Golang
+8.4k Golang : Count leading or ending zeros(any item of interest) example
+5.9k Golang : Markov chains to predict probability of next state example
+16.6k Golang : Test floating point numbers not-a-number and infinite example
+9.8k Golang : How to generate Code 39 barcode?
+10.3k Golang : Print how to use flag for your application example
+30.6k Get client IP Address in Go
+14.3k Golang : Check if a file exist or not