当前位置: 首页>>代码示例>>Golang>>正文


Golang logger.Fatalf函数代码示例

本文整理汇总了Golang中github.com/getgauge/gauge/logger.Fatalf函数的典型用法代码示例。如果您正苦于以下问题:Golang Fatalf函数的具体用法?Golang Fatalf怎么用?Golang Fatalf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Fatalf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: UninstallPlugin

// UninstallPlugin uninstall the given plugin of the given version
// If version is not specified, it uninstalls all the versions of given plugin
func UninstallPlugin(pluginName string, version string) {
	pluginsHome, err := common.GetPrimaryPluginsInstallDir()
	if err != nil {
		logger.Fatalf("Failed to uninstall plugin %s. %s", pluginName, err.Error())
	}
	if !common.DirExists(filepath.Join(pluginsHome, pluginName, version)) {
		logger.Errorf("Plugin %s not found.", strings.TrimSpace(pluginName+" "+version))
		os.Exit(0)
	}
	var failed bool
	pluginsDir := filepath.Join(pluginsHome, pluginName)
	filepath.Walk(pluginsDir, func(dir string, info os.FileInfo, err error) error {
		if err == nil && info.IsDir() && dir != pluginsDir && strings.HasPrefix(filepath.Base(dir), version) {
			if err := uninstallVersionOfPlugin(dir, pluginName, filepath.Base(dir)); err != nil {
				logger.Errorf("Failed to uninstall plugin %s %s. %s", pluginName, version, err.Error())
				failed = true
			}
		}
		return nil
	})
	if failed {
		os.Exit(1)
	}
	if version == "" {
		if err := os.RemoveAll(pluginsDir); err != nil {
			logger.Fatalf("Failed to remove directory %s. %s", pluginsDir, err.Error())
		}
	}
}
开发者ID:mattdotmatt,项目名称:gauge,代码行数:31,代码来源:install.go

示例2: InitializeProject

// InitializeProject initializes a Gauge project with specified template
func InitializeProject(templateName string) {
	wd, err := os.Getwd()
	if err != nil {
		logger.Fatalf("Failed to find working directory. %s", err.Error())
	}
	config.ProjectRoot = wd

	exists, _ := common.UrlExists(getTemplateURL(templateName))

	if exists {
		err = initializeTemplate(templateName)
	} else {
		err = createProjectTemplate(templateName)
	}

	if err != nil {
		logger.Fatalf("Failed to initialize project. %s", err.Error())
	}
	logger.Info("Successfully initialized the project. Run specifications with \"gauge specs/\"\n")

	language := getTemplateLangauge(templateName)
	if !install.IsCompatiblePluginInstalled(language, true) {
		logger.Info("Compatible langauge plugin %s is not installed. Installing plugin...", language)

		install.HandleInstallResult(install.InstallPlugin(language, ""), language, true)
	}
}
开发者ID:mattdotmatt,项目名称:gauge,代码行数:28,代码来源:init.go

示例3: ListTemplates

// ListTemplates lists all the Gauge templates available in GaugeTemplatesURL
func ListTemplates() {
	templatesURL := config.GaugeTemplatesUrl()
	_, err := common.UrlExists(templatesURL)
	if err != nil {
		logger.Fatalf("Gauge templates URL is not reachable: %s", err.Error())
	}
	tempDir := common.GetTempDir()
	defer util.Remove(tempDir)
	templatesPage, err := util.Download(templatesURL, tempDir, "", true)
	if err != nil {
		util.Remove(tempDir)
		logger.Fatalf("Error occurred while downloading templates list: %s", err.Error())
	}

	templatePageContents, err := common.ReadFileContents(templatesPage)
	if err != nil {
		util.Remove(tempDir)
		logger.Fatalf("Failed to read contents of file %s: %s", templatesPage, err.Error())
	}
	templates := getTemplateNames(templatePageContents)
	for _, template := range templates {
		logger.Info(template)
	}
	logger.Info("\nRun `gauge --init <template_name>` to create a new Gauge project.")
}
开发者ID:mattdotmatt,项目名称:gauge,代码行数:26,代码来源:init.go

示例4: validateFlags

func validateFlags() {
	if !InParallel {
		return
	}
	if NumberOfExecutionStreams < 1 {
		logger.Fatalf("Invalid input(%s) to --n flag.", strconv.Itoa(NumberOfExecutionStreams))
	}
	if !isValidStrategy(Strategy) {
		logger.Fatalf("Invalid input(%s) to --strategy flag.", Strategy)
	}
}
开发者ID:0-T-0,项目名称:gauge,代码行数:11,代码来源:execute.go

示例5: LoadEnv

// LoadEnv first loads the default env properties and then the user specified env properties.
// This way user specified env variable can overwrite default if required
func LoadEnv(envName string) {
	currentEnv = envName

	err := loadDefaultProperties()
	if err != nil {
		logger.Fatalf("Failed to load the default property. %s", err.Error())
	}

	err = loadEnvDir(currentEnv)
	if err != nil {
		logger.Fatalf("Failed to load env. %s", err.Error())
	}
}
开发者ID:0-T-0,项目名称:gauge,代码行数:15,代码来源:env.go

示例6: InstallAllPlugins

func InstallAllPlugins() {
	manifest, err := manifest.ProjectManifest()
	if err != nil {
		logger.Fatalf(err.Error())
	}
	installPluginsFromManifest(manifest)
}
开发者ID:0-T-0,项目名称:gauge,代码行数:7,代码来源:install.go

示例7: GetConceptFiles

// GetConceptFiles returns the list of concept files present in the PROJECTROOT/base_dir_of_path
func GetConceptFiles(path string) []string {
	absPath, err := filepath.Abs(path)
	if err != nil {
		logger.Fatalf("Error getting absolute path. %v", err)
	}

	projRoot := config.ProjectRoot
	if projRoot == "" {
		logger.Fatalf("Failed to get project root. %v", err)
	}
	projRoot += string(filepath.Separator)

	path = strings.TrimPrefix(absPath, projRoot)
	path = strings.Split(path, string(filepath.Separator))[0]
	return FindConceptFilesIn(path)
}
开发者ID:mattdotmatt,项目名称:gauge,代码行数:17,代码来源:fileUtils.go

示例8: RunInBackground

// RunInBackground runs Gauge in daemonized mode on the given apiPort
func RunInBackground(apiPort string, specDirs []string) {
	var port int
	var err error
	if apiPort != "" {
		port, err = strconv.Atoi(apiPort)
		if err != nil {
			logger.Fatalf(fmt.Sprintf("Invalid port number: %s", apiPort))
		}
		os.Setenv(common.APIPortEnvVariableName, apiPort)
	} else {
		port, err = conn.GetPortFromEnvironmentVariable(common.APIPortEnvVariableName)
		if err != nil {
			logger.Fatalf(fmt.Sprintf("Failed to start API Service. %s \n", err.Error()))
		}
	}
	runAPIServiceIndefinitely(port, specDirs)
}
开发者ID:mattdotmatt,项目名称:gauge,代码行数:18,代码来源:api.go

示例9: validateTagExpression

func validateTagExpression(tagExpression string) {
	filter := &ScenarioFilterBasedOnTags{tagExpression: tagExpression}
	filter.replaceSpecialChar()
	_, err := filter.formatAndEvaluateExpression(make(map[string]bool, 0), func(a map[string]bool, b string) bool { return true })
	if err != nil {
		logger.Fatalf(err.Error())
	}
}
开发者ID:mattdotmatt,项目名称:gauge,代码行数:8,代码来源:specItemFilter.go

示例10: startAPI

//TODO : duplicate in execute.go. Need to fix runner init.
func startAPI() *runner.TestRunner {
	sc := api.StartAPI()
	select {
	case runner := <-sc.RunnerChan:
		return runner
	case err := <-sc.ErrorChan:
		logger.Fatalf("Failed to start gauge API: %s", err.Error())
	}
	return nil
}
开发者ID:mattdotmatt,项目名称:gauge,代码行数:11,代码来源:validate.go

示例11: refactorInit

func refactorInit(args []string) {
	if len(args) < 1 {
		logger.Fatalf("Flag needs at least two arguments: --refactor\nUsage : gauge --refactor <old step> <new step> [[spec directories]]")
	}
	var specDirs = []string{common.SpecsDirectoryName}
	if len(args) > 1 {
		specDirs = args[1:]
	}
	startChan := api.StartAPI()
	refactor.RefactorSteps(*refactorSteps, args[0], startChan, specDirs)
}
开发者ID:mattdotmatt,项目名称:gauge,代码行数:11,代码来源:gauge.go

示例12: InitializeProject

// InitializeProject initializes a Gauge project with specified template
func InitializeProject(templateName string) {
	wd, err := os.Getwd()
	if err != nil {
		logger.Fatalf("Failed to find working directory. %s", err.Error())
	}
	config.ProjectRoot = wd

	exists, _ := common.UrlExists(getTemplateURL(templateName))

	if exists {
		err = initializeTemplate(templateName)
	} else {
		err = createProjectTemplate(templateName)
	}

	if err != nil {
		logger.Fatalf("Failed to initialize. %s", err.Error())
	}
	logger.Info("\nSuccessfully initialized the project. Run specifications with \"gauge specs/\"")
}
开发者ID:0-T-0,项目名称:gauge,代码行数:21,代码来源:init.go

示例13: runAPIServiceIndefinitely

func runAPIServiceIndefinitely(port int, wg *sync.WaitGroup) {
	wg.Add(1)
	startChan := &runner.StartChannels{RunnerChan: make(chan *runner.TestRunner), ErrorChan: make(chan error), KillChan: make(chan bool)}
	go StartAPIService(port, startChan)
	select {
	case runner := <-startChan.RunnerChan:
		runner.Kill()
	case err := <-startChan.ErrorChan:
		logger.Fatalf(err.Error())
	}
}
开发者ID:0-T-0,项目名称:gauge,代码行数:11,代码来源:api.go

示例14: startAPI

func startAPI() *runner.TestRunner {
	startChan := &runner.StartChannels{RunnerChan: make(chan *runner.TestRunner), ErrorChan: make(chan error), KillChan: make(chan bool)}
	go api.StartAPIService(0, startChan)
	select {
	case runner := <-startChan.RunnerChan:
		return runner
	case err := <-startChan.ErrorChan:
		logger.Fatalf("Failed to start gauge API: %s", err.Error())
	}
	return nil
}
开发者ID:0-T-0,项目名称:gauge,代码行数:11,代码来源:execute.go

示例15: InstallPluginZip

func InstallPluginZip(zipFile string, pluginName string) {
	tempDir := common.GetTempDir()
	unzippedPluginDir, err := common.UnzipArchive(zipFile, tempDir)
	defer common.Remove(tempDir)
	if err != nil {
		common.Remove(tempDir)
		logger.Fatalf("Failed to install plugin. %s\n", err.Error())
	}
	logger.Info("Plugin unzipped to => %s\n", unzippedPluginDir)

	hasPluginJSON := common.FileExists(filepath.Join(unzippedPluginDir, pluginJSON))
	if hasPluginJSON {
		err = installPluginFromDir(unzippedPluginDir)
	} else {
		err = installRunnerFromDir(unzippedPluginDir, pluginName)
	}
	if err != nil {
		common.Remove(tempDir)
		logger.Fatalf("Failed to install plugin. %s\n", err.Error())
	}
	logger.Info("Successfully installed plugin from file.")
}
开发者ID:0-T-0,项目名称:gauge,代码行数:22,代码来源:install.go


注:本文中的github.com/getgauge/gauge/logger.Fatalf函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。