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