mirror of
https://github.com/Threnklyn/advent-of-code-go.git
synced 2026-05-18 19:13:27 +02:00
updated cast panic to echo arg type
This commit is contained in:
+6
-3
@@ -3,7 +3,10 @@ package cast
|
|||||||
// Suite of casting functions to speed up solutions
|
// Suite of casting functions to speed up solutions
|
||||||
// This is NOT idiomatic Go... but AOC isn't about that...
|
// This is NOT idiomatic Go... but AOC isn't about that...
|
||||||
|
|
||||||
import "strconv"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
// ToInt will case a given arg into an int type.
|
// ToInt will case a given arg into an int type.
|
||||||
// Supported types are:
|
// Supported types are:
|
||||||
@@ -18,7 +21,7 @@ func ToInt(arg interface{}) int {
|
|||||||
panic("error converting string to int " + err.Error())
|
panic("error converting string to int " + err.Error())
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
panic("unhandled type for int casting")
|
panic(fmt.Sprintf("unhandled type for int casting %T", arg))
|
||||||
}
|
}
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
@@ -39,7 +42,7 @@ func ToString(arg interface{}) string {
|
|||||||
case rune:
|
case rune:
|
||||||
str = string(arg.(rune))
|
str = string(arg.(rune))
|
||||||
default:
|
default:
|
||||||
panic("unhandled type for string casting")
|
panic(fmt.Sprintf("unhandled type for string casting %T", arg))
|
||||||
}
|
}
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user