Documentation
¶
Overview ¶
Copyright © 2024 NAME HERE <EMAIL ADDRESS>
Copyright © 2024 NAME HERE <EMAIL ADDRESS>
Copyright © 2024 NAME HERE <EMAIL ADDRESS>
Copyright © 2024 NAME HERE <EMAIL ADDRESS>
Copyright © 2024 NAME HERE <EMAIL ADDRESS>
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var AdditionCmd = &cobra.Command{ Use: "Addition", Short: "Performs the addition operation for two numbers", Long: ` Performs the addition operation for two numbers.`, Run: func(cmd *cobra.Command, args []string) { fmt.Println("Addition called") if len(args) != 2 { fmt.Println("Error: Please provide two numbers") } var a, b int var err error a, err = strconv.Atoi(args[0]) if err != nil { fmt.Println("Error: Invalid input for the first number.") return } b, err = strconv.Atoi(args[1]) if err != nil { fmt.Println("Error: Invalid input for the second number.") return } result := a + b fmt.Printf("The result is %d\n", result) }, }
AdditionCmd represents the Addition command
View Source
var DivisionCmd = &cobra.Command{ Use: "Division", Short: "Performs the division operation for two numbers", Long: "Performs the division operation for two numbers.", Run: func(cmd *cobra.Command, args []string) { fmt.Println("Division called") var a, b int var err error if len(args) != 2 { fmt.Println("Error : Please provide two numbers ") } a, err = strconv.Atoi(args[0]) if err != nil { fmt.Println("Error : Invalid input for the first number. ") return } b, err = strconv.Atoi(args[1]) if err != nil { fmt.Println("Error : Invalid input for the second number. ") } result := a / b fmt.Printf("The result is %d\n", result) }, }
DivisionCmd represents the Division command
View Source
var MultiplicationCmd = &cobra.Command{ Use: "Multiplication", Short: "Performs the multiplication operation for two numbers", Long: "Performs the multiplication operation for two numbers.", Run: func(cmd *cobra.Command, args []string) { fmt.Println("Multiplication called") var a, b int var err error if len(args) != 2 { fmt.Println("Error : Please provide two numbers ") } a, err = strconv.Atoi(args[0]) if err != nil { fmt.Println("Error : Invalid input for the first number. ") return } b, err = strconv.Atoi(args[1]) if err != nil { fmt.Println("Error : Invalid input for the second number. ") } result := a * b fmt.Printf("The result is %d\n", result) }, }
MultiplicationCmd represents the Multiplication command
View Source
var SubtractionCmd = &cobra.Command{ Use: "Subtraction", Short: "Performs the subtraction operation for two numbers", Long: "Performs the subtraction operation for two numbers.", Run: func(cmd *cobra.Command, args []string) { fmt.Println("Subtraction called") var a, b int var err error if len(args) != 2 { fmt.Println("Error : Please provide two numbers ") } a, err = strconv.Atoi(args[0]) if err != nil { fmt.Println("Error : Invalid input for the first number. ") return } b, err = strconv.Atoi(args[1]) if err != nil { fmt.Println("Error : Invalid input for the second number. ") } result := a / b fmt.Printf("The result is %d\n", result) }, }
SubtractionCmd represents the Subtraction command
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.