當前位置: 首頁>>代碼示例>>Golang>>正文


Golang common.SetEnvVariable函數代碼示例

本文整理匯總了Golang中github.com/getgauge/common.SetEnvVariable函數的典型用法代碼示例。如果您正苦於以下問題:Golang SetEnvVariable函數的具體用法?Golang SetEnvVariable怎麽用?Golang SetEnvVariable使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了SetEnvVariable函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: loadEnvironment

// Loads all the properties files available in the specified env directory
func loadEnvironment(env string) error {
	envDir := filepath.Join(config.ProjectRoot, common.EnvDirectoryName)

	dirToRead := path.Join(envDir, env)
	if !common.DirExists(dirToRead) {
		return errors.New(fmt.Sprintf("%s is an invalid environment", env))
	}

	isProperties := func(fileName string) bool {
		return filepath.Ext(fileName) == ".properties"
	}

	err := filepath.Walk(dirToRead, func(path string, info os.FileInfo, err error) error {
		if isProperties(path) {
			p, e := properties.Load(path)
			if e != nil {
				return errors.New(fmt.Sprintf("Failed to parse: %s. %s", path, e.Error()))
			}

			for k, v := range p {
				err := common.SetEnvVariable(k, v)
				if err != nil {
					return errors.New(fmt.Sprintf("%s: %s", path, err.Error()))
				}
			}
		}
		return nil
	})

	return err
}
開發者ID:Jayasagar,項目名稱:gauge,代碼行數:32,代碼來源:env.go

示例2: setEnvironmentProperties

func setEnvironmentProperties(properties map[string]string) error {
	for k, v := range properties {
		if err := common.SetEnvVariable(k, v); err != nil {
			return err
		}
	}
	return nil
}
開發者ID:mattdotmatt,項目名稱:gauge,代碼行數:8,代碼來源:plugin.go

示例3: setEnvVars

func setEnvVars() error {
	for name, value := range envVars {
		if !isPropertySet(name) {
			err := common.SetEnvVariable(name, value)
			if err != nil {
				return fmt.Errorf("%s", err.Error())
			}
		}
	}
	return nil
}
開發者ID:mattdotmatt,項目名稱:gauge,代碼行數:11,代碼來源:env.go

示例4: startAPIService

func startAPIService(port int) (error, *gaugeApiMessageHandler) {
	specInfoGatherer := new(specInfoGatherer)
	apiHandler := &gaugeApiMessageHandler{specInfoGatherer: specInfoGatherer}
	gaugeConnectionHandler, err := conn.NewGaugeConnectionHandler(port, apiHandler)
	if err != nil {
		return err, nil
	}
	if port == 0 {
		if err := common.SetEnvVariable(common.ApiPortEnvVariableName, strconv.Itoa(gaugeConnectionHandler.ConnectionPortNumber())); err != nil {
			return errors.New(fmt.Sprintf("Failed to set Env variable %s. %s", common.ApiPortEnvVariableName, err.Error())), nil
		}
	}
	go gaugeConnectionHandler.HandleMultipleConnections()
	apiHandler.runner = specInfoGatherer.makeListOfAvailableSteps(nil)
	return nil, apiHandler
}
開發者ID:Jayasagar,項目名稱:gauge,代碼行數:16,代碼來源:api.go

示例5: loadDefaultProperties

func loadDefaultProperties() error {
	defaultProperties = make(map[string]string)
	defaultProperties["gauge_reports_dir"] = "reports"
	defaultProperties["overwrite_reports"] = "true"
	defaultProperties["screenshot_on_failure"] = "true"
	defaultProperties["logs_directory"] = "logs"

	for property, value := range defaultProperties {
		if !isPropertySet(property) {
			if err := common.SetEnvVariable(property, value); err != nil {
				return err
			}
		}
	}
	return nil
}
開發者ID:0-T-0,項目名稱:gauge,代碼行數:16,代碼來源:env.go

示例6: loadEnvFile

func loadEnvFile(path string, info os.FileInfo, err error) error {
	if !isPropertiesFile(path) {
		return nil
	}

	properties, err := properties.Load(path)
	if err != nil {
		return fmt.Errorf("Failed to parse: %s. %s", path, err.Error())
	}

	for property, value := range properties {
		if canOverwriteProperty(property) {
			err := common.SetEnvVariable(property, value)
			if err != nil {
				return fmt.Errorf("%s: %s", path, err.Error())
			}
		}
	}

	return nil
}
開發者ID:0-T-0,項目名稱:gauge,代碼行數:21,代碼來源:env.go

示例7: StartAPIService

func StartAPIService(port int, startChannels *runner.StartChannels) {
	specInfoGatherer := new(infoGatherer.SpecInfoGatherer)
	apiHandler := &gaugeApiMessageHandler{specInfoGatherer: specInfoGatherer}
	gaugeConnectionHandler, err := conn.NewGaugeConnectionHandler(port, apiHandler)
	if err != nil {
		startChannels.ErrorChan <- err
		return
	}
	if port == 0 {
		if err := common.SetEnvVariable(common.ApiPortEnvVariableName, strconv.Itoa(gaugeConnectionHandler.ConnectionPortNumber())); err != nil {
			startChannels.ErrorChan <- errors.New(fmt.Sprintf("Failed to set Env variable %s. %s", common.ApiPortEnvVariableName, err.Error()))
			return
		}
	}
	go gaugeConnectionHandler.HandleMultipleConnections()
	runner, err := specInfoGatherer.MakeListOfAvailableSteps(startChannels.KillChan)
	if err != nil {
		startChannels.ErrorChan <- err
		return
	}
	startChannels.RunnerChan <- runner
}
開發者ID:christophermoura,項目名稱:gauge,代碼行數:22,代碼來源:api.go

示例8: startAPIService

// StartAPIService starts the Gauge API service
func startAPIService(port int, startChannels *runner.StartChannels, sig *infoGatherer.SpecInfoGatherer) {
	apiHandler := &gaugeAPIMessageHandler{specInfoGatherer: sig}
	gaugeConnectionHandler, err := conn.NewGaugeConnectionHandler(port, apiHandler)
	if err != nil {
		startChannels.ErrorChan <- fmt.Errorf("Connection error. %s", err.Error())
		return
	}
	if port == 0 {
		if err := common.SetEnvVariable(common.APIPortEnvVariableName, strconv.Itoa(gaugeConnectionHandler.ConnectionPortNumber())); err != nil {
			startChannels.ErrorChan <- fmt.Errorf("Failed to set Env variable %s. %s", common.APIPortEnvVariableName, err.Error())
			return
		}
	}
	go gaugeConnectionHandler.HandleMultipleConnections()

	runner, err := connectToRunner(startChannels.KillChan)
	if err != nil {
		startChannels.ErrorChan <- err
		return
	}
	startChannels.RunnerChan <- runner
}
開發者ID:mattdotmatt,項目名稱:gauge,代碼行數:23,代碼來源:api.go

示例9: setCurrentProjectEnvVariable

func setCurrentProjectEnvVariable() error {
	return common.SetEnvVariable(common.GaugeProjectRootEnv, ProjectRoot)
}
開發者ID:krwhitney,項目名稱:gauge,代碼行數:3,代碼來源:configuration.go


注:本文中的github.com/getgauge/common.SetEnvVariable函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。