github.com/suntong/easygen@v5.3.0+incompatible/egCal/EgCal.go (about)

     1  ////////////////////////////////////////////////////////////////////////////
     2  // Package: egCal
     3  // Purpose: easygen generic calculation functionalities
     4  // Authors: Tong Sun (c) 2017, All rights reserved
     5  ////////////////////////////////////////////////////////////////////////////
     6  
     7  /*
     8  
     9  Package egCal provides generic calculation functionalities.
    10  
    11  egCal provides the generic calculation functionalities from
    12  
    13  consul template functions
    14  https://github.com/hashicorp/consul-template / template_functions.go
    15  
    16  */
    17  package egCal
    18  
    19  import (
    20  	"text/template"
    21  
    22  	"github.com/go-easygen/easygen"
    23  )
    24  
    25  ////////////////////////////////////////////////////////////////////////////
    26  // Constant and data type/structure definitions
    27  
    28  // EgCal -- EasyGen Calculation
    29  /*
    30  
    31    add is template function for Add
    32    subtract is template function for Subtract
    33    multiply is template function for Multiply
    34    divide is template function for Divide
    35  
    36  */
    37  type EgCal struct {
    38  	*easygen.EgBase
    39  }
    40  
    41  var egFuncMap = easygen.FuncMap{
    42  	"add":      Add,
    43  	"subtract": Subtract,
    44  	"multiply": Multiply,
    45  	"divide":   Divide,
    46  }
    47  
    48  ////////////////////////////////////////////////////////////////////////////
    49  // Function definitions
    50  
    51  // FuncDefs returns the custom definition mapping for this specific package.
    52  func FuncDefs() template.FuncMap {
    53  	return template.FuncMap(egFuncMap)
    54  }