github.com/inspektor-gadget/inspektor-gadget@v0.28.1/pkg/columns/helpers.go (about) 1 // Copyright 2022-2024 The Inspektor Gadget authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package columns 16 17 import ( 18 "reflect" 19 "strings" 20 ) 21 22 // ToLowerStrings transforms the elements of an array of strings into lowercase. 23 func ToLowerStrings(in []string) []string { 24 for i := range in { 25 in[i] = strings.ToLower(in[i]) 26 } 27 return in 28 } 29 30 func GetWidthFromType(kind reflect.Kind) int { 31 switch kind { 32 default: 33 return 0 34 case reflect.Uint8: 35 return MaxCharsUint8 36 case reflect.Int8: 37 return MaxCharsInt8 38 case reflect.Uint16: 39 return MaxCharsUint16 40 case reflect.Int16: 41 return MaxCharsInt16 42 case reflect.Uint32: 43 return MaxCharsUint32 44 case reflect.Int32: 45 return MaxCharsInt32 46 case reflect.Uint64, reflect.Uint: 47 return MaxCharsUint64 48 case reflect.Int64, reflect.Int: 49 return MaxCharsInt64 50 case reflect.Bool: 51 return MaxCharsBool 52 } 53 }