Every line of 'golang enum' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Go code is secure.
424 func Enum(p api.Protocol) uint16 { 425 if p == api.ProtocolTCP { 426 return 6 427 } 428 if p == api.ProtocolUDP { 429 return 17 430 } 431 return 0 432 }
15 func (c *EnumConstraint) Enum(v ...interface{}) *EnumConstraint { 16 c.enums = v 17 return c 18 }
1128 func Enum(val, enum interface{}) bool { 1129 if val == nil || enum == nil { 1130 return false 1131 } 1132 1133 v, err := convert(val) 1134 if err != nil { 1135 return false 1136 } 1137 // if is string value 1138 if strVal, ok := v.(string); ok { 1139 if ss, ok := enum.([]string); ok { 1140 for _, strItem := range ss { 1141 if strVal == strItem { // exists 1142 return true 1143 } 1144 } 1145 } 1146 1147 return false 1148 } 1149 1150 // as int value 1151 intVal, err := mathutil.Int64(v) 1152 if err != nil { 1153 return false 1154 } 1155 1156 if int64s, ok := toInt64Slice(enum); ok { 1157 for _, i64 := range int64s { 1158 if intVal == i64 { // exists 1159 return true 1160 } 1161 } 1162 } 1163 return false 1164 }
118 func (m *PointContent) GetENum() uint32 { 119 if m != nil { 120 return m.ENum 121 } 122 return 0 123 }
88 func (s *IntSet) Enums() []int { 89 len := s.Len() 90 if len == 0 { 91 return []int{} 92 } 93 94 enums := make([]int, 0, len) 95 for i, sword := range s.words { 96 for bit := uint(0); bit < UINT_SIZE; bit++ { 97 if sword&(1<
180 func (v *items) Enum() *InterfaceListIterator { 181 var items []interface{} 182 for _, item := range v.enum { 183 items = append(items, item) 184 } 185 var iter InterfaceListIterator 186 iter.size = len(items) 187 iter.items = items 188 return &iter 189 }
304 func convertEnum(value string, t reflect.Type, enumValMap map[string]int32) (reflect.Value, error) { 305 // see if it's an enumeration string 306 if enumVal, ok := enumValMap[value]; ok { 307 return reflect.ValueOf(enumVal).Convert(t), nil 308 } 309 310 // check for an integer that matches an enumeration value 311 eVal, err := strconv.Atoi(value) 312 if err != nil { 313 return reflect.Value{}, fmt.Errorf("%s is not a valid %s", value, t) 314 } 315 for _, v := range enumValMap { 316 if v == int32(eVal) { 317 return reflect.ValueOf(eVal).Convert(t), nil 318 } 319 } 320 return reflect.Value{}, fmt.Errorf("%s is not a valid %s", value, t) 321 }
74 func (x PubliclyImportedEnum) Enum() *PubliclyImportedEnum { 75 return (*PubliclyImportedEnum)((imp2.PubliclyImportedEnum)(x).Enum()) 76 }
13 func Enum(path, in string, data interface{}, enum interface{}) *errors.Validation { 14 val := reflect.ValueOf(enum) 15 if val.Kind() != reflect.Slice { 16 return nil 17 } 18 19 var values []interface{} 20 for i := 0; i < val.Len(); i++ { 21 ele := val.Index(i) 22 enumValue := ele.Interface() 23 if data != nil && reflect.DeepEqual(data, enumValue) { 24 return nil 25 } 26 values = append(values, enumValue) 27 } 28 return errors.EnumFail(path, in, data, values) 29 }
179 func (this *Property) Enums() []PropertyEnum { 180 var result []PropertyEnum 181 ctx := (*C.drmModePropertyRes)(this) 182 sliceHeader := (*reflect.SliceHeader)((unsafe.Pointer(&result))) 183 sliceHeader.Cap = int(ctx.count_enums) 184 sliceHeader.Len = int(ctx.count_enums) 185 sliceHeader.Data = uintptr(unsafe.Pointer(ctx.enums)) 186 return result 187 }