diff --git a/src/SPC/builder/traits/UnixGoCheckTrait.php b/src/SPC/builder/traits/UnixGoCheckTrait.php deleted file mode 100644 index 12e3d005..00000000 --- a/src/SPC/builder/traits/UnixGoCheckTrait.php +++ /dev/null @@ -1,83 +0,0 @@ -findCommand('go', $paths) === null) { - $this->installGo(); - } - - $gobin = getenv('GOBIN') ?: (getenv('HOME') . '/go/bin'); - putenv("GOBIN={$gobin}"); - - $paths[] = $gobin; - - if ($this->findCommand('xcaddy', $paths) === null) { - shell(true)->exec('go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest'); - } - - return CheckResult::ok(); - } - - private function installGo(): bool - { - $prefix = ''; - if (get_current_user() !== 'root') { - $prefix = 'sudo '; - logger()->warning('Current user is not root, using sudo for running command'); - } - - $arch = php_uname('m'); - $go_arch = match ($arch) { - 'x86_64' => 'amd64', - 'aarch64' => 'arm64', - default => $arch - }; - $os = strtolower(PHP_OS_FAMILY); - - $go_version = '1.24.4'; - $go_filename = "go{$go_version}.{$os}-{$go_arch}.tar.gz"; - $go_url = "https://go.dev/dl/{$go_filename}"; - - logger()->info("Downloading Go {$go_version} for {$go_arch}"); - - try { - // Download Go binary - Downloader::downloadFile('go', $go_url, $go_filename); - - // Extract the tarball - FileSystem::extractSource('go', SPC_SOURCE_ARCHIVE, DOWNLOAD_PATH . "/{$go_filename}"); - - // Move to /usr/local/go - logger()->info('Installing Go to /usr/local/go'); - shell()->exec("{$prefix}rm -rf /usr/local/go"); - shell()->exec("{$prefix}mv " . SOURCE_PATH . '/go /usr/local/'); - - if (!str_contains(getenv('PATH'), '/usr/local/go/bin')) { - logger()->info('Adding Go to PATH'); - shell()->exec("{$prefix}echo 'export PATH=\$PATH:/usr/local/go/bin' >> /etc/profile"); - putenv('PATH=' . getenv('PATH') . ':/usr/local/go/bin'); - } - - logger()->info('Go has been installed successfully'); - return true; - } catch (RuntimeException $e) { - logger()->error('Failed to install Go: ' . $e->getMessage()); - return false; - } - } -} diff --git a/src/SPC/doctor/item/BSDToolCheckList.php b/src/SPC/doctor/item/BSDToolCheckList.php index 97f0ccf9..2505227b 100644 --- a/src/SPC/doctor/item/BSDToolCheckList.php +++ b/src/SPC/doctor/item/BSDToolCheckList.php @@ -47,12 +47,6 @@ class BSDToolCheckList return CheckResult::ok(); } - #[AsCheckItem('if xcaddy is installed', limit_os: 'BSD')] - public function checkXcaddy(): ?CheckResult - { - return $this->checkGoAndXcaddy(); - } - #[AsFixItem('build-tools-bsd')] public function fixBuildTools(array $missing): bool { diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index 07f6b5fb..56235b0c 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -5,7 +5,6 @@ declare(strict_types=1); namespace SPC\doctor\item; use SPC\builder\linux\SystemUtil; -use SPC\builder\traits\UnixGoCheckTrait; use SPC\builder\traits\UnixSystemUtilTrait; use SPC\doctor\AsCheckItem; use SPC\doctor\AsFixItem; @@ -15,7 +14,6 @@ use SPC\exception\RuntimeException; class LinuxToolCheckList { use UnixSystemUtilTrait; - use UnixGoCheckTrait; public const TOOLS_ALPINE = [ 'make', 'bison', 'flex', @@ -89,12 +87,6 @@ class LinuxToolCheckList return CheckResult::ok(); } - #[AsCheckItem('if xcaddy is installed', limit_os: 'Linux')] - public function checkXcaddy(): ?CheckResult - { - return $this->checkGoAndXcaddy(); - } - #[AsCheckItem('if cmake version >= 3.18', limit_os: 'Linux')] public function checkCMakeVersion(): ?CheckResult { diff --git a/src/SPC/doctor/item/MacOSToolCheckList.php b/src/SPC/doctor/item/MacOSToolCheckList.php index 57ba8157..b4043a1d 100644 --- a/src/SPC/doctor/item/MacOSToolCheckList.php +++ b/src/SPC/doctor/item/MacOSToolCheckList.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace SPC\doctor\item; -use SPC\builder\traits\UnixGoCheckTrait; use SPC\builder\traits\UnixSystemUtilTrait; use SPC\doctor\AsCheckItem; use SPC\doctor\AsFixItem; @@ -14,7 +13,6 @@ use SPC\exception\RuntimeException; class MacOSToolCheckList { use UnixSystemUtilTrait; - use UnixGoCheckTrait; /** @var string[] MacOS 环境下编译依赖的命令 */ public const REQUIRED_COMMANDS = [ @@ -36,12 +34,6 @@ class MacOSToolCheckList 'glibtoolize', ]; - #[AsCheckItem('if xcaddy is installed', limit_os: 'Darwin')] - public function checkXcaddy(): ?CheckResult - { - return $this->checkGoAndXcaddy(); - } - #[AsCheckItem('if homebrew has installed', limit_os: 'Darwin', level: 998)] public function checkBrew(): ?CheckResult {