// newCtor creates a new ctor for the return type of constructor.
349125
func newCtor(constructor reflect.Type, v reflect.Value) *ctor {
	if constructor.Kind() != reflect.Func || constructor.IsVariadic() {
		return nil
	}
	numOut := constructor.NumOut()
	if numOut == 0 || numOut > 2 || (numOut == 2 && constructor.Out(1) != terror) {
		return nil
	}
	outType := constructor.Out(0)
	numIn := constructor.NumIn()
	inTypes := make([]reflect.Type, numIn)
	for i := range inTypes {
		inTypes[i] = constructor.In(i)
	}
	construct := func(in []reflect.Value) (reflect.Value, error) {
		for i, arg := range in {
			if arg.IsValid() {
				continue
			}
			const format = "unable to create arg %d (%s) of %s constructor"
			return reflect.Value{}, fmt.Errorf(format, i, inTypes[i], outType)
		}
		out := v.Call(in)
		var err error
		if len(out) == 2 && !out[1].IsNil() {
			err = out[1].Interface().(error)
		}
		return out[0], err
	}

	return &ctor{
		funcType:     constructor,
		outType:      outType,
		inTypes:      inTypes,
		construct:    construct,
		errChan:      make(chan error),
		onceManifest: &sync.Once{},
		onceResult:   &sync.Once{},
	}
}
1037288
func NewDecoder(r io.Reader) *Decoder {
	return &Decoder{r, defaultDelimiter, defaultEscape, false, false}
}
18463
func NewDecoder(r io.Reader) *Decoder {
	decoder := &Decoder{
		r: bufio.NewReader(r),
	}

	return decoder
}
669162
func NewLoader(ctx context.Context, logger log.Logger, version string, debugContext *web.HeaderCtxFlag, itemFlagger *dpsink.ItemFlagger, ctxdims *log.CtxDimensions, next web.NextConstructor) *Loader {
	sfxL := &signalFxLoader{
		logger:        logger,
		rootContext:   ctx,
		versionString: version,
		itemFlagger:   itemFlagger,
		ctxdims:       ctxdims,
		httpChain:     next,
		debugContext:  debugContext,
	}
	return &Loader{
		forwarders: map[string]forwarderLoader{
			"signalfx-json": sfxL,
			"signalfx":      sfxL,
			"carbon": &carbonLoader{
				logger: logger,
			},
			"csv": &csvLoader{},
		},
		listeners: map[string]listenerLoader{
			"signalfx": sfxL,
			"carbon": &carbonLoader{
				logger: logger,
			},
			"collectd": &collectdLoader{
				rootContext:  ctx,
				debugContext: debugContext,
				logger:       logger,
				httpChain:    next,
			},
			"prometheus": &prometheusLoader{
				rootContext:  ctx,
				debugContext: debugContext,
				logger:       logger,
				httpChain:    next,
			},
			"wavefront": &wavefrontLoader{
				logger: logger,
			},
		},
		listenWrappers: []listenSinkWrapper{
			&dimensionListenerSink{},
		},
	}
}
687342
func newReader(ctx context.Context, d *dispatcher, r io.ReadCloser) *reader {
	return &reader{
		ctx: ctx,
		d:   d,
		r:   r,
	}
}
468984
func (fw *Framework) NewConnector(ctx context.Context, servers func() ([]srvcache.Server, error), name string, logger *log.Entry) (conn Connector, err error) {
	if name == "" {
		name = fw.Config.Identity
	}

	conn = &Connection{
		name:              name,
		servers:           servers,
		logger:            logger.WithField("connection", name),
		choria:            fw,
		config:            fw.Config,
		subscriptions:     make(map[string]*nats.Subscription),
		chanSubscriptions: make(map[string]*channelSubscription),
		outbox:            make(chan *nats.Msg, 1000),
	}

	err = conn.Connect(ctx)

	return conn, err
}
162161
func NewDecoder(r io.Reader) goa.Decoder {
	return codec.NewDecoder(r, &Handle)
}
1015646
func NewReader(ctx context.Context, r io.Reader) *Reader {
	return &Reader{
		ctx:    ctx,
		reader: r,
	}
}
367859
func NewReader(config ReaderConfig) (*Reader, error) {
	if err := config.validate(); err != nil {
		return nil, errors.Trace(err)
	}
	r := &Reader{config: config}
	return r, nil
}
792342
func NewBuilder(mapper meta.RESTMapper, typer runtime.ObjectTyper, clientMapper ClientMapper, decoder runtime.Decoder) *Builder {
	return &Builder{
		mapper:        &Mapper{typer, mapper, clientMapper, decoder},
		requireObject: true,
	}
}
1109886
func NewRedirector(login SSHLogin) (*Redirector, error) {
	//clt, proxyURL, err := initClient(login.ProxyAddr, login.Insecure, login.Pool)
	//if err != nil {
	//	return nil, trace.Wrap(err)
	//}

	clt, err := NewCredentialsClient(login.ProxyAddr, login.Insecure, login.Pool)
	if err != nil {
		return nil, trace.Wrap(err)
	}

	// Create secret key that will be sent with the request and then used the
	// decrypt the response from the server.
	key, err := secret.NewKey()
	if err != nil {
		return nil, trace.Wrap(err)
	}

	context, cancel := context.WithCancel(login.Context)
	rd := &Redirector{
		context:     context,
		cancel:      cancel,
		proxyClient: clt.clt,
		proxyURL:    clt.url,
		SSHLogin:    login,
		mux:         http.NewServeMux(),
		key:         key,
		shortPath:   "/" + uuid.New(),
		responseC:   make(chan *auth.SSHLoginResponse, 1),
		errorC:      make(chan error, 1),
	}

	// callback is a callback URL communicated to the Teleport proxy,
	// after SAML/OIDC login, the teleport will redirect user's browser
	// to this laptop-local URL
	rd.mux.Handle("/callback", rd.wrapCallback(rd.callback))
	// short path is a link-shortener style URL
	// that will redirect to the Teleport-Proxy supplied address
	rd.mux.HandleFunc(rd.shortPath, func(w http.ResponseWriter, r *http.Request) {
		http.Redirect(w, r, rd.redirectURL.Value(), http.StatusFound)
	})
	return rd, nil
}
330157
func NewDecoder(r io.Reader, h Handle) *Decoder {
	d := newDecoder(h)
	d.Reset(r)
	return d
}
895983
func NewOperator(token int, lexeme string) (Operator, error) {
	switch token {
	case parser.EqualityToken:
		return equalityOperator, nil
	case parser.LeftDipleToken:
		return lessThanOperator, nil
	case parser.RightDipleToken:
		return greaterThanOperator, nil
	case parser.LessOrEqualToken:
		return lessOrEqualOperator, nil
	case parser.GreaterOrEqualToken:
		return greaterOrEqualOperator, nil
	}

	return nil, fmt.Errorf("Operator '%s' does not exist", lexeme)
}
60631
func NewErr(r *http.Response) error {
	if r.StatusCode >= http.StatusOK && r.StatusCode < http.StatusMultipleChoices {
		return nil
	}

	switch r.StatusCode {
	case http.StatusUnauthorized:
		return transport.ErrAuthenticationRequired
	case http.StatusForbidden:
		return transport.ErrAuthorizationFailed
	case http.StatusNotFound:
		return transport.ErrRepositoryNotFound
	}

	return plumbing.NewUnexpectedError(&Err{r})
}
1283820
func NewAttr(name, val string) *Attribute {
	a := Attribute{Name: name, Value: val}
	return &a
}
82895
func NewLoginUser(ctx *middleware.Context, handler LoginUserHandler) *LoginUser {
	return &LoginUser{Context: ctx, Handler: handler}
}
18533
func (c *Config) NewIterator() (*ConfigIterator, error) {
	iter := &ConfigIterator{cfg: c}

	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	ret := C.git_config_iterator_new(&iter.ptr, c.ptr)
	if ret < 0 {
		return nil, MakeGitError(ret)
	}

	return iter, nil
}