You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

github.com/sumitthorat/go-math

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/sumitthorat/go-math

v0.2.0
Source
Go
Version published
Created
Source

Go-Math Package

A simple Go package that provides arithmetic operations.

Installation

go get github.com/sumitthorat/go-math

Usage

You can use the package in two ways:

package main

import (
    "fmt"
    "github.com/sumitthorat/go-math"
)

func main() {
    // Create a new Arithmetic instance
    a := math.New()
    
    // Use the Add method
    sum := a.Add([]int{1, 2, 3, 4, 5})
    fmt.Println("Sum:", sum)
    
    // Use the Multiply method
    product := a.Multiply([]int{1, 2, 3, 4, 5})
    fmt.Println("Product:", product)
}

Option 2: Using the arithmetic package directly

package main

import (
    "fmt"
    "github.com/sumitthorat/go-math/pkg/arithmetic"
)

func main() {
    // Create a new Arithmetic instance
    a := &arithmetic.Arithmetic{}
    
    // Use the Add method
    sum := a.Add([]int{1, 2, 3, 4, 5})
    fmt.Println("Sum:", sum)
    
    // Use the Multiply method
    product := a.Multiply([]int{1, 2, 3, 4, 5})
    fmt.Println("Product:", product)
}

License

MIT

FAQs

Package last updated on 10 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts