gotype/defs.go (40 lines of code) (raw):

// Licensed to Elasticsearch B.V. under one or more contributor // license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright // ownership. Elasticsearch B.V. licenses this file to you under // the Apache License, Version 2.0 (the "License"); you may // not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, // software distributed under the License is distributed on an // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. package gotype import ( "reflect" structform "github.com/elastic/go-structform" "github.com/elastic/go-structform/internal/unsafe" ) type options struct { tag string } var ( tInterface = reflect.TypeOf((*interface{})(nil)).Elem() tString = reflect.TypeOf("") tBool = reflect.TypeOf(true) tInt = reflect.TypeOf(int(0)) tInt8 = reflect.TypeOf(int8(0)) tInt16 = reflect.TypeOf(int16(0)) tInt32 = reflect.TypeOf(int32(0)) tInt64 = reflect.TypeOf(int64(0)) tUint = reflect.TypeOf(uint(0)) tByte = reflect.TypeOf(byte(0)) tUint8 = reflect.TypeOf(uint8(0)) tUint16 = reflect.TypeOf(uint16(0)) tUint32 = reflect.TypeOf(uint32(0)) tUint64 = reflect.TypeOf(uint64(0)) tFloat32 = reflect.TypeOf(float32(0)) tFloat64 = reflect.TypeOf(float64(0)) tError = reflect.TypeOf((*error)(nil)).Elem() tExtVisitor = reflect.TypeOf((*structform.ExtVisitor)(nil)).Elem() tFolder = reflect.TypeOf((*Folder)(nil)).Elem() tExpander = reflect.TypeOf((*Expander)(nil)).Elem() tUnfoldState = reflect.TypeOf((*UnfoldState)(nil)).Elem() tIsZeroer = reflect.TypeOf((*IsZeroer)(nil)).Elem() ) func bytes2Str(b []byte) string { return unsafe.Bytes2Str(b) } func implementsFolder(t reflect.Type) bool { return t.Implements(tFolder) } func implementsPtrFolder(t reflect.Type) bool { return implementsFolder(reflect.PtrTo(t)) } func implementsIsZeroer(t reflect.Type) bool { return t.Implements(tIsZeroer) } func implementsPtrIsZeroer(t reflect.Type) bool { return implementsIsZeroer(reflect.PtrTo(t)) }