refactor: Remove unused isWSL function from configuration initialization
- Deleted the isWSL function that checked for WSL environment, including related logging. - Streamlined the init_config.go file by eliminating unnecessary code.
- commit
- becc750bc918e29b63e5f701ea5b6d0bb328deb0
- author
- bamen · · 2025-03-29 08:58 UTC
- parent
- 3ac0ad3
- signature
- unsigned
1 file · +0 -24
M internal/common/init_config.go +0 -24
| @@ -756,30 +756,6 @@ func (c *Config) GetToken() string { | |||
| 756 | 756 | return c.General.JwtToken | |
| 757 | 757 | } | |
| 758 | 758 | ||
| 759 | - | func isWSL() bool { | |
| 760 | - | logger.Debug("isWSL: Checking if running in WSL") | |
| 761 | - | // Check if /proc/version exists | |
| 762 | - | _, err := os.Stat("/proc/version") | |
| 763 | - | if err != nil { | |
| 764 | - | logger.Debug("isWSL: /proc/version does not exist, not WSL", "error", err) | |
| 765 | - | return false | |
| 766 | - | } | |
| 767 | - | ||
| 768 | - | // Read /proc/version file | |
| 769 | - | logger.Debug("isWSL: Reading /proc/version file") | |
| 770 | - | data, err := os.ReadFile("/proc/version") | |
| 771 | - | if err != nil { | |
| 772 | - | logger.Debug("isWSL: Failed to read /proc/version", "error", err) | |
| 773 | - | return false | |
| 774 | - | } | |
| 775 | - | ||
| 776 | - | // Convert to string and check if it contains "Microsoft" or "WSL" | |
| 777 | - | version := string(data) | |
| 778 | - | isWsl := strings.Contains(strings.ToLower(version), "microsoft") || strings.Contains(strings.ToLower(version), "wsl") | |
| 779 | - | logger.Debug("isWSL: WSL detection result", "isWsl", isWsl) | |
| 780 | - | return isWsl | |
| 781 | - | } | |
| 782 | - | ||
| 783 | 759 | func (c *HttpConfig) Protocol() string { | |
| 784 | 760 | if c.Https { | |
| 785 | 761 | return "https" | |
| @@ -756,30 +756,6 @@ func (c *Config) GetToken() string { | |||||
| 756 | return c.General.JwtToken | 756 | return c.General.JwtToken | ||
| 757 | } | 757 | } | ||
| 758 | 758 | ||||
| 759 | - | func isWSL() bool { | |||
| 760 | - | logger.Debug("isWSL: Checking if running in WSL") | |||
| 761 | - | // Check if /proc/version exists | |||
| 762 | - | _, err := os.Stat("/proc/version") | |||
| 763 | - | if err != nil { | |||
| 764 | - | logger.Debug("isWSL: /proc/version does not exist, not WSL", "error", err) | |||
| 765 | - | return false | |||
| 766 | - | } | |||
| 767 | - | ||||
| 768 | - | // Read /proc/version file | |||
| 769 | - | logger.Debug("isWSL: Reading /proc/version file") | |||
| 770 | - | data, err := os.ReadFile("/proc/version") | |||
| 771 | - | if err != nil { | |||
| 772 | - | logger.Debug("isWSL: Failed to read /proc/version", "error", err) | |||
| 773 | - | return false | |||
| 774 | - | } | |||
| 775 | - | ||||
| 776 | - | // Convert to string and check if it contains "Microsoft" or "WSL" | |||
| 777 | - | version := string(data) | |||
| 778 | - | isWsl := strings.Contains(strings.ToLower(version), "microsoft") || strings.Contains(strings.ToLower(version), "wsl") | |||
| 779 | - | logger.Debug("isWSL: WSL detection result", "isWsl", isWsl) | |||
| 780 | - | return isWsl | |||
| 781 | - | } | |||
| 782 | - | ||||
| 783 | func (c *HttpConfig) Protocol() string { | 759 | func (c *HttpConfig) Protocol() string { | ||
| 784 | if c.Https { | 760 | if c.Https { | ||
| 785 | return "https" | 761 | return "https" | ||