package lib import ( "Yunlot/conf" "fmt" "io" "net/http" "os" ) var url = "https://yunlot.baozhida.cn/API/RunCode/Download?T_describe=" func DownloadSo(T_analysis string) { //url := "http://example.com/file.txt" // 检查文件是否存在 if _, err := os.Stat(conf.Analysis_Dir + T_analysis + ".so"); os.IsNotExist(err) { fmt.Println("File does not exist.") } else { return } resp, err := http.Get(url + T_analysis) if err != nil { fmt.Println("Error downloading file:", err) return } defer resp.Body.Close() out, err := os.Create(conf.Analysis_Dir + T_analysis + ".so") if err != nil { fmt.Println("Error creating file:", err) return } defer out.Close() _, err = io.Copy(out, resp.Body) if err != nil { fmt.Println("Error downloading file:", err) return } fmt.Println("File downloaded successfully.") }