// NewLauncher returns a new instance of Launcher connected to standard in/out/err.
330403
func NewLauncher() *Launcher {
	return &Launcher{
		Stdin:         os.Stdin,
		Stdout:        os.Stdout,
		Stderr:        os.Stderr,
		StorageConfig: storage.NewConfig(),
	}
}
30191
func NewExpander(r io.Reader, dict []byte) *Expander {
	e := Expander{}
	e.r = r
	e.to = 0
	e.dict = dict
	return &e
}
1170467
func New(name string) *Loader {
	return &Loader{
		Args:         os.Args[1:],
		Aliases:      map[string]string{},
		KeyParser:    DashSeparatorKeyParser,
		LoadDefaults: false,
		FlagSet:      flaglib.NewFlagSet(name, flaglib.ContinueOnError),
	}
}
887688
func NewLogger(minLogLevel LogLevel) Logger {
	sink := writerSink{
		writer:      os.Stdout,
		minLogLevel: minLogLevel,
	}
	return &logger{
		sinks: []Sink{sink},
	}
}
381552
func (db *DB) newBuilder(executor Executor) Builder {
	builderFunc, ok := BuilderFuncMap[db.driverName]
	if !ok {
		builderFunc = NewStandardBuilder
	}
	return builderFunc(db, executor)
}
643940
func newLogger(name string) (Logger, func(Level)) {
	logger := logging.NewLogger(name)
	logger.SetLevel(convertLevel(getLogLevel()))

	if os.Getenv("KITE_LOG_NOCOLOR") != "" {
		logging.StdoutHandler.Colorize = false
		logging.StderrHandler.Colorize = false
	}

	setLevel := func(l Level) {
		logger.SetLevel(convertLevel(l))
		logging.DefaultHandler.SetLevel(convertLevel(l))
	}

	return logger, setLevel
}
383703
func NewGenerator(pkg, target string) (*Generator, error) {
	var err error
	if pkg == "" || pkg[0] == '.' {
		pkg, err = filepath.Abs(filepath.Clean(pkg))
		if err != nil {
			return nil, err
		}
		pkg = gogenutil.StripGopath(pkg)
	}
	p, err := importer.Default().Import(pkg)
	if err != nil {
		return nil, err
	}
	obj := p.Scope().Lookup(target)
	if obj == nil {
		return nil, fmt.Errorf("struct %s missing", target)
	}
	if _, ok := obj.Type().Underlying().(*types.Struct); !ok {
		return nil, fmt.Errorf("%s should be an struct, was %s", target, obj.Type().Underlying())
	}
	return &Generator{
		targetName: target,
		pkg:        p,
		target:     obj.Type().Underlying().(*types.Struct),
	}, nil
}
688553
func NewLoader(chainParams *chaincfg.Params, dbDirPath string,
	recoveryWindow uint32) *Loader {

	return &Loader{
		chainParams:    chainParams,
		dbDirPath:      dbDirPath,
		recoveryWindow: recoveryWindow,
	}
}
320759
func (p *PeriodicDispatch) nextLaunch() (*structs.Job, time.Time) {
	// If there is nothing wait for an update.
	p.l.RLock()
	defer p.l.RUnlock()
	if p.heap.Length() == 0 {
		return nil, time.Time{}
	}

	nextJob := p.heap.Peek()
	if nextJob == nil {
		return nil, time.Time{}
	}

	return nextJob.job, nextJob.next
}
567280
func (t *Config) NewRenderer(manager ...driver.Manager) driver.Driver {
	tmplDir := t.TmplDir
	if len(t.Theme) > 0 {
		tmplDir = filepath.Join(tmplDir, t.Theme)
	}
	renderer := New(t.Engine, tmplDir)
	renderer.Init()
	if len(manager) > 0 {
		renderer.SetManager(manager[0])
	}
	renderer.SetContentProcessor(t.Parser())
	if t.StaticOptions != nil {
		st := t.NewStatic()
		renderer.SetFuncMap(func() map[string]interface{} {
			return st.Register(nil)
		})
		absTmplPath, err := filepath.Abs(tmplDir)
		var absFilePath string
		if err == nil {
			absFilePath, err = filepath.Abs(t.StaticOptions.Root)
		}
		if err == nil {
			if strings.HasPrefix(absFilePath, absTmplPath) {
				//如果静态文件在模板的子文件夹时，监控模板时判断静态文件更改
				renderer.MonitorEvent(st.OnUpdate())
			}
		}
	}
	return renderer
}
740391
func NewFsLoader(fs utilfs.Filesystem, kubeletFile string) (Loader, error) {
	_, kubeletCodecs, err := kubeletscheme.NewSchemeAndCodecs()
	if err != nil {
		return nil, err
	}

	return &fsLoader{
		fs:            fs,
		kubeletCodecs: kubeletCodecs,
		kubeletFile:   kubeletFile,
	}, nil
}
810616
func NewLogger(config Config) (Logger, error) {
	switch config.Name {
	case Console:
		return NewConsoleLogger(config)
	case Syslog:
		return NewSysLogger(config)
	case UDPLog:
		return NewUDPLogger(config)
	}
	return nil, fmt.Errorf("unknown logger: %v", config)
}
823569
func (g *GeneratorArgs) NewBuilder() (*parser.Builder, error) {
	b := parser.New()
	// Ignore all auto-generated files.
	b.AddBuildTags(g.GeneratedBuildTag)

	for _, d := range g.InputDirs {
		var err error
		if strings.HasSuffix(d, "/...") {
			err = b.AddDirRecursive(strings.TrimSuffix(d, "/..."))
		} else {
			err = b.AddDir(d)
		}
		if err != nil {
			return nil, fmt.Errorf("unable to add directory %q: %v", d, err)
		}
	}
	return b, nil
}
891879
func NewGenerator(pkg, iface string) (*Generator, error) {
	p, err := importer.DefaultWithTestFiles().Import(pkg)
	if err != nil {
		return nil, err
	}
	obj := p.Scope().Lookup(iface)
	if obj == nil {
		return nil, fmt.Errorf("interface %s missing", iface)
	}
	if !types.IsInterface(obj.Type()) {
		return nil, fmt.Errorf("%s should be an interface, was %s", iface, obj.Type())
	}
	g := &Generator{
		ifaceName: iface,
		pkg:       p,
		iface:     obj.Type().Underlying().(*types.Interface).Complete(),
	}
	g.SetTemplate(defaultMockTemplate)
	return g, nil
}
500724
func (lr *logRegistry) NewLogger(name string) logging.Logger {
	if existingLogger := lr.getLoggerFromMapping(name); existingLogger != nil {
		panic(fmt.Errorf("logger with name '%s' already exists", name))
	}
	if err := checkLoggerName(name); err != nil {
		panic(err)
	}

	logger := NewLogger(name)

	// set initial logger level
	if lvl, ok := lr.logLevels[name]; ok {
		setLevel(logger, lvl)
	} else {
		setLevel(logger, lr.defaultLevel)
	}

	lr.putLoggerToMapping(logger)

	// add all defined hooks
	for _, hook := range lr.hooks {
		logger.std.AddHook(hook)
	}

	return logger
}
287166
func NewIDGenerator() *IDGenerator {
	g := new(IDGenerator)
	_, err := rand.Read(g.seed[:])
	if err != nil {
		panic(err)
	}
	return g
}
582314
func NewGenerator(o *GeneratorOptions) Generator {
	// TODO(abg): Determine package name from `namespace go` directive.
	namespace := NewNamespace()
	return &generator{
		PackageName:    o.PackageName,
		ImportPath:     o.ImportPath,
		Namespace:      namespace,
		importer:       newImporter(namespace.Child()),
		mangler:        newMangler(),
		thriftImporter: o.Importer,
		fset:           token.NewFileSet(),
		noZap:          o.NoZap,
	}
}