how download google drive file with wget
package main
import (
"fmt"
"io"
"net/http"
"os"
)
func downloadFile(url string, destination string) error {
response, err := http.Get(url)
if err != nil {
return err
}
defer response.Body.Close()
file, err := os.Create(destination)
if err != nil {
return err
}
defer file.Close()
_, err = io.Copy(file, response.Body)
if err != nil {
return err
}
fmt.Printf("File downloaded successfully: %s\n", destination)
return nil
}
func main() {
fileURL := "https://drive.google.com/uc?export=download&id=YOUR_FILE_ID"
outputFile := "downloaded_file.txt"
err := downloadFile(fileURL, outputFile)
if err != nil {
fmt.Printf("Error downloading file: %v\n", err)
}
}
Replace YOUR_FILE_ID
in the fileURL
variable with the actual file ID from your Google Drive link. Save the file with a .go
extension, and then run it using the go run
command. The downloaded file will be saved with the name specified in the outputFile
variable.