egCal

package
v5.3.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2023 License: MIT, MPL-2.0 Imports: 4 Imported by: 11

Documentation

Overview

Package egCal provides generic calculation functionalities.

egCal provides the generic calculation functionalities from

consul template functions https://github.com/hashicorp/consul-template / template_functions.go

Example

for standalone test, change package to `main` and the next func def to, func main() {

package main

import (
	"os"

	"github.com/go-easygen/easygen"
	"github.com/go-easygen/easygen/egCal"
	"github.com/go-easygen/easygen/egVar"
)

// for standalone test, change package to `main` and the next func def to,
// func main() {
func main() {
	tmpl0 := easygen.NewTemplate().Customize()
	tmpl := tmpl0.Funcs(easygen.FuncDefs()).Funcs(egVar.FuncDefs()).Funcs(egCal.FuncDefs())
	err := easygen.Process0(tmpl, os.Stdout,
		"{{.Name}}: {{clk2uc .Name}} {{clk2ss .Name}}\n"+
			"Cal: {{add 2 3}}, {{multiply 2 3}}, {{subtract 9 2}}, {{divide 24 3}}\n",
		"../test/var0")

	if err != nil {
		panic(err)
	}
}

// To show the full code in GoDoc
type dummy struct {
}
Output:

some-init-method: SomeInitMethod SOME_INIT_METHOD
Cal: 5, 6, 7, 8

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(a, b interface{}) (interface{}, error)

Add returns the sum of a and b.

func Divide

func Divide(a, b interface{}) (interface{}, error)

Divide returns the division of b from a.

func FuncDefs

func FuncDefs() template.FuncMap

FuncDefs returns the custom definition mapping for this specific package.

func Multiply

func Multiply(a, b interface{}) (interface{}, error)

Multiply returns the product of a and b.

func Subtract

func Subtract(a, b interface{}) (interface{}, error)

Subtract returns the difference of b from a.

Types

type EgCal

type EgCal struct {
	*easygen.EgBase
}

EgCal -- EasyGen Calculation

add is template function for Add
subtract is template function for Subtract
multiply is template function for Multiply
divide is template function for Divide

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL