github.com/blend/go-sdk@v1.20220411.3/configutil/duration_ptr.go (about) 1 /* 2 3 Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file. 5 6 */ 7 8 package configutil 9 10 import ( 11 "context" 12 "time" 13 ) 14 15 // DurationPtr returns a DurationSource for a given duration pointer. 16 func DurationPtr(value *time.Duration) DurationSource { 17 return DurationPtrSource{Value: value} 18 } 19 20 var ( 21 _ DurationSource = (*DurationPtrSource)(nil) 22 ) 23 24 // DurationPtrSource is a DurationSource that wraps a duration pointer. 25 type DurationPtrSource struct { 26 Value *time.Duration 27 } 28 29 // Duration implements DurationSource. 30 func (dps DurationPtrSource) Duration(_ context.Context) (*time.Duration, error) { 31 return dps.Value, nil 32 }