gitlab.com/evatix-go/core@v1.3.55/converters/StringToInteger.go (about)

     1  package converters
     2  
     3  import (
     4  	"strconv"
     5  
     6  	"gitlab.com/evatix-go/core/constants"
     7  	"gitlab.com/evatix-go/core/errcore"
     8  )
     9  
    10  func StringToInteger(
    11  	input string,
    12  ) (value int, err error) {
    13  	value, err2 := strconv.Atoi(input)
    14  
    15  	if err2 != nil {
    16  		reference := input +
    17  			constants.NewLineUnix +
    18  			err2.Error()
    19  
    20  		return constants.Zero, errcore.ParsingFailedType.Error(
    21  			errcore.FailedToConvertType.String(),
    22  			reference)
    23  	}
    24  
    25  	return value, err
    26  }