refactor(config): improve config file handling and error messages

- Replace manual address formatting with net.JoinHostPort in tcpClient
- Simplify debug/error messages in IsInstanceRunning by removing redundant output
- Fix incorrect map reference for RunUser in CreateInstanceHandler
- Extract config file creation logic into handleConfigFileCreate
- Add auth_token to response data in GetInstanceInfoHandler
- Remove redundant AuthToken field from InstanceInfo struct
This commit is contained in:
2026-04-21 18:39:11 +08:00
parent 3e3adf122c
commit df8df78bab
4 changed files with 59 additions and 20 deletions
+1 -1
View File
@@ -42,7 +42,7 @@ func tcpConnect(ipaddr string, port int) error {
return fmt.Errorf("already connected")
}
address := fmt.Sprintf("%s:%d", ipaddr, port)
address := net.JoinHostPort(ipaddr, fmt.Sprintf("%d", port))
conn, err := net.DialTimeout("tcp", address, 3*time.Second)
if err != nil {
return fmt.Errorf("failed to connect to %s: %v", address, err)