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


Golang dbg.Fatal函数代码示例

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


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

示例1: testText

func testText() *wax.Part {
	t := `- write a ws pg that knows how to display multiple parts with
	  drag and drop and resizes. Play embedding just a chunk of html
	  and later play with embedding something from a different url

	- write a canvas ctl
	- port the old canvas text frame using the canvas ctl
	- write an terminal variant that simply honors In,Out,Err chans
	  on a text frame.
	- use local storage to save the layout editing state for errors
	  and to recover those if desired
	- make sure we can share an inner part with controls multiple times
	 (ie not just repeating controls, but parts with controls, although
	 for this we should probably use iframes)

	- use tls for conns to the registry and peers
	- put in place some kind of auth
	- make the registry a hierarchy, so that we can have
	  registry islands and they sync to each other
	  make it use broadcast to discover other machines nearby
	  and propagate island information

`
	if err := tTxt.Ins([]rune(t), 0); err != nil {
		dbg.Fatal("txt ins: %s", err)
	}
	p, err := wax.New("$txt$")
	if err != nil {
		dbg.Fatal("new part: %s", err)
	}
	p.SetEnv(map[string]interface{}{"txt": tTxt})
	return p

}
开发者ID:Christopheraburns,项目名称:clive,代码行数:34,代码来源:parts.go

示例2: usage

func usage(err error) {
	opts.Usage(os.Stderr)
	fmt.Fprintf(os.Stderr, "\tspec = name | name!file | name!file!flags \n")
	fmt.Fprintf(os.Stderr, "\tspec flags = ro | rw | ncro | ncrw \n")
	if err == nil {
		dbg.Fatal("usage")
	}
	dbg.Fatal(err)
}
开发者ID:Christopheraburns,项目名称:clive,代码行数:9,代码来源:zx.go

示例3: bexit

func bexit(c cmd.Ctx) error {
	args := c.Args
	xprintf("exiting...\n")
	if len(args) <= 1 || args[1] == "" {
		dbg.Fatal("")
	} else {
		dbg.Fatal(args[1])
	}
	return nil
}
开发者ID:Christopheraburns,项目名称:clive,代码行数:10,代码来源:bltin.go

示例4: main

func main() {
	defer dbg.Exits("")
	os.Args[0] = "zxdump"
	dfltdump := zx.Path(dbg.Home, "dump")
	opts.NewFlag("s", "don't dump right now, wait until next at 5am", &Skip)
	opts.NewFlag("1", "dump once and exit", &Once)
	opts.NewFlag("v", "verbose", &Verbose)
	opts.NewFlag("D", "debug", &Debug)
	opts.NewFlag("x", "expr: files excluded (.*, tmp.* if none given); tmp always excluded.", &Xcludes)
	Dump = dfltdump
	opts.NewFlag("d", "dir: where to keep the dump, or empty if none", &Dump)
	args, err := opts.Parse(os.Args)
	if err != nil {
		dbg.Warn("%s", err)
		opts.Usage()
		dbg.Exits(err)
	}
	if len(Xcludes) == 0 {
		Xcludes = []string{".*", "tmp.*", "*.tmp"}
	}
	Xcludes = append(Xcludes, "tmp")
	if len(args) == 0 {
		dbg.Warn("arguments missing")
		opts.Usage()
		dbg.Exits("usage")
	}
	if Skip && Once {
		dbg.Fatal("can't skip the current dump and dump once now")
	}
	nt := 0
	ec := make(chan bool)
	for i := 0; i < len(args); i++ {
		al := strings.SplitN(args[i], "!", 2)
		if len(al) == 1 {
			al = append(al, al[0])
			al[0] = path.Base(al[0])
		}
		t, err := lfs.New(al[0], al[1], lfs.RO)
		if err != nil {
			dbg.Warn("%s: %s", al[0], err)
			continue
		}
		t.ReadAttrs(true)
		nt++
		go dump(Dump, t, ec)
	}
	if nt == 0 {
		dbg.Fatal("no trees to dump")
	}
	for nt > 0 {
		<-ec
		nt--
	}
}
开发者ID:Christopheraburns,项目名称:clive,代码行数:54,代码来源:dump.go

示例5: main

