hostname.go 285 B

12345678910111213141516171819202122
  1. // License: GPLv3 Copyright: 2022, Kovid Goyal, <kovid at kovidgoyal.net>
  2. package utils
  3. import (
  4. "fmt"
  5. "os"
  6. "sync"
  7. )
  8. var _ = fmt.Print
  9. var hostname string = "*"
  10. var Hostname = sync.OnceValue(func() string {
  11. h, err := os.Hostname()
  12. if err == nil {
  13. return h
  14. }
  15. return ""
  16. })