Skip to content

Instantly share code, notes, and snippets.

@Cibernomadas Cibernomadas/main.go
Created May 20, 2018

Embed
What would you like to do?
func validaArgumentosInt(args []string) (int, int, error) {
var a, b int
if len(args) == 2 {
a, err := strconv.Atoi(args[0])
if err != nil {
return a, b, err
}
b, err := strconv.Atoi(args[1])
if err != nil {
return a, b, err
}
return a, b, err
}
return a, b, fmt.Errorf("Número de argumentos no valido")
}
func validaArgumentosFloat(args []string) (float64, float64, error) {
var a, b float64
if len(args) == 2 {
a, err := strconv.ParseFloat(args[0], 64)
if err != nil {
return a, b, err
}
b, err := strconv.ParseFloat(args[1], 64)
if err != nil {
return a, b, err
}
return a, b, err
}
return a, b, fmt.Errorf("Número de argumentos no valido")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.