How to use DownloadAndUnzip method of util Package

Best Gauge code snippet using util.DownloadAndUnzip


Source:util.go Github


Full Screen

...29// IsWindows returns if Gauge is running on Windows30func IsWindows() bool {31 return runtime.GOOS == "windows"32}33// DownloadAndUnzip downloads the zip file from given download link and unzips it.34// Returns the unzipped file path.35func DownloadAndUnzip(downloadLink string, tempDir string) (string, error) {36 logger.Info("Downloading %s", filepath.Base(downloadLink))37 logger.Debug("Download URL %s", downloadLink)38 downloadedFile, err := Download(downloadLink, tempDir, "", false)39 if err != nil {40 return "", err41 }42 logger.Debug("Downloaded to %s", downloadedFile)43 unzippedPluginDir, err := common.UnzipArchive(downloadedFile, tempDir)44 if err != nil {45 return "", fmt.Errorf("Failed to Unzip file %s: %s", downloadedFile, err.Error())46 }47 logger.Debug("Unzipped to => %s\n", unzippedPluginDir)48 return unzippedPluginDir, nil49}...

Full Screen

Full Screen


Source:springinitializr.go Github


Full Screen

1package spring2import (3 ""4 "io/ioutil"5 "net/http"6 "os"7 "path"8)9const (10 Maven = "maven-project"11 Gradle = "gradle-project"12 Java = "java"13 Kotlin = "kotlin"14 SpringBootLatestVersion = "2.2.5.RELEASE"15 springInitializerUrlTemplate = "spring.initializr.tmpl"16)17func GenerateSpringProject(config *SpringProjectConfig) (string, error) {18 springTemplate, err := util.GetSpringTemplate(springInitializerUrlTemplate)19 if err != nil {20 return "", err21 }22 url, err := util.ParseTemplate(config, springInitializerUrlTemplate, springTemplate)23 if err != nil {24 return "", err25 }26 _, err = downloadAndUnzip(&url)27 if err != nil {28 return "", err29 }30 return path.Join(util.OutputDirectory, (*config).Name), nil31}32func downloadAndUnzip(downloadUrl *string) ([]string, error) {33 request, err := http.NewRequest("GET", *downloadUrl, nil)34 if err != nil {35 return nil, err36 }37 ch := make(chan util.ChannelResponse)38 defer close(ch)39 go util.MakeHttpRequest(request, ch)40 channelResponse := <-ch41 if channelResponse.Success {42 fileName, err := util.GenerateTemporaryFileName()43 if err != nil {44 return nil, err45 }46 if err = ioutil.WriteFile(fileName, channelResponse.Data, os.ModePerm); err != nil {47 return nil, err48 }49 files, err := util.Unzip(fileName, util.OutputDirectory)50 // Remove the temp file51 err = os.Remove(fileName)52 if err == nil {53 return nil, err54 }55 return files, err56 }57 return nil, channelResponse.Error58}...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:


You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Gauge automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?