package lib import ( "AIOTCOER/conf" "AIOTCOER/logs" "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) { logs.PrintlnError("File does not exist.") } else { return } resp, err := http.Get(url + T_analysis) if err != nil { logs.PrintlnError("Error downloading file:", err) return } defer resp.Body.Close() out, err := os.Create(conf.Analysis_Dir + T_analysis + ".so") if err != nil { logs.PrintlnError("Error creating file:", err) return } defer out.Close() _, err = io.Copy(out, resp.Body) if err != nil { logs.PrintlnError("Error downloading file:", err) return } logs.Println("File downloaded successfully.") }