format.go
func (f *defaultFormats) Add(name string, strfmt Format, validator Validator) bool {
	f.Lock()
	defer f.Unlock()

	nme := f.normalizeName(name)

	tpe := reflect.TypeOf(strfmt)
	if tpe.Kind() == reflect.Ptr {
		tpe = tpe.Elem()
	}

	for i := range f.data {
		v := &f.data[i]
		if v.Name == nme {
			v.Type = tpe
			v.Validator = validator
			return false
		}
	}

	// turns out it's new after all
	f.data = append(f.data, knownFormat{Name: nme, OrigName: name, Type: tpe, Validator: validator})
	return true
}
func (f *defaultFormats) Add(name string, strfmt Format, validator Validator) bool {
	f.Lock()
	defer f.Unlock()

	nme := f.normalizeName(name)

	tpe := reflect.TypeOf(strfmt)
	if tpe.Kind() == reflect.Ptr {
		tpe = tpe.Elem()
	}

	for i := range f.data {
		v := &f.data[i]
		if v.Name == nme {
			v.Type = tpe
			v.Validator = validator
			return false
		}
	}

	// turns out it's new after all
	f.data = append(f.data, knownFormat{Name: nme, OrigName: name, Type: tpe, Validator: validator})
	return true
}
func ( f * defaultFormats ) Add ( name string , strfmt Format , validator Validator ) bool { f . Lock ( ) defer f . Unlock ( ) nme := f . normalizeName ( name ) tpe := reflect . TypeOf ( strfmt ) if tpe . Kind ( ) == reflect . Ptr { tpe = tpe . Elem ( ) } for i := range f . data { v := & f . data [ i ] if v . Name == nme { v . Type = tpe v . Validator = validator return false } } // turns out it's new after all f . data = append ( f . data , knownFormat { Name : nme , OrigName : name , Type : tpe , Validator : validator } ) return true }
// Add adds a new format, return true if this was a new item instead of a replacement
Add adds a new format return true if this was a new item instead of a replacement