github.com/blend/go-sdk@v1.20220411.3/configutil/int.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 "context"
    11  
    12  var (
    13  	_ IntSource = (*Int)(nil)
    14  )
    15  
    16  // Int implements value provider.
    17  //
    18  // Note: Int treats 0 as unset, if 0 is a valid value you must use configutil.IntPtr.
    19  type Int int
    20  
    21  // Int returns the value for a constant.
    22  func (i Int) Int(_ context.Context) (*int, error) {
    23  	if i > 0 {
    24  		value := int(i)
    25  		return &value, nil
    26  	}
    27  	return nil, nil
    28  }