_id
stringlengths
2
7
title
stringlengths
1
118
partition
stringclasses
3 values
text
stringlengths
52
85.5k
language
stringclasses
1 value
meta_information
dict
q17500
Equals
train
func (e *equalsGenerator) Equals(g Generator, spec compile.TypeSpec, lhs, rhs string) (string, error) { if isPrimitiveType(spec) { if _, isEnum := spec.(*compile.EnumSpec); !isEnum { return fmt.Sprintf("(%s == %s)", lhs, rhs), nil } } switch s := spec.(type) { case *compile.BinarySpec: bytes := g.Import("bytes") return fmt.Sprintf("%s.Equal(%s, %s)", bytes, lhs, rhs), nil case *compile.MapSpec: equals, err := e.mapG.Equals(g, s) return fmt.Sprintf("%s(%s, %s)", equals, lhs, rhs), err case *compile.ListSpec: equals, err := e.listG.Equals(g, s) return fmt.Sprintf("%s(%s, %s)", equals, lhs, rhs), err case *compile.SetSpec: equals, err := e.setG.Equals(g, s) return fmt.Sprintf("%s(%s, %s)", equals, lhs, rhs), err default: // Custom defined type return fmt.Sprintf("%s.Equals(%s)", lhs, rhs), nil } }
go
{ "resource": "" }
q17501
EqualsPtr
train
func (e *equalsGenerator) EqualsPtr(g Generator, spec compile.TypeSpec, lhs, rhs string) (string, error) { if !isPrimitiveType(spec) { // Everything else is a reference type that has a Equals method on it. return g.TextTemplate( `((<.LHS> == nil && <.RHS> == nil) || (<.LHS> != nil && <.RHS> != nil && <equals .Spec .LHS .RHS>))`, struct { Spec compile.TypeSpec LHS string RHS string }{Spec: spec, LHS: lhs, RHS: rhs}, ) } name := equalsPtrFuncName(g, spec) err := g.EnsureDeclared( ` <$type := typeReference .Spec> <$lhs := newVar "lhs"> <$rhs := newVar "rhs"> func <.Name>(<$lhs>, <$rhs> *<$type>) bool { <- $x := newVar "x" -> <- $y := newVar "y"> if <$lhs> != nil && <$rhs> != nil { // Call Equals method after dereferencing the pointers <$x> := *<$lhs> <$y> := *<$rhs> return <equals .Spec $x $y> } return <$lhs> == nil && <$rhs> == nil } `, struct { Name string Spec compile.TypeSpec }{Name: name, Spec: spec}, ) return fmt.Sprintf("%s(%s, %s)", name, lhs, rhs), err }
go
{ "resource": "" }
q17502
NewClient
train
func NewClient(p protocol.Protocol, t Transport) Client { return client{p: p, t: t} }
go
{ "resource": "" }
q17503
Send
train
func (c client) Send(name string, reqValue wire.Value) (wire.Value, error) { reqEnvelope := wire.Envelope{ Name: name, Type: wire.Call, SeqID: 1, // don't care Value: reqValue, } // TODO(abg): We don't use or support out-of-order requests and responses // for plugin communaction so this should be fine for now but we may // eventually want to match responses to requests using seqID. var buff bytes.Buffer if err := c.p.EncodeEnveloped(reqEnvelope, &buff); err != nil { return wire.Value{}, err } resBody, err := c.t.Send(buff.Bytes()) if err != nil { return wire.Value{}, err } resEnvelope, err := c.p.DecodeEnveloped(bytes.NewReader(resBody)) if err != nil { return wire.Value{}, err } switch resEnvelope.Type { case wire.Exception: var exc exception.TApplicationException if err := exc.FromWire(resEnvelope.Value); err != nil { return wire.Value{}, err } return wire.Value{}, &exc case wire.Reply: return resEnvelope.Value, nil default: return wire.Value{}, errUnknownEnvelopeType(resEnvelope.Type) } }
go
{ "resource": "" }
q17504
Constant
train
func Constant(g Generator, c *compile.Constant) error { err := g.DeclareFromTemplate( `<formatDoc .Doc><if canBeConstant .Type>const<else>var<end> <constantName .Name> <typeReference .Type> = <constantValue .Value .Type>`, c, TemplateFunc("constantValue", ConstantValue), TemplateFunc("canBeConstant", canBeConstant), TemplateFunc("constantName", constantName), ) return wrapGenerateError(c.Name, err) }
go
{ "resource": "" }
q17505
ConstantValue
train
func ConstantValue(g Generator, c compile.ConstantValue, t compile.TypeSpec) (string, error) { switch v := c.(type) { case compile.ConstantBool: return constantBool(g, v, t) case compile.ConstantDouble: return constantDouble(g, v, t) case compile.ConstantInt: return constantInt(g, v, t) case compile.ConstantList: return constantList(g, v, t) case compile.ConstantMap: return constantMap(g, v, t) case compile.ConstantSet: return constantSet(g, v, t) case compile.ConstantString: return strconv.Quote(string(v)), nil case *compile.ConstantStruct: return constantStruct(g, v, t) case compile.EnumItemReference: return enumItemReference(g, v, t) case compile.ConstReference: if canBeConstant(v.Target.Type) { return g.LookupConstantName(v.Target) } return ConstantValue(g, v.Target.Value, v.Target.Type) default: panic(fmt.Sprintf("Unknown constant value %v (%T)", c, c)) } }
go
{ "resource": "" }
q17506
verifyUniqueEnumItemLabels
train
func verifyUniqueEnumItemLabels(spec *compile.EnumSpec) error { items := spec.Items used := make(map[string]compile.EnumItem, len(items)) for _, i := range items { itemName := entityLabel(&i) if conflict, isUsed := used[itemName]; isUsed { return fmt.Errorf( "item %q with label %q conflicts with item %q in enum %q", i.Name, itemName, conflict.Name, spec.Name) } used[itemName] = i } return nil }
go
{ "resource": "" }
q17507
enumUniqueItems
train
func enumUniqueItems(items []compile.EnumItem) []compile.EnumItem { used := make(map[int32]struct{}, len(items)) filtered := items[:0] // zero-alloc filtering for _, i := range items { if _, isUsed := used[i.Value]; isUsed { continue } filtered = append(filtered, i) used[i.Value] = struct{}{} } return filtered }
go
{ "resource": "" }
q17508
claim
train
func (n namespace) claim(name string, line int) error { s := n.transform(name) if line, ok := n.names[s]; ok { return nameConflict{name: name, line: line} } n.names[s] = line return nil }
go
{ "resource": "" }
q17509
compileConstant
train
func compileConstant(file string, src *ast.Constant) (*Constant, error) { typ, err := compileTypeReference(src.Type) if err != nil { return nil, err } return &Constant{ Name: src.Name, File: file, Type: typ, Doc: src.Doc, Value: compileConstantValue(src.Value), }, nil }
go
{ "resource": "" }
q17510
Link
train
func (c *Constant) Link(scope Scope) (err error) { if c.linked() { return nil } if c.Type, err = c.Type.Link(scope); err != nil { return compileError{Target: c.Name, Reason: err} } if c.Value, err = c.Value.Link(scope, c.Type); err != nil { return compileError{Target: c.Name, Reason: err} } return nil }
go
{ "resource": "" }
q17511
isAllCaps
train
func isAllCaps(s string) bool { for _, r := range s { if unicode.IsLetter(r) && !unicode.IsUpper(r) { return false } } return true }
go
{ "resource": "" }
q17512
pascalCase
train
func pascalCase(allowAllCaps bool, words ...string) string { for i, chunk := range words { if len(chunk) == 0 { // foo__bar continue } // known initalism init := strings.ToUpper(chunk) if _, ok := commonInitialisms[init]; ok { words[i] = init continue } // Was SCREAMING_SNAKE_CASE and not a known initialism so Titlecase it. if isAllCaps(chunk) && !allowAllCaps { // A single ALLCAPS word does not count as SCREAMING_SNAKE_CASE. // There must be at least one underscore. words[i] = strings.Title(strings.ToLower(chunk)) continue } // Just another word, but could already be camelCased somehow, so just // change the first letter. head, headIndex := utf8.DecodeRuneInString(chunk) words[i] = string(unicode.ToUpper(head)) + string(chunk[headIndex:]) } return strings.Join(words, "") }
go
{ "resource": "" }
q17513
goCase
train
func goCase(s string) string { if len(s) == 0 { panic(fmt.Sprintf("%q is not a valid identifier", s)) } words := strings.Split(s, "_") return pascalCase(len(words) == 1 /* all caps */, words...) // goCase allows all caps only if the string is a single all caps word. // That is, "FOO" is allowed but "FOO_BAR" is changed to "FooBar". }
go
{ "resource": "" }
q17514
NewServer
train
func NewServer(r io.Reader, w io.Writer) *Server { return &Server{ r: NewReader(r), w: NewWriter(w), running: atomic.NewBool(false), } }
go
{ "resource": "" }
q17515
Serve
train
func (s *Server) Serve(h Handler) (err error) { if s.running.Swap(true) { return fmt.Errorf("server is already running") } defer func() { err = multierr.Append(err, s.r.Close()) err = multierr.Append(err, s.w.Close()) }() for s.running.Load() { req, err := s.r.Read() if err != nil { // If the error occurred because the server was stopped, ignore it. if !s.running.Load() { break } return err } res, err := h.Handle(req) if err != nil { return err } if err := s.w.Write(res); err != nil { return err } } return nil }
go
{ "resource": "" }
q17516
Stop
train
func (s *Server) Stop() error { // We only close the reader because we want the writer to be available if // Stop() was called by a request handler which still needs to send back a // response (goodbye()). The writer will be closed automatically when the // loop exits. if s.running.Swap(false) { return s.r.Close() } return nil }
go
{ "resource": "" }
q17517
embedIDL
train
func embedIDL(g Generator, i thriftPackageImporter, m *compile.Module) error { pkg, err := i.Package(m.ThriftPath) if err != nil { return wrapGenerateError("idl embedding", err) } packageRelPath, err := i.RelativeThriftFilePath(m.ThriftPath) if err != nil { return wrapGenerateError("idl embedding", err) } hash := sha1.Sum(m.Raw) var includes []string for _, v := range m.Includes { importPath, err := i.Package(v.Module.ThriftPath) if err != nil { return wrapGenerateError("idl embedding", err) } includes = append(includes, g.Import(importPath)) } sort.Strings(includes) data := struct { Name string Package string FilePath string SHA1 string Includes []string Raw []byte }{ Name: m.Name, Package: pkg, FilePath: packageRelPath, SHA1: hex.EncodeToString(hash[:]), Includes: includes, Raw: m.Raw, } err = g.DeclareFromTemplate(` <$idl := import "go.uber.org/thriftrw/thriftreflect"> // ThriftModule represents the IDL file used to generate this package. var ThriftModule = &<$idl>.ThriftModule { Name: "<.Name>", Package: "<.Package>", FilePath: <printf "%q" .FilePath>, SHA1: "<.SHA1>", <if .Includes -> Includes: []*<$idl>.ThriftModule {<range .Includes> <.>.ThriftModule, <end> }, <end -> Raw: rawIDL, } const rawIDL = <printf "%q" .Raw> `, data) return wrapGenerateError("idl embedding", err) }
go
{ "resource": "" }
q17518
String
train
func (v *Argument) String() string { if v == nil { return "<nil>" } var fields [2]string i := 0 fields[i] = fmt.Sprintf("Name: %v", v.Name) i++ fields[i] = fmt.Sprintf("Type: %v", v.Type) i++ return fmt.Sprintf("Argument{%v}", strings.Join(fields[:i], ", ")) }
go
{ "resource": "" }
q17519
Equals
train
func (v *Argument) Equals(rhs *Argument) bool { if v == nil { return rhs == nil } else if rhs == nil { return false } if !(v.Name == rhs.Name) { return false } if !v.Type.Equals(rhs.Type) { return false } return true }
go
{ "resource": "" }
q17520
MarshalLogObject
train
func (v *Argument) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { if v == nil { return nil } enc.AddString("name", v.Name) err = multierr.Append(err, enc.AddObject("type", v.Type)) return err }
go
{ "resource": "" }
q17521
MarshalLogObject
train
func (v Feature) MarshalLogObject(enc zapcore.ObjectEncoder) error { enc.AddInt32("value", int32(v)) switch int32(v) { case 1: enc.AddString("name", "SERVICE_GENERATOR") } return nil }
go
{ "resource": "" }
q17522
String
train
func (v Feature) String() string { w := int32(v) switch w { case 1: return "SERVICE_GENERATOR" } return fmt.Sprintf("Feature(%d)", w) }
go
{ "resource": "" }
q17523
MarshalJSON
train
func (v Feature) MarshalJSON() ([]byte, error) { switch int32(v) { case 1: return ([]byte)("\"SERVICE_GENERATOR\""), nil } return ([]byte)(strconv.FormatInt(int64(v), 10)), nil }
go
{ "resource": "" }
q17524
String
train
func (v *Function) String() string { if v == nil { return "<nil>" } var fields [7]string i := 0 fields[i] = fmt.Sprintf("Name: %v", v.Name) i++ fields[i] = fmt.Sprintf("ThriftName: %v", v.ThriftName) i++ fields[i] = fmt.Sprintf("Arguments: %v", v.Arguments) i++ if v.ReturnType != nil { fields[i] = fmt.Sprintf("ReturnType: %v", v.ReturnType) i++ } if v.Exceptions != nil { fields[i] = fmt.Sprintf("Exceptions: %v", v.Exceptions) i++ } if v.OneWay != nil { fields[i] = fmt.Sprintf("OneWay: %v", *(v.OneWay)) i++ } if v.Annotations != nil { fields[i] = fmt.Sprintf("Annotations: %v", v.Annotations) i++ } return fmt.Sprintf("Function{%v}", strings.Join(fields[:i], ", ")) }
go
{ "resource": "" }
q17525
Equals
train
func (v *Function) Equals(rhs *Function) bool { if v == nil { return rhs == nil } else if rhs == nil { return false } if !(v.Name == rhs.Name) { return false } if !(v.ThriftName == rhs.ThriftName) { return false } if !_List_Argument_Equals(v.Arguments, rhs.Arguments) { return false } if !((v.ReturnType == nil && rhs.ReturnType == nil) || (v.ReturnType != nil && rhs.ReturnType != nil && v.ReturnType.Equals(rhs.ReturnType))) { return false } if !((v.Exceptions == nil && rhs.Exceptions == nil) || (v.Exceptions != nil && rhs.Exceptions != nil && _List_Argument_Equals(v.Exceptions, rhs.Exceptions))) { return false } if !_Bool_EqualsPtr(v.OneWay, rhs.OneWay) { return false } if !((v.Annotations == nil && rhs.Annotations == nil) || (v.Annotations != nil && rhs.Annotations != nil && _Map_String_String_Equals(v.Annotations, rhs.Annotations))) { return false } return true }
go
{ "resource": "" }
q17526
MarshalLogObject
train
func (v *Function) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { if v == nil { return nil } enc.AddString("name", v.Name) enc.AddString("thriftName", v.ThriftName) err = multierr.Append(err, enc.AddArray("arguments", (_List_Argument_Zapper)(v.Arguments))) if v.ReturnType != nil { err = multierr.Append(err, enc.AddObject("returnType", v.ReturnType)) } if v.Exceptions != nil { err = multierr.Append(err, enc.AddArray("exceptions", (_List_Argument_Zapper)(v.Exceptions))) } if v.OneWay != nil { enc.AddBool("oneWay", *v.OneWay) } if v.Annotations != nil { err = multierr.Append(err, enc.AddObject("annotations", (_Map_String_String_Zapper)(v.Annotations))) } return err }
go
{ "resource": "" }
q17527
GetArguments
train
func (v *Function) GetArguments() (o []*Argument) { if v != nil { o = v.Arguments } return }
go
{ "resource": "" }
q17528
GetReturnType
train
func (v *Function) GetReturnType() (o *Type) { if v != nil && v.ReturnType != nil { return v.ReturnType } return }
go
{ "resource": "" }
q17529
GetExceptions
train
func (v *Function) GetExceptions() (o []*Argument) { if v != nil && v.Exceptions != nil { return v.Exceptions } return }
go
{ "resource": "" }
q17530
GetOneWay
train
func (v *Function) GetOneWay() (o bool) { if v != nil && v.OneWay != nil { return *v.OneWay } return }
go
{ "resource": "" }
q17531
String
train
func (v *GenerateServiceRequest) String() string { if v == nil { return "<nil>" } var fields [5]string i := 0 fields[i] = fmt.Sprintf("RootServices: %v", v.RootServices) i++ fields[i] = fmt.Sprintf("Services: %v", v.Services) i++ fields[i] = fmt.Sprintf("Modules: %v", v.Modules) i++ fields[i] = fmt.Sprintf("PackagePrefix: %v", v.PackagePrefix) i++ fields[i] = fmt.Sprintf("ThriftRoot: %v", v.ThriftRoot) i++ return fmt.Sprintf("GenerateServiceRequest{%v}", strings.Join(fields[:i], ", ")) }
go
{ "resource": "" }
q17532
Equals
train
func (v *GenerateServiceRequest) Equals(rhs *GenerateServiceRequest) bool { if v == nil { return rhs == nil } else if rhs == nil { return false } if !_List_ServiceID_Equals(v.RootServices, rhs.RootServices) { return false } if !_Map_ServiceID_Service_Equals(v.Services, rhs.Services) { return false } if !_Map_ModuleID_Module_Equals(v.Modules, rhs.Modules) { return false } if !(v.PackagePrefix == rhs.PackagePrefix) { return false } if !(v.ThriftRoot == rhs.ThriftRoot) { return false } return true }
go
{ "resource": "" }
q17533
MarshalLogArray
train
func (l _List_ServiceID_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) (err error) { for _, v := range l { enc.AppendInt32((int32)(v)) } return err }
go
{ "resource": "" }
q17534
MarshalLogArray
train
func (m _Map_ServiceID_Service_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) (err error) { for k, v := range m { err = multierr.Append(err, enc.AppendObject(_Map_ServiceID_Service_Item_Zapper{Key: k, Value: v})) } return err }
go
{ "resource": "" }
q17535
MarshalLogObject
train
func (v _Map_ModuleID_Module_Item_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { enc.AddInt32("key", (int32)(v.Key)) err = multierr.Append(err, enc.AddObject("value", v.Value)) return err }
go
{ "resource": "" }
q17536
MarshalLogArray
train
func (m _Map_ModuleID_Module_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) (err error) { for k, v := range m { err = multierr.Append(err, enc.AppendObject(_Map_ModuleID_Module_Item_Zapper{Key: k, Value: v})) } return err }
go
{ "resource": "" }
q17537
MarshalLogObject
train
func (v *GenerateServiceRequest) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { if v == nil { return nil } err = multierr.Append(err, enc.AddArray("rootServices", (_List_ServiceID_Zapper)(v.RootServices))) err = multierr.Append(err, enc.AddArray("services", (_Map_ServiceID_Service_Zapper)(v.Services))) err = multierr.Append(err, enc.AddArray("modules", (_Map_ModuleID_Module_Zapper)(v.Modules))) enc.AddString("packagePrefix", v.PackagePrefix) enc.AddString("thriftRoot", v.ThriftRoot) return err }
go
{ "resource": "" }
q17538
GetRootServices
train
func (v *GenerateServiceRequest) GetRootServices() (o []ServiceID) { if v != nil { o = v.RootServices } return }
go
{ "resource": "" }
q17539
GetServices
train
func (v *GenerateServiceRequest) GetServices() (o map[ServiceID]*Service) { if v != nil { o = v.Services } return }
go
{ "resource": "" }
q17540
GetModules
train
func (v *GenerateServiceRequest) GetModules() (o map[ModuleID]*Module) { if v != nil { o = v.Modules } return }
go
{ "resource": "" }
q17541
GetPackagePrefix
train
func (v *GenerateServiceRequest) GetPackagePrefix() (o string) { if v != nil { o = v.PackagePrefix } return }
go
{ "resource": "" }
q17542
GetThriftRoot
train
func (v *GenerateServiceRequest) GetThriftRoot() (o string) { if v != nil { o = v.ThriftRoot } return }
go
{ "resource": "" }
q17543
String
train
func (v *GenerateServiceResponse) String() string { if v == nil { return "<nil>" } var fields [1]string i := 0 if v.Files != nil { fields[i] = fmt.Sprintf("Files: %v", v.Files) i++ } return fmt.Sprintf("GenerateServiceResponse{%v}", strings.Join(fields[:i], ", ")) }
go
{ "resource": "" }
q17544
Equals
train
func (v *GenerateServiceResponse) Equals(rhs *GenerateServiceResponse) bool { if v == nil { return rhs == nil } else if rhs == nil { return false } if !((v.Files == nil && rhs.Files == nil) || (v.Files != nil && rhs.Files != nil && _Map_String_Binary_Equals(v.Files, rhs.Files))) { return false } return true }
go
{ "resource": "" }
q17545
MarshalLogObject
train
func (m _Map_String_Binary_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { for k, v := range m { enc.AddString((string)(k), base64.StdEncoding.EncodeToString(v)) } return err }
go
{ "resource": "" }
q17546
MarshalLogObject
train
func (v *GenerateServiceResponse) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { if v == nil { return nil } if v.Files != nil { err = multierr.Append(err, enc.AddObject("files", (_Map_String_Binary_Zapper)(v.Files))) } return err }
go
{ "resource": "" }
q17547
GetFiles
train
func (v *GenerateServiceResponse) GetFiles() (o map[string][]byte) { if v != nil && v.Files != nil { return v.Files } return }
go
{ "resource": "" }
q17548
String
train
func (v *HandshakeRequest) String() string { if v == nil { return "<nil>" } var fields [0]string i := 0 return fmt.Sprintf("HandshakeRequest{%v}", strings.Join(fields[:i], ", ")) }
go
{ "resource": "" }
q17549
Equals
train
func (v *HandshakeRequest) Equals(rhs *HandshakeRequest) bool { if v == nil { return rhs == nil } else if rhs == nil { return false } return true }
go
{ "resource": "" }
q17550
MarshalLogObject
train
func (v *HandshakeRequest) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { if v == nil { return nil } return err }
go
{ "resource": "" }
q17551
String
train
func (v *HandshakeResponse) String() string { if v == nil { return "<nil>" } var fields [4]string i := 0 fields[i] = fmt.Sprintf("Name: %v", v.Name) i++ fields[i] = fmt.Sprintf("APIVersion: %v", v.APIVersion) i++ fields[i] = fmt.Sprintf("Features: %v", v.Features) i++ if v.LibraryVersion != nil { fields[i] = fmt.Sprintf("LibraryVersion: %v", *(v.LibraryVersion)) i++ } return fmt.Sprintf("HandshakeResponse{%v}", strings.Join(fields[:i], ", ")) }
go
{ "resource": "" }
q17552
Equals
train
func (v *HandshakeResponse) Equals(rhs *HandshakeResponse) bool { if v == nil { return rhs == nil } else if rhs == nil { return false } if !(v.Name == rhs.Name) { return false } if !(v.APIVersion == rhs.APIVersion) { return false } if !_List_Feature_Equals(v.Features, rhs.Features) { return false } if !_String_EqualsPtr(v.LibraryVersion, rhs.LibraryVersion) { return false } return true }
go
{ "resource": "" }
q17553
MarshalLogObject
train
func (v *HandshakeResponse) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { if v == nil { return nil } enc.AddString("name", v.Name) enc.AddInt32("apiVersion", v.APIVersion) err = multierr.Append(err, enc.AddArray("features", (_List_Feature_Zapper)(v.Features))) if v.LibraryVersion != nil { enc.AddString("libraryVersion", *v.LibraryVersion) } return err }
go
{ "resource": "" }
q17554
GetAPIVersion
train
func (v *HandshakeResponse) GetAPIVersion() (o int32) { if v != nil { o = v.APIVersion } return }
go
{ "resource": "" }
q17555
GetFeatures
train
func (v *HandshakeResponse) GetFeatures() (o []Feature) { if v != nil { o = v.Features } return }
go
{ "resource": "" }
q17556
GetLibraryVersion
train
func (v *HandshakeResponse) GetLibraryVersion() (o string) { if v != nil && v.LibraryVersion != nil { return *v.LibraryVersion } return }
go
{ "resource": "" }
q17557
String
train
func (v *Module) String() string { if v == nil { return "<nil>" } var fields [3]string i := 0 fields[i] = fmt.Sprintf("ImportPath: %v", v.ImportPath) i++ fields[i] = fmt.Sprintf("Directory: %v", v.Directory) i++ fields[i] = fmt.Sprintf("ThriftFilePath: %v", v.ThriftFilePath) i++ return fmt.Sprintf("Module{%v}", strings.Join(fields[:i], ", ")) }
go
{ "resource": "" }
q17558
Equals
train
func (v *Module) Equals(rhs *Module) bool { if v == nil { return rhs == nil } else if rhs == nil { return false } if !(v.ImportPath == rhs.ImportPath) { return false } if !(v.Directory == rhs.Directory) { return false } if !(v.ThriftFilePath == rhs.ThriftFilePath) { return false } return true }
go
{ "resource": "" }
q17559
MarshalLogObject
train
func (v *Module) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { if v == nil { return nil } enc.AddString("importPath", v.ImportPath) enc.AddString("directory", v.Directory) enc.AddString("thriftFilePath", v.ThriftFilePath) return err }
go
{ "resource": "" }
q17560
GetDirectory
train
func (v *Module) GetDirectory() (o string) { if v != nil { o = v.Directory } return }
go
{ "resource": "" }
q17561
GetThriftFilePath
train
func (v *Module) GetThriftFilePath() (o string) { if v != nil { o = v.ThriftFilePath } return }
go
{ "resource": "" }
q17562
ToWire
train
func (v ModuleID) ToWire() (wire.Value, error) { x := (int32)(v) return wire.NewValueI32(x), error(nil) }
go
{ "resource": "" }
q17563
String
train
func (v ModuleID) String() string { x := (int32)(v) return fmt.Sprint(x) }
go
{ "resource": "" }
q17564
Equals
train
func (lhs ModuleID) Equals(rhs ModuleID) bool { return ((int32)(lhs) == (int32)(rhs)) }
go
{ "resource": "" }
q17565
String
train
func (v *Service) String() string { if v == nil { return "<nil>" } var fields [6]string i := 0 fields[i] = fmt.Sprintf("Name: %v", v.Name) i++ fields[i] = fmt.Sprintf("ThriftName: %v", v.ThriftName) i++ if v.ParentID != nil { fields[i] = fmt.Sprintf("ParentID: %v", *(v.ParentID)) i++ } fields[i] = fmt.Sprintf("Functions: %v", v.Functions) i++ fields[i] = fmt.Sprintf("ModuleID: %v", v.ModuleID) i++ if v.Annotations != nil { fields[i] = fmt.Sprintf("Annotations: %v", v.Annotations) i++ } return fmt.Sprintf("Service{%v}", strings.Join(fields[:i], ", ")) }
go
{ "resource": "" }
q17566
Equals
train
func (v *Service) Equals(rhs *Service) bool { if v == nil { return rhs == nil } else if rhs == nil { return false } if !(v.Name == rhs.Name) { return false } if !(v.ThriftName == rhs.ThriftName) { return false } if !_ServiceID_EqualsPtr(v.ParentID, rhs.ParentID) { return false } if !_List_Function_Equals(v.Functions, rhs.Functions) { return false } if !(v.ModuleID == rhs.ModuleID) { return false } if !((v.Annotations == nil && rhs.Annotations == nil) || (v.Annotations != nil && rhs.Annotations != nil && _Map_String_String_Equals(v.Annotations, rhs.Annotations))) { return false } return true }
go
{ "resource": "" }
q17567
MarshalLogObject
train
func (v *Service) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { if v == nil { return nil } enc.AddString("name", v.Name) enc.AddString("thriftName", v.ThriftName) if v.ParentID != nil { enc.AddInt32("parentID", (int32)(*v.ParentID)) } err = multierr.Append(err, enc.AddArray("functions", (_List_Function_Zapper)(v.Functions))) enc.AddInt32("moduleID", (int32)(v.ModuleID)) if v.Annotations != nil { err = multierr.Append(err, enc.AddObject("annotations", (_Map_String_String_Zapper)(v.Annotations))) } return err }
go
{ "resource": "" }
q17568
GetParentID
train
func (v *Service) GetParentID() (o ServiceID) { if v != nil && v.ParentID != nil { return *v.ParentID } return }
go
{ "resource": "" }
q17569
GetFunctions
train
func (v *Service) GetFunctions() (o []*Function) { if v != nil { o = v.Functions } return }
go
{ "resource": "" }
q17570
GetModuleID
train
func (v *Service) GetModuleID() (o ModuleID) { if v != nil { o = v.ModuleID } return }
go
{ "resource": "" }
q17571
String
train
func (v ServiceID) String() string { x := (int32)(v) return fmt.Sprint(x) }
go
{ "resource": "" }
q17572
FromWire
train
func (v *ServiceID) FromWire(w wire.Value) error { x, err := w.GetI32(), error(nil) *v = (ServiceID)(x) return err }
go
{ "resource": "" }
q17573
Equals
train
func (lhs ServiceID) Equals(rhs ServiceID) bool { return ((int32)(lhs) == (int32)(rhs)) }
go
{ "resource": "" }
q17574
SimpleType_Values
train
func SimpleType_Values() []SimpleType { return []SimpleType{ SimpleTypeBool, SimpleTypeByte, SimpleTypeInt8, SimpleTypeInt16, SimpleTypeInt32, SimpleTypeInt64, SimpleTypeFloat64, SimpleTypeString, SimpleTypeStructEmpty, } }
go
{ "resource": "" }
q17575
ToWire
train
func (v SimpleType) ToWire() (wire.Value, error) { return wire.NewValueI32(int32(v)), nil }
go
{ "resource": "" }
q17576
String
train
func (v SimpleType) String() string { w := int32(v) switch w { case 1: return "BOOL" case 2: return "BYTE" case 3: return "INT8" case 4: return "INT16" case 5: return "INT32" case 6: return "INT64" case 7: return "FLOAT64" case 8: return "STRING" case 9: return "STRUCT_EMPTY" } return fmt.Sprintf("SimpleType(%d)", w) }
go
{ "resource": "" }
q17577
String
train
func (v *Type) String() string { if v == nil { return "<nil>" } var fields [6]string i := 0 if v.SimpleType != nil { fields[i] = fmt.Sprintf("SimpleType: %v", *(v.SimpleType)) i++ } if v.SliceType != nil { fields[i] = fmt.Sprintf("SliceType: %v", v.SliceType) i++ } if v.KeyValueSliceType != nil { fields[i] = fmt.Sprintf("KeyValueSliceType: %v", v.KeyValueSliceType) i++ } if v.MapType != nil { fields[i] = fmt.Sprintf("MapType: %v", v.MapType) i++ } if v.ReferenceType != nil { fields[i] = fmt.Sprintf("ReferenceType: %v", v.ReferenceType) i++ } if v.PointerType != nil { fields[i] = fmt.Sprintf("PointerType: %v", v.PointerType) i++ } return fmt.Sprintf("Type{%v}", strings.Join(fields[:i], ", ")) }
go
{ "resource": "" }
q17578
Equals
train
func (v *Type) Equals(rhs *Type) bool { if v == nil { return rhs == nil } else if rhs == nil { return false } if !_SimpleType_EqualsPtr(v.SimpleType, rhs.SimpleType) { return false } if !((v.SliceType == nil && rhs.SliceType == nil) || (v.SliceType != nil && rhs.SliceType != nil && v.SliceType.Equals(rhs.SliceType))) { return false } if !((v.KeyValueSliceType == nil && rhs.KeyValueSliceType == nil) || (v.KeyValueSliceType != nil && rhs.KeyValueSliceType != nil && v.KeyValueSliceType.Equals(rhs.KeyValueSliceType))) { return false } if !((v.MapType == nil && rhs.MapType == nil) || (v.MapType != nil && rhs.MapType != nil && v.MapType.Equals(rhs.MapType))) { return false } if !((v.ReferenceType == nil && rhs.ReferenceType == nil) || (v.ReferenceType != nil && rhs.ReferenceType != nil && v.ReferenceType.Equals(rhs.ReferenceType))) { return false } if !((v.PointerType == nil && rhs.PointerType == nil) || (v.PointerType != nil && rhs.PointerType != nil && v.PointerType.Equals(rhs.PointerType))) { return false } return true }
go
{ "resource": "" }
q17579
MarshalLogObject
train
func (v *Type) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { if v == nil { return nil } if v.SimpleType != nil { err = multierr.Append(err, enc.AddObject("simpleType", *v.SimpleType)) } if v.SliceType != nil { err = multierr.Append(err, enc.AddObject("sliceType", v.SliceType)) } if v.KeyValueSliceType != nil { err = multierr.Append(err, enc.AddObject("keyValueSliceType", v.KeyValueSliceType)) } if v.MapType != nil { err = multierr.Append(err, enc.AddObject("mapType", v.MapType)) } if v.ReferenceType != nil { err = multierr.Append(err, enc.AddObject("referenceType", v.ReferenceType)) } if v.PointerType != nil { err = multierr.Append(err, enc.AddObject("pointerType", v.PointerType)) } return err }
go
{ "resource": "" }
q17580
GetSimpleType
train
func (v *Type) GetSimpleType() (o SimpleType) { if v != nil && v.SimpleType != nil { return *v.SimpleType } return }
go
{ "resource": "" }
q17581
GetSliceType
train
func (v *Type) GetSliceType() (o *Type) { if v != nil && v.SliceType != nil { return v.SliceType } return }
go
{ "resource": "" }
q17582
GetKeyValueSliceType
train
func (v *Type) GetKeyValueSliceType() (o *TypePair) { if v != nil && v.KeyValueSliceType != nil { return v.KeyValueSliceType } return }
go
{ "resource": "" }
q17583
GetMapType
train
func (v *Type) GetMapType() (o *TypePair) { if v != nil && v.MapType != nil { return v.MapType } return }
go
{ "resource": "" }
q17584
GetReferenceType
train
func (v *Type) GetReferenceType() (o *TypeReference) { if v != nil && v.ReferenceType != nil { return v.ReferenceType } return }
go
{ "resource": "" }
q17585
GetPointerType
train
func (v *Type) GetPointerType() (o *Type) { if v != nil && v.PointerType != nil { return v.PointerType } return }
go
{ "resource": "" }
q17586
String
train
func (v *TypePair) String() string { if v == nil { return "<nil>" } var fields [2]string i := 0 fields[i] = fmt.Sprintf("Left: %v", v.Left) i++ fields[i] = fmt.Sprintf("Right: %v", v.Right) i++ return fmt.Sprintf("TypePair{%v}", strings.Join(fields[:i], ", ")) }
go
{ "resource": "" }
q17587
Equals
train
func (v *TypePair) Equals(rhs *TypePair) bool { if v == nil { return rhs == nil } else if rhs == nil { return false } if !v.Left.Equals(rhs.Left) { return false } if !v.Right.Equals(rhs.Right) { return false } return true }
go
{ "resource": "" }
q17588
MarshalLogObject
train
func (v *TypePair) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { if v == nil { return nil } err = multierr.Append(err, enc.AddObject("left", v.Left)) err = multierr.Append(err, enc.AddObject("right", v.Right)) return err }
go
{ "resource": "" }
q17589
GetLeft
train
func (v *TypePair) GetLeft() (o *Type) { if v != nil { o = v.Left } return }
go
{ "resource": "" }
q17590
GetRight
train
func (v *TypePair) GetRight() (o *Type) { if v != nil { o = v.Right } return }
go
{ "resource": "" }
q17591
String
train
func (v *TypeReference) String() string { if v == nil { return "<nil>" } var fields [3]string i := 0 fields[i] = fmt.Sprintf("Name: %v", v.Name) i++ fields[i] = fmt.Sprintf("ImportPath: %v", v.ImportPath) i++ if v.Annotations != nil { fields[i] = fmt.Sprintf("Annotations: %v", v.Annotations) i++ } return fmt.Sprintf("TypeReference{%v}", strings.Join(fields[:i], ", ")) }
go
{ "resource": "" }
q17592
Equals
train
func (v *TypeReference) Equals(rhs *TypeReference) bool { if v == nil { return rhs == nil } else if rhs == nil { return false } if !(v.Name == rhs.Name) { return false } if !(v.ImportPath == rhs.ImportPath) { return false } if !((v.Annotations == nil && rhs.Annotations == nil) || (v.Annotations != nil && rhs.Annotations != nil && _Map_String_String_Equals(v.Annotations, rhs.Annotations))) { return false } return true }
go
{ "resource": "" }
q17593
MarshalLogObject
train
func (v *TypeReference) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { if v == nil { return nil } enc.AddString("name", v.Name) enc.AddString("importPath", v.ImportPath) if v.Annotations != nil { err = multierr.Append(err, enc.AddObject("annotations", (_Map_String_String_Zapper)(v.Annotations))) } return err }
go
{ "resource": "" }
q17594
capitalize
train
func capitalize(s string) string { if len(s) == 0 { return s } x, i := utf8.DecodeRuneInString(s) return string(unicode.ToUpper(x)) + string(s[i:]) }
go
{ "resource": "" }
q17595
fileBaseName
train
func fileBaseName(p string) string { return strings.TrimSuffix(filepath.Base(p), filepath.Ext(p)) }
go
{ "resource": "" }
q17596
splitInclude
train
func splitInclude(s string) (string, string) { if i := strings.IndexRune(s, '.'); i > 0 { return s[:i], s[i+1:] } return "", s }
go
{ "resource": "" }
q17597
MapItemListToSlice
train
func MapItemListToSlice(l MapItemList) []MapItem { items := make([]MapItem, 0, l.Size()) // explicitly ignoring since we know there will not be an error _ = l.ForEach(func(v MapItem) error { items = append(items, v) return nil }) return items }
go
{ "resource": "" }
q17598
NewClient
train
func NewClient(w io.Writer, r io.Reader) *Client { return &Client{ r: NewReader(r), w: NewWriter(w), } }
go
{ "resource": "" }
q17599
Send
train
func (c *Client) Send(b []byte) ([]byte, error) { c.Lock() defer c.Unlock() if err := c.w.Write(b); err != nil { return nil, err } return c.r.Read() }
go
{ "resource": "" }