...

Source file src/github.com/jedib0t/go-pretty/v6/table/util.go

Documentation: github.com/jedib0t/go-pretty/v6/table

     1  package table
     2  
     3  import (
     4  	"reflect"
     5  )
     6  
     7  // AutoIndexColumnID returns a unique Column ID/Name for the given Column Number.
     8  // The functionality is similar to what you get in an Excel spreadsheet w.r.t.
     9  // the Column ID/Name.
    10  func AutoIndexColumnID(colIdx int) string {
    11  	charIdx := colIdx % 26
    12  	out := string(rune(65 + charIdx))
    13  	colIdx = colIdx / 26
    14  	if colIdx > 0 {
    15  		return AutoIndexColumnID(colIdx-1) + out
    16  	}
    17  	return out
    18  }
    19  
    20  // isNumber returns true if the argument is a numeric type; false otherwise.
    21  func isNumber(x interface{}) bool {
    22  	if x == nil {
    23  		return false
    24  	}
    25  
    26  	switch reflect.TypeOf(x).Kind() {
    27  	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
    28  		reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64,
    29  		reflect.Float32, reflect.Float64:
    30  		return true
    31  	}
    32  	return false
    33  }
    34  
    35  // WidthEnforcer is a function that helps enforce a width condition on a string.
    36  type WidthEnforcer func(col string, maxLen int) string
    37  
    38  // widthEnforcerNone returns the input string as is without any modifications.
    39  func widthEnforcerNone(col string, maxLen int) string {
    40  	return col
    41  }
    42  

View as plain text