func main() {
	defer dbg.Exits("")
	os.Args[0] = "zxfs"
	quiet := false

	opts.NewFlag("q", "don't print errors to stderr", &quiet)
	opts.NewFlag("D", "debug and zxfs calls", &zxfs.Debug)
	opts.NewFlag("r", "read only", &rflag)
	opts.NewFlag("s", "statistics", &sflag)
	opts.NewFlag("n", "don't use caching (otherwise write-through cache)", &nocaching)
	opts.NewFlag("d", "use delayed writes cache", &delayed)
	opts.NewFlag("Z", "debug zx requests", &zdebug)
	opts.NewFlag("V", "verbose debug and fuse requests", &fs.Debug)
	opts.NewFlag("x", "addr: re-export locally the cached tree to this address, if any", &xaddr)
	opts.NewFlag("m", "use mfs caching", &mfscfs)
	opts.NewFlag("l", "dir: use lfs caching at dir", &lfsdir)
	args, err := opts.Parse(os.Args)
	if err != nil {
		opts.Usage(os.Stderr)
		dbg.Fatal(err)
	}
	zxfs.Debug = zxfs.Debug || fs.Debug
	zxfs.Verb = !quiet || zxfs.Debug
	if fs.Debug {
		fuse.Debug = func(m interface{}) {
			fmt.Fprintf(os.Stderr, "fuse: %v\n", m)
		}
	}
	switch len(args) {
	case 2:
		addr = args[0]
		mntdir = args[1]
	case 1:
		addr = args[0]
	default:
		opts.Usage(os.Stderr)
		dbg.Fatal("usage")
	}
	dprintf("debug on\n")
	xfs, fn, err := mkfs(addr)
	if err != nil {
		dbg.Fatal("%s", err)
	}
	defer fn()
	if nocaching || !delayed {
		err = ncmount(xfs)
	} else {
		dbg.Fatal("delayed write mount is gone")
	}
	if err != nil {
		dbg.Fatal("%s", err)
	}
	dbg.Warn("unmounted: exiting")
}
开发者ID:Christopheraburns,项目名称:clive,代码行数:54,代码来源:zxfs.go

示例6: ExampleNew

func ExampleNew() {
	// create a tree using the local directory /tmp/cache for the cache
	dfs, err := lfs.New("cache", "/tmp/cache", lfs.RW)
	if err != nil {
		dbg.Fatal("lfs: %s", err)
	}
	fs, err := New("example mdfs", dfs)
	if err != nil {
		dbg.Fatal("mfds: %s", err)
	}
	dbg.Warn("fs %s ready", fs)
	// Now use it...
}
开发者ID:Christopheraburns,项目名称:clive,代码行数:13,代码来源:mdfs_test.go

示例7: Pack

func (m *Msg) Pack() []byte {
	buf := make([]byte, 0, 100)
	var n [8]byte

	if m.Op<Tmin || m.Op>=Tend {
		dbg.Fatal("unknown msg type %d", m.Op)
	}
	buf = append(buf, byte(m.Op))
	buf = nchan.PutString(buf, m.Rid)
	if m.Op==Tget || m.Op==Tput {
		binary.LittleEndian.PutUint64(n[0:], uint64(m.Off))
		buf = append(buf, n[:8]...)
	}
	if m.Op == Tget {
		binary.LittleEndian.PutUint64(n[0:], uint64(m.Count))
		buf = append(buf, n[:8]...)
	}
	if m.Op==Tput || m.Op==Tmkdir || m.Op==Twstat {
		buf = append(buf, m.D.Pack()...)
	}
	if m.Op == Tmove {
		buf = nchan.PutString(buf, m.To)
	}
	if m.Op==Tfind || m.Op==Tget || m.Op==Tput || m.Op==Tfindget {
		buf = nchan.PutString(buf, m.Pred)
	}
	if m.Op==Tfind || m.Op==Tfindget {
		buf = nchan.PutString(buf, m.Spref)
		buf = nchan.PutString(buf, m.Dpref)
		binary.LittleEndian.PutUint64(n[0:], uint64(m.Depth))
		buf = append(buf, n[:8]...)
	}
	return buf
}
开发者ID:Christopheraburns,项目名称:clive,代码行数:34,代码来源:proto.go

示例8: testfn

func testfn(t *testing.T, fn func(t fstest.Fataler, fss ...zx.Tree)) {
	fstest.Repeats = 1
	fs, err := mfs.New("example mfs")
	if err != nil {
		dbg.Fatal("lfs: %s", err)
	}
	xfs, _ := fs.AuthFor(&auth.Info{Uid: dbg.Usr, SpeaksFor: dbg.Usr, Ok: true})
	tr := New(xfs)
	tc := make(chan string)
	dc := make(chan bool)
	go func() {
		for x := range tc {
			printf("%s\n", x)
		}
		dc <- true
	}()
	fstest.MkZXTree(t, tr)
	fs.Dbg = testing.Verbose()
	if fs.Dbg {
		defer fs.Dump(os.Stdout)
	}
	tr.C = tc
	if fn != nil {
		fn(t, tr)
	}
	tr.Close(nil)
	close(tc)
	<-dc
}
开发者ID:Christopheraburns,项目名称:clive,代码行数:29,代码来源:trfs_test.go

示例9: testFor

func testFor() *wax.Part {
	forpg := `
		Trees:
		<ul>
		$for t in repl.Trees do$
			<li>
			Name: $t.Name$;
			Path: $t.Path$;
			Kind: $t.Sync$
			<ul>
			$for p in t.Peers do$
				<li>
				$p$
			$end$
			</ul>
		$end$
		</ul>
	`
	p, err := wax.New(forpg)
	if err != nil {
		dbg.Fatal("new part: %s", err)
	}
	tenv := map[string]interface{}{"repl": tRepl}
	p.SetEnv(tenv)
	return p
}
开发者ID:Christopheraburns,项目名称:clive,代码行数:26,代码来源:parts.go

示例10: xInBlk

