packagemainimport("flag""fmt""io""net/http""os""path")funcdownload(url,filenamestring)(errerror){fmt.Println("Downloading ",url," to ",filename)resp,err:=http.Get(url)iferr!=nil{return}deferresp.Body.Close()f,err:=os.Create(filename)iferr!=nil{return}deferf.Close()_,err=io.Copy(f,resp.Body)return}funcmain(){pUrl:=flag.String("url","","URL to be processed")flag.Parse()url:=*pUrlifurl==""{fmt.Fprintf(os.Stderr,"Error: empty URL!\n")return}filename:=path.Base(url)fmt.Println("Checking if "+filename+" exists ...")if_,err:=os.Stat(filename);os.IsNotExist(err){err:=download(url,filename)iferr!=nil{panic(err)}fmt.Println(filename+" saved!")}else{fmt.Println(filename+" already exists!")}}