mirror of
https://gitee.com/johng/gf.git
synced 2024-12-02 04:07:47 +08:00
add fnction MustSet/MusetSetMap for package gsession
This commit is contained in:
parent
40225c5352
commit
77422f71f7
@ -14,6 +14,16 @@ type TracerProvider struct {
|
||||
*sdkTrace.TracerProvider
|
||||
}
|
||||
|
||||
// New returns a new and configured TracerProvider, which has no SpanProcessor.
|
||||
//
|
||||
// In default the returned TracerProvider is configured with:
|
||||
// - a ParentBased(AlwaysSample) Sampler
|
||||
// - a unix nano timestamp and random umber based IDGenerator
|
||||
// - the resource.Default() Resource
|
||||
// - the default SpanLimits.
|
||||
//
|
||||
// The passed opts are used to override these default values and configure the
|
||||
// returned TracerProvider appropriately.
|
||||
func New() *TracerProvider {
|
||||
return &TracerProvider{
|
||||
TracerProvider: sdkTrace.NewTracerProvider(
|
||||
|
@ -306,6 +306,22 @@ func (s *Session) MustGet(key string, def ...interface{}) *gvar.Var {
|
||||
return v
|
||||
}
|
||||
|
||||
// MustSet performs as function Set, but it panics if any error occurs.
|
||||
func (s *Session) MustSet(key string, value interface{}) {
|
||||
err := s.Set(key, value)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// MustSetMap performs as function SetMap, but it panics if any error occurs.
|
||||
func (s *Session) MustSetMap(data map[string]interface{}) {
|
||||
err := s.SetMap(data)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// MustContains performs as function Contains, but it panics if any error occurs.
|
||||
func (s *Session) MustContains(key string) bool {
|
||||
b, err := s.Contains(key)
|
||||
|
Loading…
Reference in New Issue
Block a user