// both for Ninblk and Nhereblk
func (nd *Nd) xInBlk() ([]string, error) {
	xprintf("x %s\n", nd)
	if len(nd.Child) == 0 {
		return []string{}, nil
	}
	if len(nd.Child)>1 || nd.Child[0].Kind!=Npipe {
		dbg.Fatal("inblk child bug; it assumes a single pipe in block")
		return []string{}, dbg.ErrBug
	}
	c := nd.Child[0]
	fd, w, _ := os.Pipe()
	c.mkExec(nd.Stdin, w, nd.Stderr, nd.args...)
	c.extraFds(nd)
	c.closefds = append(c.closefds, w)
	c.Args = nil // don't & it
	c.xPipe()
	var b bytes.Buffer
	io.Copy(&b, fd)
	fd.Close()
	xprintf("x %s done\n", nd)
	if nd.Kind == Nhereblk {
		return []string{b.String()}, nil
	}
	words := strings.Fields(b.String())
	return words, nil
}
开发者ID:Christopheraburns,项目名称:clive,代码行数:27,代码来源:exec.go

示例11: ctx

func ctx() *Ctx {
	c := AppCtx()
	if c == nil {
		dbg.Fatal("no context for %d", runtime.AppId())
	}
	return c
}
开发者ID:Christopheraburns,项目名称:clive,代码行数:7,代码来源:app.go

示例12: testAdt

func testAdt() *wax.Part {
	p, err := wax.New(`$repl$`)
	if err != nil {
		dbg.Fatal("new part: %s", err)
	}
	p.SetEnv(map[string]interface{}{"repl": tRepl})
	return p
}
开发者ID:Christopheraburns,项目名称:clive,代码行数:8,代码来源:parts.go

示例13: testCanvas

func testCanvas() *wax.Part {
	p, err := wax.New("$tc$")
	if err != nil {
		dbg.Fatal("new part: %s", err)
	}
	p.SetEnv(map[string]interface{}{"tc": tCanvas})
	return p
}
开发者ID:Christopheraburns,项目名称:clive,代码行数:8,代码来源:parts.go

示例14: NewFlag

// Define a new flag with the given name and usage.
// valuep must be a pointer to the argument type and will be set to
// the command line flag value if the flag is found.
// Known types are bool, int, Counter, Octal, Hexa, int64, uint64, string,
// float64, time.Duration, time.Time, and []string.
// []string is a string option that may be repeated.
// The time formats understood are
//	"01/02"
//	"01/02/06"
//	"01/02/2006"
//	"2006/0102"
//	"15:04:05"
//	"15:04"
//	"3pm"
//	"3:04pm"
//	"01/02 15:04"
//	"01/02/06 15:04"
//	"01/02/2006 15:04"
//	"2006/0102 15:04 "
//
// If the name is "+..." or "-..." and vp is *int, then it is understood as
// a request to accept +number or -number as an argument.
//
// The help string should just describe the flag for flags with no
// argument, and should be something like "dir: do this with dir"
// if the flag accepts a "dir" argument. This convention is used to generate
// a good usage diagnostic.
func (f *Flags) NewFlag(name, help string, vp interface{}) {
	if vp == nil {
		dbg.Fatal("flag %s: nil value", name)
	}
	if len(name) == 0 {
		dbg.Fatal("empty flag name")
	}
	if f.defs[name] != nil {
		dbg.Fatal("flag %s redefined", name)
	}
	aname := ""
	if i := strings.Index(help, ":"); i > 0 {
		aname = help[:i]
	}
	switch vp.(type) {
	case *bool:

	case *int:
		if aname == "" {
			aname = "num"
		}
		if name[0] == '+' {
			if f.plus != nil {
				dbg.Fatal("flag +number redefined")
			}
			f.plus = &def{name: name, help: help, valp: vp, argname: aname}
			return
		}
		if name[0] == '-' {
			if f.minus != nil {
				dbg.Fatal("flag -number redefined")
			}
			f.minus = &def{name: name, help: help, valp: vp, argname: aname}
			return
		}
	case *Counter:
	case *Octal, *Hexa, *int64, *uint64, *float64:
		if aname == "" {
			aname = "num"
		}
	case *string, *[]string:
		if aname == "" {
			aname = "str"
		}
	case *time.Duration:
		if aname == "" {
			aname = "ival"
		}
	case *time.Time:
		if aname == "" {
			aname = "time"
		}
	default:
		dbg.Fatal("flag %s: unknown flag type", name)
	}
	if name[0]=='+' || name[0]=='-' {
		dbg.Fatal("name '±...' is only for *int")
	}
	f.defs[name] = &def{name: name, help: help, valp: vp, argname: aname}
}
开发者ID:Christopheraburns,项目名称:clive,代码行数:87,代码来源:opt.go

示例15: ExampleNewDir

func ExampleNewDir() {
	fi, err := os.Stat("/a/file")
	if err != nil {
		dbg.Fatal(err)
	}
	d := NewDir(fi, 0)
	printf("%s\n", d)
	// could print `path"/a/file", name:"file" type:"d" mode:"0755" size:"3" mtime:"5000000000"`
}
开发者ID:Christopheraburns,项目名称:clive,代码行数:9,代码来源:fs_test.go


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