go-zero/core/sysx/host.go

22 lines
255 B
Go
Raw Normal View History

2020-07-26 17:09:05 +08:00
package sysx
import (
"os"
"github.com/tal-tech/go-zero/core/stringx"
2020-07-26 17:09:05 +08:00
)
var hostname string
func init() {
var err error
hostname, err = os.Hostname()
if err != nil {
hostname = stringx.RandId()
}
2020-07-26 17:09:05 +08:00
}
func Hostname() string {
return hostname
}