From a0828a265f23cc8c450f9d78b8cde05b6a8adfc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=80=E5=8F=91=E8=80=85=E5=B0=8F=E8=93=9D?= <540590988@qq.com> Date: Fri, 5 Jul 2019 16:18:57 +0800 Subject: [PATCH 1/5] =?UTF-8?q?fix:=20=E8=8E=B7=E5=8F=96hostname=E7=9A=84?= =?UTF-8?q?=E4=BC=98=E5=85=88=E7=BA=A7=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/conf/env/env.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/conf/env/env.go b/pkg/conf/env/env.go index 54b867e6d..64c4a963a 100644 --- a/pkg/conf/env/env.go +++ b/pkg/conf/env/env.go @@ -45,10 +45,13 @@ var ( func init() { var err error - if Hostname, err = os.Hostname(); err != nil || Hostname == "" { - Hostname = os.Getenv("HOSTNAME") + Hostname = os.Getenv("HOSTNAME") + if Hostname == "" { + Hostname, err = os.Hostname() + if err != nil { + Hostname = "" + } } - addFlag(flag.CommandLine) } From d5d510f7d6c4b89dc1647e81609128bc9290a2b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=80=E5=8F=91=E8=80=85=E5=B0=8F=E8=93=9D?= <540590988@qq.com> Date: Fri, 5 Jul 2019 18:13:04 +0800 Subject: [PATCH 2/5] feat: default host name --- pkg/conf/env/env.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/conf/env/env.go b/pkg/conf/env/env.go index 64c4a963a..aea995ab9 100644 --- a/pkg/conf/env/env.go +++ b/pkg/conf/env/env.go @@ -49,7 +49,7 @@ func init() { if Hostname == "" { Hostname, err = os.Hostname() if err != nil { - Hostname = "" + Hostname = Hostname = strconv.Itoa(time.Now().UnixNano()) } } addFlag(flag.CommandLine) From a5cdf8ffc799e54e45ca87aeb50a34c1e8fcc72a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=80=E5=8F=91=E8=80=85=E5=B0=8F=E8=93=9D?= <540590988@qq.com> Date: Fri, 5 Jul 2019 18:16:08 +0800 Subject: [PATCH 3/5] fix: bug --- pkg/conf/env/env.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/conf/env/env.go b/pkg/conf/env/env.go index aea995ab9..a5c50441b 100644 --- a/pkg/conf/env/env.go +++ b/pkg/conf/env/env.go @@ -49,7 +49,7 @@ func init() { if Hostname == "" { Hostname, err = os.Hostname() if err != nil { - Hostname = Hostname = strconv.Itoa(time.Now().UnixNano()) + Hostname = Hostname = strconv.Itoa(int(time.Now().UnixNano())) } } addFlag(flag.CommandLine) From f0ee75eb37507d2d1c173d8d8179e2aeaa7d358c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=80=E5=8F=91=E8=80=85=E5=B0=8F=E8=93=9D?= <540590988@qq.com> Date: Fri, 5 Jul 2019 18:22:37 +0800 Subject: [PATCH 4/5] =?UTF-8?q?fix:=20=E7=BC=96=E8=BE=91=E5=99=A8=E5=87=BA?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/conf/env/env.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/conf/env/env.go b/pkg/conf/env/env.go index a5c50441b..438cb12c1 100644 --- a/pkg/conf/env/env.go +++ b/pkg/conf/env/env.go @@ -49,7 +49,7 @@ func init() { if Hostname == "" { Hostname, err = os.Hostname() if err != nil { - Hostname = Hostname = strconv.Itoa(int(time.Now().UnixNano())) + Hostname = strconv.Itoa(int(time.Now().UnixNano())) } } addFlag(flag.CommandLine) From 42d8d07fe6925fc7bbe0d759f5fcb614b3a0f62b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=80=E5=8F=91=E8=80=85=E5=B0=8F=E8=93=9D?= <540590988@qq.com> Date: Fri, 5 Jul 2019 18:26:17 +0800 Subject: [PATCH 5/5] =?UTF-8?q?fix:=20=E6=97=A0=E5=9C=B0=E8=87=AA=E5=AE=B9?= =?UTF-8?q?=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/conf/env/env.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/conf/env/env.go b/pkg/conf/env/env.go index 438cb12c1..4669bb3fb 100644 --- a/pkg/conf/env/env.go +++ b/pkg/conf/env/env.go @@ -5,6 +5,8 @@ package env import ( "flag" "os" + "strconv" + "time" ) // deploy env.