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


Golang underscore.Disable函数代码示例

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


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

示例1: main

func main() {
	flag.Parse()
	var script []byte
	var err error
	filename := flag.Arg(0)
	if filename == "" || filename == "-" {
		script, err = ioutil.ReadAll(os.Stdin)
		if err != nil {
			fmt.Printf("Can't read stdin: %v\n", err)
			os.Exit(64)
		}
	} else {
		script, err = ioutil.ReadFile(filename)
		if err != nil {
			fmt.Printf("Can't open file \"%v\": %v\n", filename, err)
			os.Exit(64)
		}
	}
	if !*underscoreFlag {
		underscore.Disable()
	}
	Otto := otto.New()
	_, err = Otto.Run(string(script))
	if err != nil {
		fmt.Println(err)
		os.Exit(64)
	}
}
开发者ID:adrianuswarmenhoven,项目名称:otto,代码行数:28,代码来源:main.go

示例2: main

func main() {
	flag.Parse()

	if !*flag_underscore {
		underscore.Disable()
	}

	err := func() error {
		src, err := readSource(flag.Arg(0))
		if err != nil {
			return err
		}

		vm := otto.New()
		_, err = vm.Run(src)
		return err
	}()
	if err != nil {
		switch err := err.(type) {
		case *otto.Error:
			fmt.Print(err.String())
		default:
			fmt.Println(err)
		}
		os.Exit(64)
	}
}
开发者ID:xyproto,项目名称:otto,代码行数:27,代码来源:main.go

示例3: main

func main() {
	flag.Parse()

	if !*flag_underscore {
		underscore.Disable()
	}

	err := func() error {
		src, err := readSource(flag.Arg(0))
		if err != nil {
			return err
		}

		vm := otto.New()
		g_vm = vm

		vm.Set("setRoute", setRoute)
		vm.Set("startServer", startServer)
		vm.Set("writeMessage", writeMessage)

		_, err = vm.Run(src)
		return err
	}()
	if err != nil {
		switch err := err.(type) {
		case *otto.Error:
			fmt.Print(err.String())
		default:
			fmt.Println(err)
		}
		os.Exit(64)
	}
}
开发者ID:khanht-nguyen,项目名称:Newton,代码行数:33,代码来源:Newton.go

示例4: TestChannelMapperUnderscoreLib

// channel mapper fn that uses _ underscore JS library
func TestChannelMapperUnderscoreLib(t *testing.T) {
	underscore.Enable() // It really slows down unit tests (by making otto.New take a lot longer)
	defer underscore.Disable()
	mapper := NewChannelMapper(`function(doc) {channel(_.first(doc.channels));}`)
	res, err := mapper.MapToChannelsAndAccess(parse(`{"channels": ["foo", "bar", "baz"]}`), `{}`, noUser)
	assertNoError(t, err, "MapToChannelsAndAccess failed")
	assert.DeepEquals(t, res.Channels, SetOf("foo"))
}
开发者ID:nvdbleek,项目名称:sync_gateway,代码行数:9,代码来源:channelmapper_test.go

示例5: init

func init() {
	//base.LogKeys["CRUD"] = true
	//base.LogKeys["CRUD+"] = true
	underscore.Disable() // It really slows down unit tests (by making otto.New take a lot longer)
}
开发者ID:nvdbleek,项目名称:sync_gateway,代码行数:5,代码来源:database_test.go

示例6: init

func init() {
	underscore.Disable()
}
开发者ID:blendlabs,项目名称:otto,代码行数:3,代码来源:underscore_test.go

示例7: init

func init() {
	base.LogNoColor()
	underscore.Disable() // It really slows down unit tests (by making otto.New take a lot longer)
}
开发者ID:sueboy19,项目名称:sync_gateway,代码行数:4,代码来源:api_test.go


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