// NewAssertContext returns an AssertContext with all fields
// which can be generated filled in.
173319
func NewAssertContext(options ...AssertContextConfigOption) AssertContext {
	expectedString := GenerateRandomString()

	serviceAccountFile := os.Getenv(ServiceAccountFileEnv)
	Expect(serviceAccountFile).ToNot(BeEmpty(),
		fmt.Sprintf(ServiceAccountFileMsg, ServiceAccountFileEnv))

	return AssertContext{
		ExpectedString:     expectedString,
		ContentFile:        MakeContentFile(expectedString),
		GCSFileName:        GenerateRandomString(),
		serviceAccountFile: serviceAccountFile,
		options:            options,
		ctx:                context.Background(),
	}
}
561957
func newContext(ctx context.Context, s *Session) context.Context {
	return context.WithValue(ctx, sessionKey{}, s)
}
85393
func NewContext(b *parser.Builder, nameSystems namer.NameSystems, canonicalOrderName string) (*Context, error) {
	universe, err := b.FindTypes()
	if err != nil {
		return nil, err
	}

	c := &Context{
		Namers:   namer.NameSystems{},
		Universe: universe,
		Inputs:   b.FindPackages(),
		FileTypes: map[string]FileType{
			GolangFileType: NewGolangFile(),
		},
		builder: b,
	}

	for name, systemNamer := range nameSystems {
		c.Namers[name] = systemNamer
		if name == canonicalOrderName {
			orderer := namer.Orderer{Namer: systemNamer}
			c.Order = orderer.OrderUniverse(universe)
		}
	}
	return c, nil
}
1368808
func NewContext(ctx context.Context, serialId *big.Int) context.Context {
	var c *Client
	var err error
	if c, err = GetClient(util.BigIntToHex(serialId)); err != nil {
		return ctx
	}
	return context.WithValue(ctx, clientKey{}, c)
}
844075
func (p11w *Pkcs11Wrapper) InitContext() (err error) {

	// check if lib file exists
	if _, err = os.Stat(p11w.Library.Path); os.IsNotExist(err) {
		return
	}

	// try to initialize
	p11w.Context = pkcs11.New(p11w.Library.Path)
	err = p11w.Context.Initialize()
	if err != nil {
		return
	}

	// get library info
	p11w.Library.Info, err = p11w.Context.GetInfo()

	return

}
871235
func NewContext(app *App, w http.ResponseWriter, r *http.Request) *Context {
	ctx := Context{
		app: app,
		Req: r,
		Res: &Response{w: w, rw: w, handlerHeader: w.Header()},

		Host:   r.Host,
		Method: r.Method,
		Path:   r.URL.Path,

		Cookies: cookie.New(w, r, app.keys...),
		kv:      make(map[interface{}]interface{}),
	}

	if app.serverName != "" {
		ctx.SetHeader(HeaderServer, app.serverName)
	}

	if app.timeout <= 0 {
		ctx.ctx, ctx.cancelCtx = context.WithCancel(r.Context())
	} else {
		ctx.ctx, ctx.cancelCtx = context.WithTimeout(r.Context(), app.timeout)
	}
	ctx.ctx = context.WithValue(ctx.ctx, isContext, isContext)

	if app.withContext != nil {
		ctx._ctx = app.withContext(r.WithContext(ctx.ctx))
		if ctx._ctx.Value(isContext) == nil {
			panic(Err.WithMsg("the context is not created from gear.Context"))
		}
	} else {
		ctx._ctx = ctx.ctx
	}
	return &ctx
}
762803
func NewContext(d Device, flags ContextFlags) *Ctx {
	var cctx C.CUcontext
	err := result(C.cuCtxCreate(&cctx, C.uint(flags), C.CUdevice(d)))
	if err != nil {
		panic(err)
	}
	ctx := newContext(makeContext(cctx))
	ctx.device = d
	ctx.flags = flags

	errChan := make(chan error)
	go ctx.Run(errChan)
	if err := <-errChan; err != nil {
		panic(err)
	}

	return ctx
}
142218
func NewContext(req engine.Request, res engine.Response, e *Echo) Context {
	c := &xContext{
		Validator:   DefaultNopValidate,
		Translator:  DefaultNopTranslate,
		Emitter:     emitter.DefaultCondEmitter,
		Transaction: DefaultNopTransaction,
		context:     context.Background(),
		request:     req,
		response:    res,
		echo:        e,
		pvalues:     make([]string, *e.maxParam),
		store:       make(Store),
		handler:     NotFoundHandler,
		funcs:       make(map[string]interface{}),
		sessioner:   DefaultSession,
	}
	c.cookier = NewCookier(c)
	c.dataEngine = NewData(c)
	return c
}
993643
func NewContext() context {
	var ctx context
	ctx.values = make(map[string]map[string]string)

	return ctx
}
729613
func NewContext(bashpath string, debug bool) (*Context, error) {
	executable, err := osext.Executable()
	if err != nil {
		return nil, err
	}
	return &Context{
		Debug:    debug,
		BashPath: bashpath,
		SelfPath: executable,
		Stdin:    os.Stdin,
		Stdout:   os.Stdout,
		Stderr:   os.Stderr,
		scripts:  make([][]byte, 0),
		vars:     make([]string, 0),
		funcs:    make(map[string]func([]string)),
	}, nil
}
238697
func NewContextWriter(ctx context.Context, w io.Writer) io.Writer {
	return ctxio.NewWriter(ctx, w)
}
918347
func NewContextWith(data map[string]interface{}) *Context {
	c := NewContext()
	c.data = data
	return c
}
259509
func NewContext(ctx context.Context) context.Context {
	u, _ := uuid.NewV4()
	uStr := u.String()
	ctx = context.WithValue(ctx, requestUuidKey, uStr)
	ctx = context.WithValue(ctx, processPidKey, strconv.Itoa(os.Getpid()))
	ctx = context.WithValue(ctx, additionnalLogElementsKey, make(map[interface{}]interface{}))
	return ctx
}
711802
func NewContext(ctx context.Context, idt *Identity) context.Context {
	return context.WithValue(ctx, idtKey, idt)
}
631389
func NewContextComponentName(ctx context.Context, componentName string) context.Context {
	return context.WithValue(ctx, ctxKeyComponent, componentName)
}
1217986
func NewContext(ctx context.Context, v *LoggerMeta) context.Context {
	if v == nil {
		return ctx
	}

	return context.WithValue(ctx, loggerMetaKey, v)
}
480218
func NewContext(p Project, opts ...func(*Context) error) (*Context, error) {
	envOr := func(key, def string) string {
		if v := os.Getenv(key); v != "" {
			return v
		}
		return def
	}

	defaults := []func(*Context) error{
		// must come before GcToolchain()
		func(c *Context) error {
			c.gohostos = runtime.GOOS
			c.gohostarch = runtime.GOARCH
			c.gotargetos = envOr("GOOS", runtime.GOOS)
			c.gotargetarch = envOr("GOARCH", runtime.GOARCH)
			c.debug = func(string, ...interface{}) {} // null logger
			return nil
		},
		GcToolchain(),
	}
	workdir, err := ioutil.TempDir("", "gb")
	if err != nil {
		return nil, err
	}

	ctx := Context{
		Project:   p,
		workdir:   workdir,
		buildmode: "exe",
		pkgs:      make(map[string]*Package),
	}

	for _, opt := range append(defaults, opts...) {
		err := opt(&ctx)
		if err != nil {
			return nil, err
		}
	}

	// sort build tags to ensure the ctxSring and Suffix is stable
	sort.Strings(ctx.buildtags)

	bc := build.Default
	bc.GOOS = ctx.gotargetos
	bc.GOARCH = ctx.gotargetarch
	bc.CgoEnabled = cgoEnabled(ctx.gohostos, ctx.gohostarch, ctx.gotargetos, ctx.gotargetarch)
	bc.ReleaseTags = releaseTags
	bc.BuildTags = ctx.buildtags

	i, err := buildImporter(&bc, &ctx)
	if err != nil {
		return nil, err
	}

	ctx.importer = i

	// C and unsafe are fake packages synthesised by the compiler.
	// Insert fake packages into the package cache.
	for _, name := range []string{"C", "unsafe"} {
		pkg, err := ctx.newPackage(&build.Package{
			Name:       name,
			ImportPath: name,
			Dir:        name, // fake, but helps diagnostics
			Goroot:     true,
		})
		if err != nil {
			return nil, err
		}
		pkg.NotStale = true
		ctx.pkgs[pkg.ImportPath] = pkg
	}

	return &ctx, err
}