本文整理汇总了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)
}
}
示例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)
}
}
示例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)
}
}
示例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"))
}
示例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)
}
示例6: init
func init() {
underscore.Disable()
}
示例7: init
func init() {
base.LogNoColor()
underscore.Disable() // It really slows down unit tests (by making otto.New take a lot longer)
}