Files
wails/test/runtime/calc.go
Travis McLane 25a157e661 Squashed 'v2/' content from commit 7d8960e
git-subtree-dir: v2
git-subtree-split: 7d8960e87431924f5705df4c777758a0eb32e145
2020-09-01 19:34:51 -05:00

45 lines
664 B
Go

package main
import (
"fmt"
wails "github.com/leaanthony/wailsv2/v2"
)
// Calc is a calculator
type Calc struct {
name string
runtime *wails.Runtime
}
func newCalc(name string) *Calc {
return &Calc{
name: name,
}
}
// Name will return the name of the calculator
func (c *Calc) Name() string {
return c.name
}
// Add will add the 2 given integers and return the result
func (c *Calc) Add(a, b int) int {
return a + b
}
func (c *Calc) unexported() int {
return 1
}
func (c *Calc) Mult(a, b int) int {
return a * b
}
func (c *Calc) Divide(a, b int) (int, error) {
if b == 0 {
return -1, fmt.Errorf("divide by zero")
}
return a / b, nil
}