當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。