Adding upstream version 3.10.8.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
37e9b6d587
commit
03bfe4079e
356 changed files with 28857 additions and 0 deletions
29
util/convert.go
Normal file
29
util/convert.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
// Copyright Earl Warren <contact@earl-warren.org>
|
||||
// Copyright Loïc Dachary <loic@dachary.org>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package util
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func ConvertMap[FromType, ToType any](objects []FromType, converter func(f FromType) ToType) []ToType {
|
||||
converted := make([]ToType, 0, len(objects))
|
||||
for _, object := range objects {
|
||||
converted = append(converted, converter(object))
|
||||
}
|
||||
return converted
|
||||
}
|
||||
|
||||
func ParseInt(s string) int64 {
|
||||
if s == "" {
|
||||
return 0
|
||||
}
|
||||
v, err := strconv.ParseInt(s, 10, 64)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("%s %w", s, err))
|
||||
}
|
||||
return v
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue