本文整理匯總了Golang中github.com/cloudfoundry-community/pat/config.Config.Parse方法的典型用法代碼示例。如果您正苦於以下問題:Golang Config.Parse方法的具體用法?Golang Config.Parse怎麽用?Golang Config.Parse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry-community/pat/config.Config
的用法示例。
在下文中一共展示了Config.Parse方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
csvStore = NewCsvStore("/tmp/fakecsvstore")
redisStore = NewCsvStore("/tmp/fakeredisstore")
CsvStoreFactory = func(dir string) laboratory.Store {
csvStoreDir = dir
return csvStore
}
RedisStoreFactory = func(host string, port int, password string) (laboratory.Store, error) {
redisHost = host
redisPort = port
redisPassword = password
return redisStore, nil
}
})
JustBeforeEach(func() {
flags.Parse(args)
})
Context("When useRedis is false", func() {
BeforeEach(func() {
args = []string{"-use-redis=false", "-csv-dir", "foo/bar/baz"}
})
It("Uses the csvDir paramter to configure a CSV store", func() {
var s laboratory.Store = nil
WithStore(func(store laboratory.Store) error {
s = store
return nil
})
Ω(s).Should(Equal(csvStore))
示例2:
)
BeforeEach(func() {
flags = config.NewConfig()
os.Clearenv()
InitCommandLineFlags(flags)
ListenAndServe = func(bind string) error {
listen = bind
return nil
}
})
Context("When VCAP_APP_PORT does not exist", func() {
BeforeEach(func() {
os.Clearenv()
flags.Parse([]string{})
})
It("Defaults to 8080", func() {
Bind()
Ω(listen).Should(Equal(":8080"))
})
})
Context("When VCAP_APP_PORT exists", func() {
BeforeEach(func() {
os.Setenv("VCAP_APP_PORT", "1234")
flags.Parse([]string{})
})
It("Uses the env variable", func() {