INNER CODE UNIT · Go

MustGetUser

arp242/goatcounter · context.go:146

func MustGetUser(ctx context.Context) *User {
	u := GetUser(ctx)
	if u == nil {
		panic("MustGetUser: no user on context")
	}
	return u
}

// NewContext creates a new context with all values set.
func NewContext(ctx context.Context, db zdb.DB) context.Context {
	n := zdb.WithDB(context.Background(), db)
	n = geo.With(n, geo.Get(ctx))
	n = NewCache(n)
	n = NewConfig(n)
	m := blackmail.Get(ctx)
	if m != nil {
		m = blackmail.NewWriter(os.Stderr)
	}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…