nicolito128 / go-calculator

A calculator module written in Go.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Go Calculator

A simple console calculator written in Go.

It accept the following operations: + (addition), - (subtraction), * (product) and / (division). Also, you can use parenthesis association ().

How to use

Import the module:

    import "github.com/nicolito128/go-calculator"

Now you can use the Resolve function. For example:

    package main

    import (
        "fmt"

        "github.com/nicolito128/go-calculator"
    )

    func main() {
        result, err := calculator.Resolve("100 + ((2 / 4) * 2 * 3)")
        if err != nil {
            panic("Oh no! An error accured.")
        }
        
        fmt.Println(result)
    }

About

A calculator module written in Go.

License:MIT License


Languages

Language:Go 97.9%Language:Makefile 2.1%