Documentation ¶
Index ¶
- func GMin[T constraints.Ordered](x, y T) T
- func JSONUnmarshal[T any](data []byte, dst *T) error
- func SumFloats(m map[string]float64) float64
- func SumInts(m map[string]int64) int64
- func SumIntsOrFloats[K comparable, V int64 | float64](m map[K]V) V
- func SumNumbers[K comparable, V Number](m map[K]V) V
- type Number
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GMin ¶
func GMin[T constraints.Ordered](x, y T) T
GMin is a generic min(a, b) function. using golang.org/x/exp/constraints package
Actual definition of constraints.Ordered as follows ``` type Ordered interface { Integer | Float | ~string } ```
func JSONUnmarshal ¶
JSONUnmarshal は、型パラメータ T を定義し引数を dst *T とすることで、T のポインタを使用することを呼び出し側に強制しています。 従来はこのような引数は interface{} を使って定義されておりどのような型でも渡すことができていたため、 ポインタでない型を渡してしまうことによる実行時エラーの懸念がありました。
func SumIntsOrFloats ¶
func SumIntsOrFloats[K comparable, V int64 | float64](m map[K]V) V
SumIntsOrFloats sums the values of map m. It supports both int64 and float64 as types for map values.
func SumNumbers ¶
func SumNumbers[K comparable, V Number](m map[K]V) V
SumNumbers sums the values of map m. Its supports both integers and floats as map values.
Types ¶
Click to show internal directories.
Click to hide internal directories.