agent/config/config.go
func (cfg *Config) trimWhitespace() {
	cfgElem := reflect.ValueOf(cfg).Elem()
	cfgStructField := reflect.Indirect(reflect.ValueOf(cfg)).Type()

	for i := 0; i < cfgElem.NumField(); i++ {
		cfgField := cfgElem.Field(i)
		if !cfgField.CanInterface() {
			continue
		}
		trimTag := cfgStructField.Field(i).Tag.Get("trim")
		if len(trimTag) == 0 {
			continue
		}

		if cfgField.Kind() != reflect.String {
			seelog.Warnf("Cannot trim non-string field type %v index %v", cfgField.Kind().String(), i)
			continue
		}
		str := cfgField.Interface().(string)
		cfgField.SetString(strings.TrimSpace(str))
	}
}
func (cfg *Config) trimWhitespace() {
	cfgElem := reflect.ValueOf(cfg).Elem()
	cfgStructField := reflect.Indirect(reflect.ValueOf(cfg)).Type()

	for i := 0; i < cfgElem.NumField(); i++ {
		cfgField := cfgElem.Field(i)
		if !cfgField.CanInterface() {
			continue
		}
		trimTag := cfgStructField.Field(i).Tag.Get("trim")
		if len(trimTag) == 0 {
			continue
		}

		if cfgField.Kind() != reflect.String {
			seelog.Warnf("Cannot trim non-string field type %v index %v", cfgField.Kind().String(), i)
			continue
		}
		str := cfgField.Interface().(string)
		cfgField.SetString(strings.TrimSpace(str))
	}
}
func ( cfg * Config ) trimWhitespace ( ) { cfgElem := reflect . ValueOf ( cfg ) . Elem ( ) cfgStructField := reflect . Indirect ( reflect . ValueOf ( cfg ) ) . Type ( ) for i := 0 ; i < cfgElem . NumField ( ) ; i ++ { cfgField := cfgElem . Field ( i ) if ! cfgField . CanInterface ( ) { continue } trimTag := cfgStructField . Field ( i ) . Tag . Get ( " " ) if len ( trimTag ) == 0 { continue } if cfgField . Kind ( ) != reflect . String { seelog . Warnf ( " " , cfgField . Kind ( ) . String ( ) , i ) continue } str := cfgField . Interface ( ) . ( string ) cfgField . SetString ( strings . TrimSpace ( str ) ) } }
// trimWhitespace trims whitespace from all string cfg values with the
// `trim` tag
trimWhitespace trims whitespace from all string cfg values with the trim tag