pub struct GoManager {}
Implementations§
Source§impl GoManager
impl GoManager
pub fn new() -> Self
Sourcepub fn extract_archive(
&self,
archive_path: &Path,
extract_to: &Path,
) -> Result<(), String>
pub fn extract_archive( &self, archive_path: &Path, extract_to: &Path, ) -> Result<(), String>
Extract archive to specified directory (public method)
§Errors
Returns an error if:
- The archive file cannot be opened
- The archive format is invalid
- Files cannot be extracted to the target directory
- File I/O operations fail
Sourcepub fn switch_version(
&self,
version: &str,
base_dir: &Path,
) -> Result<(), String>
pub fn switch_version( &self, version: &str, base_dir: &Path, ) -> Result<(), String>
跨平台版本切换实现(统一使用 symlink 模块)
§Errors
Returns an error if:
- The requested version directory does not exist
- Unable to remove existing current version link
- Unable to create new version link
- System file operations fail
Sourcepub fn get_current_version(&self, base_dir: &Path) -> Option<String>
pub fn get_current_version(&self, base_dir: &Path) -> Option<String>
获取当前活跃的Go版本(通过符号链接)
Sourcepub fn get_link_target(&self, base_dir: &Path) -> Option<PathBuf>
pub fn get_link_target(&self, base_dir: &Path) -> Option<PathBuf>
获取符号链接指向的目标路径(跨平台)
Sourcepub fn get_symlink_target(&self, base_dir: &Path) -> Option<PathBuf>
pub fn get_symlink_target(&self, base_dir: &Path) -> Option<PathBuf>
获取符号链接指向的目标路径(跨平台)
Sourcepub fn get_symlink_info(&self, base_dir: &Path) -> String
pub fn get_symlink_info(&self, base_dir: &Path) -> String
获取链接状态信息(跨平台)
Sourcepub async fn calculate_file_hash(
&self,
file_path: &Path,
) -> Result<String, String>
pub async fn calculate_file_hash( &self, file_path: &Path, ) -> Result<String, String>
计算文件的 SHA256 哈希值
§Errors
Returns an error if:
- The file cannot be opened
- File I/O operations fail during reading
- The hash calculation process fails
Sourcepub fn validate_cache_file(&self, file_path: &Path) -> bool
pub fn validate_cache_file(&self, file_path: &Path) -> bool
验证缓存文件的完整性 检查文件是否存在、非空,并且可以被读取
Sourcepub async fn get_version_info(
&self,
version: &str,
install_dir: &Path,
cache_dir: &Path,
) -> Result<GoVersionInfo, String>
pub async fn get_version_info( &self, version: &str, install_dir: &Path, cache_dir: &Path, ) -> Result<GoVersionInfo, String>
获取 Go 版本的详细信息
§Errors
Returns an error if:
- Invalid version format
- Network request fails
- Version not available for the current platform
- File size cannot be determined
Trait Implementations§
Source§impl VersionManager for GoManager
impl VersionManager for GoManager
Source§fn install<'life0, 'async_trait>(
&'life0 self,
request: InstallRequest,
) -> Pin<Box<dyn Future<Output = Result<VersionInfo, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn install<'life0, 'async_trait>(
&'life0 self,
request: InstallRequest,
) -> Pin<Box<dyn Future<Output = Result<VersionInfo, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
安装指定版本的Go
Source§fn list_installed(
&self,
request: ListInstalledRequest,
) -> Result<VersionList, String>
fn list_installed( &self, request: ListInstalledRequest, ) -> Result<VersionList, String>
列出已安装的版本
扫描基础目录中的所有子目录,返回包含有效Go安装的版本目录列表。 自动排除:
current
目录(符号链接)- 没有
bin/go
或bin/go.exe
的目录 - 非目录文件
返回的版本列表按字母顺序排序。
Source§fn list_available<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<VersionList, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_available<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<VersionList, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
列出可用的版本(实时获取)
Source§fn status(&self, request: StatusRequest) -> Result<RuntimeStatus, String>
fn status(&self, request: StatusRequest) -> Result<RuntimeStatus, String>
获取当前状态
Auto Trait Implementations§
impl Freeze for GoManager
impl RefUnwindSafe for GoManager
impl Send for GoManager
impl Sync for GoManager
impl Unpin for GoManager
impl UnwindSafe for GoManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more