本文整理匯總了Golang中clive/dbg.FlagPrintf函數的典型用法代碼示例。如果您正苦於以下問題:Golang FlagPrintf函數的具體用法?Golang FlagPrintf怎麽用?Golang FlagPrintf使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了FlagPrintf函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: New
/*
Create a new empty name space. It has a single entry for an empty
directory mounted at "/"
*/
func New() *Tree {
ns := &Tree{
pref: []*prefix{
{name: "/"},
},
}
ns.pref[0].ns = ns
ns.dprintf = dbg.FlagPrintf(os.Stderr, &ns.Debug)
ns.dfprintf = dbg.FlagPrintf(os.Stderr, &ns.DebugFind)
return ns
}
示例2: New
// Make a new repl for the given name and local and remote tree addresses.
// Pred defaults to exclude all dot files and dirs: 'name~^\.&prune|true'
func New(name, pred, laddr, raddr string) (*Repl, error) {
r := &Repl{
Name: name,
Laddr: laddr,
Raddr: raddr,
pred: pred,
}
r.vprintf = dbg.FlagPrintf(os.Stdout, &r.Verb)
if err := r.dial(); err != nil {
return nil, err
}
var err, rerr error
r.Ldb, err = sync.NewDB(name + "[" + laddr + "]", pred, r.lfs)
if err != nil {
dbg.Warn("%s: %s", laddr, err)
}
r.Rdb, rerr = sync.NewDB(name + "[" + raddr + "]", pred, r.rfs)
if rerr != nil {
err = rerr
dbg.Warn("%s: %s", raddr, rerr)
}
r.Ldb.Pred = r.pred
r.Rdb.Pred = r.pred
return r, err
}
示例3: Load
// Load the repl config and metadata dbs from disk.
func Load(fname string) (*Repl, error) {
dat, err := ioutil.ReadFile(fname)
if err != nil {
return nil, err
}
cs := string(dat)
lns := strings.Split(cs, "\n")
if len(lns) < 4 {
return nil, errors.New("too few lines in cfg")
}
r := &Repl{
Name: lns[0],
pred: lns[1],
Laddr: lns[2],
Raddr: lns[3],
}
r.vprintf = dbg.FlagPrintf(os.Stdout, &r.Verb)
if err := r.dial(); err != nil {
return nil, err
}
if r.Ldb, err = sync.LoadDB(fname+"l.db"); err != nil {
return nil, err
}
if r.Rdb, err = sync.LoadDB(fname+"r.db"); err != nil {
return nil, err
}
r.Ldb.Pred = r.pred
r.Rdb.Pred = r.pred
return r, nil
}
示例4: Serve
// Serve serves a FUSE connection with the default settings. See
// Server.Serve.
func Serve(c *fuse.Conn, fs FS) error {
server := Server{
FS: fs,
dprintf: dbg.FlagPrintf(os.Stderr, &Debug),
}
return server.Serve(c)
}
示例5: zxwax
"clive/zx/cfs"
"clive/zx/lfs"
"clive/zx/mfs"
"clive/zx/rfs"
"errors"
"fmt"
"os"
"path"
"path/filepath"
"strings"
)
var (
Verbose, Debug, Zdebug bool
Dprintf = dbg.FlagPrintf(os.Stdout, &Debug)
Vprintf = dbg.FlagPrintf(os.Stdout, &Verbose)
opts = opt.New("{spec}")
port string
wport string
svc string
addr string
zxw = map[string]string{}
)
func zxwax() {
ctrl := ctl.NewControl()
ctrl.BoolFlag("Debug", &Debug)
ctrl.CmdFlag("Exit", func() {
示例6: TestWords
package frmt
import (
"clive/dbg"
"strings"
"testing"
)
var (
debug bool
dprintf = dbg.FlagPrintf(&debug)
)
func TestWords(t *testing.T) {
txt := []string{` a te`, `xt wit`, `h`, `
some`, `
spaces `, `and words `,
}
sc, rc := Words()
go func() {
for _, t := range txt {
sc <- t
}
close(sc)
}()
words := []string{}
for w := range rc {
ws := string(w)
dprintf("word [%s]\n", ws)
words = append(words, ws)
}
示例7: main
"clive/app"
"clive/app/opt"
"clive/app/ql/qlfs"
"clive/dbg"
"clive/zx"
"clive/zx/rfs"
"clive/zx/zxfs"
"os"
)
var (
sflag bool
opts = opt.New("[mntdir] &")
addr, xaddr string
mntdir = "/n/ql"
dprintf = dbg.FlagPrintf(os.Stderr, &zxfs.Debug)
)
func main() {
defer app.Exiting()
x := app.New()
stacks := false
opts.NewFlag("F", "debug fuse requests", &zxfs.Debug)
opts.NewFlag("D", "debug", &x.Debug)
opts.NewFlag("s", "statistics", &sflag)
opts.NewFlag("x", "addr: re-export locally the ql tree to this address", &xaddr)
opts.NewFlag("S", "dump stacks on unmount for debugging", &stacks)
args, err := opts.Parse(x.Args)
if err != nil {
app.Warn("%s", err)
opts.Usage()
示例8:
//line parse.y:6
package xp
import __yyfmt__ "fmt"
//line parse.y:6
import (
"clive/dbg"
"math"
"os"
"time"
)
var (
debugYacc bool
yprintf = dbg.FlagPrintf(os.Stderr, &debugYacc)
lvl int
result value
)
//line parse.y:24
type yySymType {
yys int
ival uint64
fval float64
sval string
tval time.Time
vval interface{}
}
const INT = 57346
示例9: TestDiffs
package fscmp
import (
"clive/dbg"
"clive/zx/fstest"
"clive/zx/zux"
"fmt"
"os"
"testing"
)
var (
tdir = "/tmp/fscmptest"
tdir2 = "/tmp/fscmptest2"
Verb bool
Printf = dbg.FlagPrintf(&fstest.Verb)
)
func TestDiffs(t *testing.T) {
os.Args[0] = "fscmp.test"
fstest.Verb = testing.Verbose()
fstest.MkTree(t, tdir)
fstest.MkChgs(t, tdir)
defer os.RemoveAll(tdir)
fstest.ResetTime()
fstest.MkTree(t, tdir2)
fstest.MkChgs2(t, tdir2)
defer os.RemoveAll(tdir2)
Printf("changes...\n")
fs, err := zux.NewZX(tdir)
示例10: newLex
tTime tok = TIME
tSleft tok = SLEFT
tSright tok = SRIGHT
)
type lex {
in []rune
p0, p1 int
wasfunc, wasattr bool
result interface{}
}
var (
debugLex bool
lprintf = dbg.FlagPrintf(os.Stderr, &debugLex)
)
func newLex(input string) *lex {
return &lex{
in: []rune(input),
}
}
func (l *lex) Error(s string) {
panic(fmt.Errorf("near %s: %s", l.val(), s))
}
func (l *lex) get() rune {
if l.p1 >= len(l.in) {
return 0
示例11: BadName
import (
"bytes"
"clive/dbg"
"clive/nchan"
"errors"
"fmt"
"io"
"os"
"path"
"strconv"
"strings"
)
var DebugSend bool // set to debug sends/receives of full trees
var dprintf = dbg.FlagPrintf(os.Stderr, &DebugSend)
func BadName(elem string) error {
if strings.Contains(elem, "/") || elem == "." || elem == ".." {
return fmt.Errorf("bad element name '%s'", elem)
}
return nil
}
// Make sure s is an abslute path and return it cleaned and never empty.
func AbsPath(s string) (string, error) {
if len(s) == 0 || s[0] != '/' {
return "", fmt.Errorf("'%s' is not an absolute path", s)
}
return path.Clean(s), nil
}
示例12: walk
Bin string // restart if the binary changes
Env map[string]string
x *exec.Cmd
name string // Base(dir)
dir string // path of the dir for the cmd
runt time.Time // start time
donec chan bool
sigrestart bool
bint time.Time
}
var (
opts = opt.New("")
debug, verb bool
dprintf = dbg.FlagPrintf(os.Stderr, &debug)
vprintf = dbg.FlagPrintf(os.Stderr, &verb)
shell = "rc"
dir = "/tmp/xcmd"
cmd1 string
ErrNotYet = errors.New("not ready to start")
ErrExited = errors.New("command has exited")
ErrRestart = errors.New("restart required")
)
func walk(ds []os.FileInfo, name string) os.FileInfo {
for _, d := range ds {
if d.Name() == name {
return d
}
示例13:
"clive/zx/fstest"
"clive/zx/rzx"
"clive/zx/zux"
"clive/zx/zxc"
"fmt"
"os"
fpath "path"
"strings"
"testing"
)
const tdir = "/tmp/ns_test"
var (
verb = false
printf = dbg.FlagPrintf(&verb)
moreverb = false
ns1 = `/ /
/tmp
/tmp lfs!/!/tmp
/tmp lfs!/tmp
/usr
/usr/nemo zx!unix!8089!/tmp
path:"/x" io:"0" addr:"zx!unix!8089!/tmp"
`
ns1out = `/
/tmp
/tmp lfs!/!/tmp
/tmp
/usr
示例14: NewDB
Name string // of the db
Root *File // root
Pred string // find predicate.
lastpf *File
lastpdir string
}
// a File in the metadata DB
type File {
D zx.Dir // for the file
Child []*File // for directories
}
var (
Debug, Verb bool
dprintf = dbg.FlagPrintf(os.Stderr, &Debug)
vprintf = dbg.FlagPrintf(os.Stderr, &Verb)
)
// predicate to exclude dot files from dbs.
const NoDots = `name~^\.&prune|true`
// Create a DB for the given tree with the given name.
func NewDB(name, pred string, fs Finder) (*DB, error) {
t := &DB{
Name: name,
Pred: pred,
}
err := t.scan(fs)
return t, err
}
示例15: init
type Bg {
seq int
Nds map[*Nd]bool
Tags map[string]int
sync.Mutex
waits map[string][]chan bool
}
var (
bg = &Bg{
Nds: map[*Nd]bool{},
Tags: map[string]int{},
waits: map[string][]chan bool{},
}
debugExec bool
xprintf = dbg.FlagPrintf(os.Stderr, &debugExec)
intrlk sync.Mutex
intrc chan bool // closed upon interrupts
Interrupted bool // set to true upon interrupts
IntrExits bool // set to true when running scripts
ErrIntr = errors.New("interrupted")
)
func init() {
intrlk.Lock()
intrc = make(chan bool)
intrlk.Unlock()
dbg.AtIntr(func() bool {
dprintf("*** SIGINT\n")
intrlk.Lock()