replace log.Fatal with cobra.CheckErr
This commit is contained in:
@@ -18,7 +18,6 @@ package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"math/big"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
@@ -45,7 +44,7 @@ func count(tpf []string) map[string]*big.Int {
|
||||
func primitiveRoot(cmd *cobra.Command, args []string) {
|
||||
m, ok := new(big.Int).SetString(modulus, 10)
|
||||
if !ok {
|
||||
log.Fatal("invalid input " + modulus)
|
||||
cobra.CheckErr("invalid input " + modulus)
|
||||
}
|
||||
|
||||
factors := count(tpf)
|
||||
@@ -55,12 +54,12 @@ func primitiveRoot(cmd *cobra.Command, args []string) {
|
||||
if len(factors) == 0 {
|
||||
root, err = lib.PrimitiveRoot(m)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
cobra.CheckErr(err)
|
||||
}
|
||||
} else {
|
||||
root, err = lib.PrimitiveRootFast(m, factors)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
cobra.CheckErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user