File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -134,10 +134,13 @@ type Config struct {
134
134
func NewInitConfig () * Config {
135
135
// check mysql version is supported or not and then get parse mysql semver version
136
136
var mysqlSemVer semver.Version
137
+
137
138
if ver := getEnvValue ("MYSQL_VERSION" ); ver == utils .InvalidMySQLVersion {
138
139
panic ("invalid mysql version, currently we only support 5.7 or 8.0" )
139
140
} else {
140
- mysqlSemVer , err := semver .Parse (ver )
141
+ var err error
142
+ // Do not use := here, it will alloc a new semver.Version every time.
143
+ mysqlSemVer , err = semver .Parse (ver )
141
144
if err != nil {
142
145
log .Info ("semver get from MYSQL_VERSION is invalid" , "semver: " , mysqlSemVer )
143
146
panic (err )
@@ -314,7 +317,8 @@ func (cfg *Config) buildXenonConf() []byte {
314
317
}
315
318
316
319
hostName := fmt .Sprintf ("%s.%s.%s" , cfg .HostName , cfg .ServiceName , cfg .NameSpace )
317
-
320
+ // Because go-sql-driver will translate localhost to 127.0.0.1 or ::1, but never set the hostname
321
+ // so the host is set to "127.0.0.1" in config file.
318
322
str := fmt .Sprintf (`{
319
323
"log": {
320
324
"level": "INFO"
@@ -337,7 +341,7 @@ func (cfg *Config) buildXenonConf() []byte {
337
341
"admin": "root",
338
342
"ping-timeout": %d,
339
343
"passwd": "%s",
340
- "host": "localhost ",
344
+ "host": "127.0.0.1 ",
341
345
"version": "%s",
342
346
"master-sysvars": "%s",
343
347
"slave-sysvars": "%s",
You can’t perform that action at this time.
0 commit comments