github.com/hashicorp/vault/sdk@v0.11.0/helper/pointerutil/pointer.go (about)

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: MPL-2.0
     3  
     4  package pointerutil
     5  
     6  import (
     7  	"os"
     8  	"time"
     9  
    10  	"github.com/hashicorp/go-secure-stdlib/parseutil"
    11  )
    12  
    13  // StringPtr returns a pointer to a string value
    14  func StringPtr(s string) *string {
    15  	return &s
    16  }
    17  
    18  // BoolPtr returns a pointer to a boolean value
    19  func BoolPtr(b bool) *bool {
    20  	return &b
    21  }
    22  
    23  // TimeDurationPtr returns a pointer to a time duration value
    24  func TimeDurationPtr(duration string) *time.Duration {
    25  	d, _ := parseutil.ParseDurationSecond(duration)
    26  
    27  	return &d
    28  }
    29  
    30  // FileModePtr returns a pointer to the given os.FileMode
    31  func FileModePtr(o os.FileMode) *os.FileMode {
    32  	return &o
    33  }
    34  
    35  // Int64Ptr returns a pointer to an int64 value
    36  func Int64Ptr(i int64) *int64 {
    37  	return &i
    38  }