id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
17,600
thriftrw/thriftrw-go
compile/type.go
RootTypeSpec
func RootTypeSpec(s TypeSpec) TypeSpec { if t, ok := s.(*TypedefSpec); ok { return t.root } return s }
go
func RootTypeSpec(s TypeSpec) TypeSpec { if t, ok := s.(*TypedefSpec); ok { return t.root } return s }
[ "func", "RootTypeSpec", "(", "s", "TypeSpec", ")", "TypeSpec", "{", "if", "t", ",", "ok", ":=", "s", ".", "(", "*", "TypedefSpec", ")", ";", "ok", "{", "return", "t", ".", "root", "\n", "}", "\n", "return", "s", "\n", "}" ]
// RootTypeSpec returns the TypeSpec that the given linked TypeSpec points to. // // For most types, this is the type itself. For Typedefs, it is the root // TypeSpec of the Typedef's target.
[ "RootTypeSpec", "returns", "the", "TypeSpec", "that", "the", "given", "linked", "TypeSpec", "points", "to", ".", "For", "most", "types", "this", "is", "the", "type", "itself", ".", "For", "Typedefs", "it", "is", "the", "root", "TypeSpec", "of", "the", "Typ...
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/type.go#L69-L74
17,601
thriftrw/thriftrw-go
compile/type.go
Link
func (r typeSpecReference) Link(scope Scope) (TypeSpec, error) { src := ast.TypeReference(r) t, err := scope.LookupType(src.Name) if err == nil { return t.Link(scope) } mname, iname := splitInclude(src.Name) if len(mname) == 0 { return nil, referenceError{ Target: src.Name, Line: src.Line, S...
go
func (r typeSpecReference) Link(scope Scope) (TypeSpec, error) { src := ast.TypeReference(r) t, err := scope.LookupType(src.Name) if err == nil { return t.Link(scope) } mname, iname := splitInclude(src.Name) if len(mname) == 0 { return nil, referenceError{ Target: src.Name, Line: src.Line, S...
[ "func", "(", "r", "typeSpecReference", ")", "Link", "(", "scope", "Scope", ")", "(", "TypeSpec", ",", "error", ")", "{", "src", ":=", "ast", ".", "TypeReference", "(", "r", ")", "\n", "t", ",", "err", ":=", "scope", ".", "LookupType", "(", "src", "...
// Link replaces the typeSpecReference with an actual linked TypeSpec.
[ "Link", "replaces", "the", "typeSpecReference", "with", "an", "actual", "linked", "TypeSpec", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/type.go#L88-L126
17,602
thriftrw/thriftrw-go
compile/type.go
ForEachTypeReference
func (r typeSpecReference) ForEachTypeReference(func(TypeSpec) error) error { panic(fmt.Sprintf( "ForEachTypeReference() called on unresolved TypeSpec reference %v."+ "Make sure you called Link().", r, )) }
go
func (r typeSpecReference) ForEachTypeReference(func(TypeSpec) error) error { panic(fmt.Sprintf( "ForEachTypeReference() called on unresolved TypeSpec reference %v."+ "Make sure you called Link().", r, )) }
[ "func", "(", "r", "typeSpecReference", ")", "ForEachTypeReference", "(", "func", "(", "TypeSpec", ")", "error", ")", "error", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", "+", "\"", "\"", ",", "r", ",", ")", ")", "\n", "}" ]
// ForEachTypeReference on an unresolved typeSpecReference will cause a system // panic.
[ "ForEachTypeReference", "on", "an", "unresolved", "typeSpecReference", "will", "cause", "a", "system", "panic", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/type.go#L146-L151
17,603
thriftrw/thriftrw-go
compile/type.go
compileTypeReference
func compileTypeReference(typ ast.Type) (TypeSpec, error) { if typ == nil { return nil, nil } switch t := typ.(type) { case ast.BaseType: return compileBaseType(t) case ast.MapType: return compileMapType(t) case ast.ListType: return compileListType(t) case ast.SetType: return compileSetType(t) case as...
go
func compileTypeReference(typ ast.Type) (TypeSpec, error) { if typ == nil { return nil, nil } switch t := typ.(type) { case ast.BaseType: return compileBaseType(t) case ast.MapType: return compileMapType(t) case ast.ListType: return compileListType(t) case ast.SetType: return compileSetType(t) case as...
[ "func", "compileTypeReference", "(", "typ", "ast", ".", "Type", ")", "(", "TypeSpec", ",", "error", ")", "{", "if", "typ", "==", "nil", "{", "return", "nil", ",", "nil", "\n", "}", "\n", "switch", "t", ":=", "typ", ".", "(", "type", ")", "{", "ca...
// compileTypeReference compiles the given AST type reference into a TypeSpec. // // The returned TypeSpec may need to be linked eventually.
[ "compileTypeReference", "compiles", "the", "given", "AST", "type", "reference", "into", "a", "TypeSpec", ".", "The", "returned", "TypeSpec", "may", "need", "to", "be", "linked", "eventually", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/type.go#L171-L189
17,604
thriftrw/thriftrw-go
internal/envelope/server.go
NewServer
func NewServer(p protocol.Protocol, h Handler) Server { return Server{p: p, h: h} }
go
func NewServer(p protocol.Protocol, h Handler) Server { return Server{p: p, h: h} }
[ "func", "NewServer", "(", "p", "protocol", ".", "Protocol", ",", "h", "Handler", ")", "Server", "{", "return", "Server", "{", "p", ":", "p", ",", "h", ":", "h", "}", "\n", "}" ]
// NewServer builds a new server.
[ "NewServer", "builds", "a", "new", "server", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/internal/envelope/server.go#L57-L59
17,605
thriftrw/thriftrw-go
internal/envelope/server.go
Handle
func (s Server) Handle(data []byte) ([]byte, error) { request, err := s.p.DecodeEnveloped(bytes.NewReader(data)) if err != nil { return nil, err } response := wire.Envelope{ Name: request.Name, SeqID: request.SeqID, Type: wire.Reply, } response.Value, err = s.h.Handle(request.Name, request.Value) if ...
go
func (s Server) Handle(data []byte) ([]byte, error) { request, err := s.p.DecodeEnveloped(bytes.NewReader(data)) if err != nil { return nil, err } response := wire.Envelope{ Name: request.Name, SeqID: request.SeqID, Type: wire.Reply, } response.Value, err = s.h.Handle(request.Name, request.Value) if ...
[ "func", "(", "s", "Server", ")", "Handle", "(", "data", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "request", ",", "err", ":=", "s", ".", "p", ".", "DecodeEnveloped", "(", "bytes", ".", "NewReader", "(", "data", ")", ...
// Handle handles the given binary payload.
[ "Handle", "handles", "the", "given", "binary", "payload", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/internal/envelope/server.go#L62-L95
17,606
thriftrw/thriftrw-go
internal/envelope/server.go
tappExc
func tappExc(err error, typ exception.ExceptionType) (wire.Value, error) { return (&exception.TApplicationException{ Message: ptr.String(err.Error()), Type: &typ, }).ToWire() }
go
func tappExc(err error, typ exception.ExceptionType) (wire.Value, error) { return (&exception.TApplicationException{ Message: ptr.String(err.Error()), Type: &typ, }).ToWire() }
[ "func", "tappExc", "(", "err", "error", ",", "typ", "exception", ".", "ExceptionType", ")", "(", "wire", ".", "Value", ",", "error", ")", "{", "return", "(", "&", "exception", ".", "TApplicationException", "{", "Message", ":", "ptr", ".", "String", "(", ...
// Helper to build TApplicationException wire.Values
[ "Helper", "to", "build", "TApplicationException", "wire", ".", "Values" ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/internal/envelope/server.go#L98-L103
17,607
thriftrw/thriftrw-go
internal/plugin/multi.go
Name
func (mh MultiHandle) Name() string { names := make([]string, 0, len(mh)) for _, h := range mh { names = append(names, h.Name()) } return fmt.Sprintf("MultiHandle{%v}", strings.Join(names, ", ")) }
go
func (mh MultiHandle) Name() string { names := make([]string, 0, len(mh)) for _, h := range mh { names = append(names, h.Name()) } return fmt.Sprintf("MultiHandle{%v}", strings.Join(names, ", ")) }
[ "func", "(", "mh", "MultiHandle", ")", "Name", "(", ")", "string", "{", "names", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "mh", ")", ")", "\n", "for", "_", ",", "h", ":=", "range", "mh", "{", "names", "=", "append", "...
// Name is the combined name of this plugin
[ "Name", "is", "the", "combined", "name", "of", "this", "plugin" ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/internal/plugin/multi.go#L36-L42
17,608
thriftrw/thriftrw-go
internal/plugin/multi.go
Close
func (mh MultiHandle) Close() error { return concurrent.Range(mh, func(_ int, h Handle) error { return h.Close() }) }
go
func (mh MultiHandle) Close() error { return concurrent.Range(mh, func(_ int, h Handle) error { return h.Close() }) }
[ "func", "(", "mh", "MultiHandle", ")", "Close", "(", ")", "error", "{", "return", "concurrent", ".", "Range", "(", "mh", ",", "func", "(", "_", "int", ",", "h", "Handle", ")", "error", "{", "return", "h", ".", "Close", "(", ")", "\n", "}", ")", ...
// Close closes all Handles associated with this MultiHandle.
[ "Close", "closes", "all", "Handles", "associated", "with", "this", "MultiHandle", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/internal/plugin/multi.go#L45-L49
17,609
thriftrw/thriftrw-go
internal/plugin/multi.go
ServiceGenerator
func (mh MultiHandle) ServiceGenerator() ServiceGenerator { msg := make(MultiServiceGenerator, 0, len(mh)) for _, h := range mh { if sg := h.ServiceGenerator(); sg != nil { msg = append(msg, sg) } } return msg }
go
func (mh MultiHandle) ServiceGenerator() ServiceGenerator { msg := make(MultiServiceGenerator, 0, len(mh)) for _, h := range mh { if sg := h.ServiceGenerator(); sg != nil { msg = append(msg, sg) } } return msg }
[ "func", "(", "mh", "MultiHandle", ")", "ServiceGenerator", "(", ")", "ServiceGenerator", "{", "msg", ":=", "make", "(", "MultiServiceGenerator", ",", "0", ",", "len", "(", "mh", ")", ")", "\n", "for", "_", ",", "h", ":=", "range", "mh", "{", "if", "s...
// ServiceGenerator returns a ServiceGenerator which calls into the // ServiceGenerators of all plugins associated with this MultiHandle and // consolidates their results.
[ "ServiceGenerator", "returns", "a", "ServiceGenerator", "which", "calls", "into", "the", "ServiceGenerators", "of", "all", "plugins", "associated", "with", "this", "MultiHandle", "and", "consolidates", "their", "results", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/internal/plugin/multi.go#L54-L62
17,610
thriftrw/thriftrw-go
internal/plugin/multi.go
Handle
func (msg MultiServiceGenerator) Handle() Handle { mh := make(MultiHandle, len(msg)) for i, sg := range msg { mh[i] = sg.Handle() } return mh }
go
func (msg MultiServiceGenerator) Handle() Handle { mh := make(MultiHandle, len(msg)) for i, sg := range msg { mh[i] = sg.Handle() } return mh }
[ "func", "(", "msg", "MultiServiceGenerator", ")", "Handle", "(", ")", "Handle", "{", "mh", ":=", "make", "(", "MultiHandle", ",", "len", "(", "msg", ")", ")", "\n", "for", "i", ",", "sg", ":=", "range", "msg", "{", "mh", "[", "i", "]", "=", "sg",...
// Handle returns a reference to the Handle that owns this ServiceGenerator.
[ "Handle", "returns", "a", "reference", "to", "the", "Handle", "that", "owns", "this", "ServiceGenerator", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/internal/plugin/multi.go#L69-L75
17,611
thriftrw/thriftrw-go
internal/plugin/multi.go
Generate
func (msg MultiServiceGenerator) Generate(req *api.GenerateServiceRequest) (*api.GenerateServiceResponse, error) { var ( lock sync.Mutex files = make(map[string][]byte) usedPaths = make(map[string]string) // path -> plugin name ) err := concurrent.Range(msg, func(_ int, sg ServiceGenerator) error { ...
go
func (msg MultiServiceGenerator) Generate(req *api.GenerateServiceRequest) (*api.GenerateServiceResponse, error) { var ( lock sync.Mutex files = make(map[string][]byte) usedPaths = make(map[string]string) // path -> plugin name ) err := concurrent.Range(msg, func(_ int, sg ServiceGenerator) error { ...
[ "func", "(", "msg", "MultiServiceGenerator", ")", "Generate", "(", "req", "*", "api", ".", "GenerateServiceRequest", ")", "(", "*", "api", ".", "GenerateServiceResponse", ",", "error", ")", "{", "var", "(", "lock", "sync", ".", "Mutex", "\n", "files", "=",...
// Generate calls all the service generators associated with this plugin and // consolidates their output. // // Any conflicts in the generated files will result in a failure.
[ "Generate", "calls", "all", "the", "service", "generators", "associated", "with", "this", "plugin", "and", "consolidates", "their", "output", ".", "Any", "conflicts", "in", "the", "generated", "files", "will", "result", "in", "a", "failure", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/internal/plugin/multi.go#L81-L112
17,612
thriftrw/thriftrw-go
internal/plugin/transport.go
NewTransportHandle
func NewTransportHandle(name string, t envelope.Transport) (Handle, error) { client := api.NewPluginClient(multiplex.NewClient( "Plugin", envelope.NewClient(_proto, t), )) handshake, err := client.Handshake(&api.HandshakeRequest{}) if err != nil { return nil, errHandshakeFailed{Name: name, Reason: err} } ...
go
func NewTransportHandle(name string, t envelope.Transport) (Handle, error) { client := api.NewPluginClient(multiplex.NewClient( "Plugin", envelope.NewClient(_proto, t), )) handshake, err := client.Handshake(&api.HandshakeRequest{}) if err != nil { return nil, errHandshakeFailed{Name: name, Reason: err} } ...
[ "func", "NewTransportHandle", "(", "name", "string", ",", "t", "envelope", ".", "Transport", ")", "(", "Handle", ",", "error", ")", "{", "client", ":=", "api", ".", "NewPluginClient", "(", "multiplex", ".", "NewClient", "(", "\"", "\"", ",", "envelope", ...
// NewTransportHandle builds a new Handle which speaks to the given transport. // // If the transport is an io.Closer, it will be closed when the handle is closed.
[ "NewTransportHandle", "builds", "a", "new", "Handle", "which", "speaks", "to", "the", "given", "transport", ".", "If", "the", "transport", "is", "an", "io", ".", "Closer", "it", "will", "be", "closed", "when", "the", "handle", "is", "closed", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/internal/plugin/transport.go#L52-L89
17,613
thriftrw/thriftrw-go
gen/service.go
Service
func Service(g Generator, s *compile.ServiceSpec) (map[string]*bytes.Buffer, error) { files := make(map[string]*bytes.Buffer) for _, functionName := range sortStringKeys(s.Functions) { fileName := fmt.Sprintf("%s_%s.go", strings.ToLower(s.Name), strings.ToLower(functionName)) function := s.Functions[functionNam...
go
func Service(g Generator, s *compile.ServiceSpec) (map[string]*bytes.Buffer, error) { files := make(map[string]*bytes.Buffer) for _, functionName := range sortStringKeys(s.Functions) { fileName := fmt.Sprintf("%s_%s.go", strings.ToLower(s.Name), strings.ToLower(functionName)) function := s.Functions[functionNam...
[ "func", "Service", "(", "g", "Generator", ",", "s", "*", "compile", ".", "ServiceSpec", ")", "(", "map", "[", "string", "]", "*", "bytes", ".", "Buffer", ",", "error", ")", "{", "files", ":=", "make", "(", "map", "[", "string", "]", "*", "bytes", ...
// Service generates code for the given service. // // Returns a map from file name to contents for that file. The file names are // relative to the package directory for the service.
[ "Service", "generates", "code", "for", "the", "given", "service", ".", "Returns", "a", "map", "from", "file", "name", "to", "contents", "for", "that", "file", ".", "The", "file", "names", "are", "relative", "to", "the", "package", "directory", "for", "the"...
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/gen/service.go#L36-L59
17,614
thriftrw/thriftrw-go
gen/service.go
ServiceFunction
func ServiceFunction(g Generator, s *compile.ServiceSpec, f *compile.FunctionSpec) error { argsName := functionNamePrefix(s, f) + "Args" argsGen := fieldGroupGenerator{ Namespace: NewNamespace(), Name: argsName, Fields: compile.FieldGroup(f.ArgsSpec), Doc: fmt.Sprintf( "%v represents the arguments ...
go
func ServiceFunction(g Generator, s *compile.ServiceSpec, f *compile.FunctionSpec) error { argsName := functionNamePrefix(s, f) + "Args" argsGen := fieldGroupGenerator{ Namespace: NewNamespace(), Name: argsName, Fields: compile.FieldGroup(f.ArgsSpec), Doc: fmt.Sprintf( "%v represents the arguments ...
[ "func", "ServiceFunction", "(", "g", "Generator", ",", "s", "*", "compile", ".", "ServiceSpec", ",", "f", "*", "compile", ".", "FunctionSpec", ")", "error", "{", "argsName", ":=", "functionNamePrefix", "(", "s", ",", "f", ")", "+", "\"", "\"", "\n", "a...
// ServiceFunction generates code for the given function of the given service.
[ "ServiceFunction", "generates", "code", "for", "the", "given", "function", "of", "the", "given", "service", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/gen/service.go#L62-L128
17,615
thriftrw/thriftrw-go
gen/service.go
functionParams
func functionParams(g Generator, f *compile.FunctionSpec) (string, error) { return g.TextTemplate( ` <- $params := newNamespace -> <- range .ArgsSpec> <- if .Required> <$params.NewName .Name> <typeReference .Type>, <- else> <$params.NewName .Name> <typeReferencePtr .Type>, <- end -> <end> `,...
go
func functionParams(g Generator, f *compile.FunctionSpec) (string, error) { return g.TextTemplate( ` <- $params := newNamespace -> <- range .ArgsSpec> <- if .Required> <$params.NewName .Name> <typeReference .Type>, <- else> <$params.NewName .Name> <typeReferencePtr .Type>, <- end -> <end> `,...
[ "func", "functionParams", "(", "g", "Generator", ",", "f", "*", "compile", ".", "FunctionSpec", ")", "(", "string", ",", "error", ")", "{", "return", "g", ".", "TextTemplate", "(", "`\n\t\t<- $params := newNamespace ->\n\t\t<- range .ArgsSpec>\n\t\t\t<- if .Required>\n\...
// functionParams returns a named parameter list for the given function.
[ "functionParams", "returns", "a", "named", "parameter", "list", "for", "the", "given", "function", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/gen/service.go#L131-L143
17,616
thriftrw/thriftrw-go
gen/service.go
functionNewArgs
func functionNewArgs(g Generator, s *compile.ServiceSpec, f *compile.FunctionSpec) (string, error) { return g.TextTemplate( ` <- $f := .Function -> <- $prefix := namePrefix .Service $f -> <- $params := newNamespace -> func( <- range $f.ArgsSpec> <- if .Required> <$params.NewName .Name> <typeRefer...
go
func functionNewArgs(g Generator, s *compile.ServiceSpec, f *compile.FunctionSpec) (string, error) { return g.TextTemplate( ` <- $f := .Function -> <- $prefix := namePrefix .Service $f -> <- $params := newNamespace -> func( <- range $f.ArgsSpec> <- if .Required> <$params.NewName .Name> <typeRefer...
[ "func", "functionNewArgs", "(", "g", "Generator", ",", "s", "*", "compile", ".", "ServiceSpec", ",", "f", "*", "compile", ".", "FunctionSpec", ")", "(", "string", ",", "error", ")", "{", "return", "g", ".", "TextTemplate", "(", "`\n\t\t<- $f := .Function ->\...
// functionNewArgs generates an expression which provides the NewArgs function // for the given Thrift function.
[ "functionNewArgs", "generates", "an", "expression", "which", "provides", "the", "NewArgs", "function", "for", "the", "given", "Thrift", "function", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/gen/service.go#L267-L301
17,617
thriftrw/thriftrw-go
protocol/binary/writer.go
BorrowWriter
func BorrowWriter(w io.Writer) *Writer { writer := writerPool.Get().(*Writer) writer.writer = w return writer }
go
func BorrowWriter(w io.Writer) *Writer { writer := writerPool.Get().(*Writer) writer.writer = w return writer }
[ "func", "BorrowWriter", "(", "w", "io", ".", "Writer", ")", "*", "Writer", "{", "writer", ":=", "writerPool", ".", "Get", "(", ")", ".", "(", "*", "Writer", ")", "\n", "writer", ".", "writer", "=", "w", "\n", "return", "writer", "\n", "}" ]
// BorrowWriter fetches a Writer from the system that will write its output to // the given io.Writer. // // This Writer must be returned back using ReturnWriter.
[ "BorrowWriter", "fetches", "a", "Writer", "from", "the", "system", "that", "will", "write", "its", "output", "to", "the", "given", "io", ".", "Writer", ".", "This", "Writer", "must", "be", "returned", "back", "using", "ReturnWriter", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/protocol/binary/writer.go#L61-L65
17,618
thriftrw/thriftrw-go
protocol/binary/writer.go
WriteValue
func (bw *Writer) WriteValue(v wire.Value) error { switch v.Type() { case wire.TBool: if v.GetBool() { return bw.writeByte(1) } return bw.writeByte(0) case wire.TI8: return bw.writeByte(byte(v.GetI8())) case wire.TDouble: value := math.Float64bits(v.GetDouble()) return bw.writeInt64(int64(value)) ...
go
func (bw *Writer) WriteValue(v wire.Value) error { switch v.Type() { case wire.TBool: if v.GetBool() { return bw.writeByte(1) } return bw.writeByte(0) case wire.TI8: return bw.writeByte(byte(v.GetI8())) case wire.TDouble: value := math.Float64bits(v.GetDouble()) return bw.writeInt64(int64(value)) ...
[ "func", "(", "bw", "*", "Writer", ")", "WriteValue", "(", "v", "wire", ".", "Value", ")", "error", "{", "switch", "v", ".", "Type", "(", ")", "{", "case", "wire", ".", "TBool", ":", "if", "v", ".", "GetBool", "(", ")", "{", "return", "bw", ".",...
// WriteValue writes the given Thrift value to the underlying stream using the // Thrift Binary Protocol.
[ "WriteValue", "writes", "the", "given", "Thrift", "value", "to", "the", "underlying", "stream", "using", "the", "Thrift", "Binary", "Protocol", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/protocol/binary/writer.go#L200-L246
17,619
thriftrw/thriftrw-go
ast/definition.go
Info
func (c *Constant) Info() DefinitionInfo { return DefinitionInfo{Name: c.Name, Line: c.Line} }
go
func (c *Constant) Info() DefinitionInfo { return DefinitionInfo{Name: c.Name, Line: c.Line} }
[ "func", "(", "c", "*", "Constant", ")", "Info", "(", ")", "DefinitionInfo", "{", "return", "DefinitionInfo", "{", "Name", ":", "c", ".", "Name", ",", "Line", ":", "c", ".", "Line", "}", "\n", "}" ]
// Info for Constant
[ "Info", "for", "Constant" ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/ast/definition.go#L61-L63
17,620
thriftrw/thriftrw-go
ast/definition.go
Info
func (t *Typedef) Info() DefinitionInfo { return DefinitionInfo{Name: t.Name, Line: t.Line} }
go
func (t *Typedef) Info() DefinitionInfo { return DefinitionInfo{Name: t.Name, Line: t.Line} }
[ "func", "(", "t", "*", "Typedef", ")", "Info", "(", ")", "DefinitionInfo", "{", "return", "DefinitionInfo", "{", "Name", ":", "t", ".", "Name", ",", "Line", ":", "t", ".", "Line", "}", "\n", "}" ]
// Info for Typedef.
[ "Info", "for", "Typedef", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/ast/definition.go#L91-L93
17,621
thriftrw/thriftrw-go
ast/definition.go
Info
func (e *Enum) Info() DefinitionInfo { return DefinitionInfo{Name: e.Name, Line: e.Line} }
go
func (e *Enum) Info() DefinitionInfo { return DefinitionInfo{Name: e.Name, Line: e.Line} }
[ "func", "(", "e", "*", "Enum", ")", "Info", "(", ")", "DefinitionInfo", "{", "return", "DefinitionInfo", "{", "Name", ":", "e", ".", "Name", ",", "Line", ":", "e", ".", "Line", "}", "\n", "}" ]
// Info for Enum.
[ "Info", "for", "Enum", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/ast/definition.go#L128-L130
17,622
thriftrw/thriftrw-go
ast/definition.go
Info
func (s *Struct) Info() DefinitionInfo { return DefinitionInfo{Name: s.Name, Line: s.Line} }
go
func (s *Struct) Info() DefinitionInfo { return DefinitionInfo{Name: s.Name, Line: s.Line} }
[ "func", "(", "s", "*", "Struct", ")", "Info", "(", ")", "DefinitionInfo", "{", "return", "DefinitionInfo", "{", "Name", ":", "s", ".", "Name", ",", "Line", ":", "s", ".", "Line", "}", "\n", "}" ]
// Info for Struct.
[ "Info", "for", "Struct", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/ast/definition.go#L207-L209
17,623
thriftrw/thriftrw-go
ast/definition.go
Info
func (s *Service) Info() DefinitionInfo { return DefinitionInfo{Name: s.Name, Line: s.Line} }
go
func (s *Service) Info() DefinitionInfo { return DefinitionInfo{Name: s.Name, Line: s.Line} }
[ "func", "(", "s", "*", "Service", ")", "Info", "(", ")", "DefinitionInfo", "{", "return", "DefinitionInfo", "{", "Name", ":", "s", ".", "Name", ",", "Line", ":", "s", ".", "Line", "}", "\n", "}" ]
// Info for Service.
[ "Info", "for", "Service", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/ast/definition.go#L243-L245
17,624
thriftrw/thriftrw-go
gen/generator.go
curryGenerator
func curryGenerator(f interface{}, g Generator) interface{} { typ := reflect.TypeOf(f) if typ.NumIn() > 0 && typ.In(0) == _typeOfGenerator { return curry.One(f, g) } return f }
go
func curryGenerator(f interface{}, g Generator) interface{} { typ := reflect.TypeOf(f) if typ.NumIn() > 0 && typ.In(0) == _typeOfGenerator { return curry.One(f, g) } return f }
[ "func", "curryGenerator", "(", "f", "interface", "{", "}", ",", "g", "Generator", ")", "interface", "{", "}", "{", "typ", ":=", "reflect", ".", "TypeOf", "(", "f", ")", "\n", "if", "typ", ".", "NumIn", "(", ")", ">", "0", "&&", "typ", ".", "In", ...
// curryGenerator adds g as the first argument to f if f accepts it. Otherwise f // is returned unmodified.
[ "curryGenerator", "adds", "g", "as", "the", "first", "argument", "to", "f", "if", "f", "accepts", "it", ".", "Otherwise", "f", "is", "returned", "unmodified", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/gen/generator.go#L113-L119
17,625
thriftrw/thriftrw-go
gen/generator.go
NewGenerator
func NewGenerator(o *GeneratorOptions) Generator { // TODO(abg): Determine package name from `namespace go` directive. namespace := NewNamespace() return &generator{ PackageName: o.PackageName, ImportPath: o.ImportPath, Namespace: namespace, importer: newImporter(namespace.Child()), mangl...
go
func NewGenerator(o *GeneratorOptions) Generator { // TODO(abg): Determine package name from `namespace go` directive. namespace := NewNamespace() return &generator{ PackageName: o.PackageName, ImportPath: o.ImportPath, Namespace: namespace, importer: newImporter(namespace.Child()), mangl...
[ "func", "NewGenerator", "(", "o", "*", "GeneratorOptions", ")", "Generator", "{", "// TODO(abg): Determine package name from `namespace go` directive.", "namespace", ":=", "NewNamespace", "(", ")", "\n", "return", "&", "generator", "{", "PackageName", ":", "o", ".", "...
// NewGenerator sets up a new generator for Go code.
[ "NewGenerator", "sets", "up", "a", "new", "generator", "for", "Go", "code", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/gen/generator.go#L153-L166
17,626
thriftrw/thriftrw-go
gen/generator.go
checkNoZap
func checkNoZap(g Generator) bool { if gen, ok := g.(*generator); ok { return gen.noZap } return false }
go
func checkNoZap(g Generator) bool { if gen, ok := g.(*generator); ok { return gen.noZap } return false }
[ "func", "checkNoZap", "(", "g", "Generator", ")", "bool", "{", "if", "gen", ",", "ok", ":=", "g", ".", "(", "*", "generator", ")", ";", "ok", "{", "return", "gen", ".", "noZap", "\n", "}", "\n", "return", "false", "\n", "}" ]
// checkNoZap returns whether the NoZap flag is passed.
[ "checkNoZap", "returns", "whether", "the", "NoZap", "flag", "is", "passed", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/gen/generator.go#L169-L174
17,627
thriftrw/thriftrw-go
gen/generator.go
TextTemplate
func (g *generator) TextTemplate(s string, data interface{}, opts ...TemplateOption) (string, error) { templateFuncs := template.FuncMap{ "formatDoc": formatDoc, "goCase": goCase, "goName": goName, "import": g.Import, "isHashable": isHashable, "setUsesMap": ...
go
func (g *generator) TextTemplate(s string, data interface{}, opts ...TemplateOption) (string, error) { templateFuncs := template.FuncMap{ "formatDoc": formatDoc, "goCase": goCase, "goName": goName, "import": g.Import, "isHashable": isHashable, "setUsesMap": ...
[ "func", "(", "g", "*", "generator", ")", "TextTemplate", "(", "s", "string", ",", "data", "interface", "{", "}", ",", "opts", "...", "TemplateOption", ")", "(", "string", ",", "error", ")", "{", "templateFuncs", ":=", "template", ".", "FuncMap", "{", "...
// TextTemplate renders the given template with the given template context.
[ "TextTemplate", "renders", "the", "given", "template", "with", "the", "given", "template", "context", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/gen/generator.go#L217-L263
17,628
thriftrw/thriftrw-go
gen/generator.go
appendDecl
func (g *generator) appendDecl(decl ast.Decl) { g.decls = append(g.decls, decl) }
go
func (g *generator) appendDecl(decl ast.Decl) { g.decls = append(g.decls, decl) }
[ "func", "(", "g", "*", "generator", ")", "appendDecl", "(", "decl", "ast", ".", "Decl", ")", "{", "g", ".", "decls", "=", "append", "(", "g", ".", "decls", ",", "decl", ")", "\n", "}" ]
// appendDecl appends a new declaration to the generator.
[ "appendDecl", "appends", "a", "new", "declaration", "to", "the", "generator", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/gen/generator.go#L515-L517
17,629
thriftrw/thriftrw-go
gen/generate.go
Generate
func Generate(m *compile.Module, o *Options) error { if !filepath.IsAbs(o.ThriftRoot) { return fmt.Errorf( "ThriftRoot must be an absolute path: %q is not absolute", o.ThriftRoot) } if !filepath.IsAbs(o.OutputDir) { return fmt.Errorf( "OutputDir must be an absolute path: %q is not absolute", o.Outpu...
go
func Generate(m *compile.Module, o *Options) error { if !filepath.IsAbs(o.ThriftRoot) { return fmt.Errorf( "ThriftRoot must be an absolute path: %q is not absolute", o.ThriftRoot) } if !filepath.IsAbs(o.OutputDir) { return fmt.Errorf( "OutputDir must be an absolute path: %q is not absolute", o.Outpu...
[ "func", "Generate", "(", "m", "*", "compile", ".", "Module", ",", "o", "*", "Options", ")", "error", "{", "if", "!", "filepath", ".", "IsAbs", "(", "o", ".", "ThriftRoot", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "o", ".", ...
// Generate generates code based on the given options.
[ "Generate", "generates", "code", "based", "on", "the", "given", "options", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/gen/generate.go#L82-L158
17,630
thriftrw/thriftrw-go
ast/visitor.go
Visit
func (f VisitorFunc) Visit(w Walker, n Node) Visitor { f(w, n) return f }
go
func (f VisitorFunc) Visit(w Walker, n Node) Visitor { f(w, n) return f }
[ "func", "(", "f", "VisitorFunc", ")", "Visit", "(", "w", "Walker", ",", "n", "Node", ")", "Visitor", "{", "f", "(", "w", ",", "n", ")", "\n", "return", "f", "\n", "}" ]
// Visit the given node and its descendants.
[ "Visit", "the", "given", "node", "and", "its", "descendants", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/ast/visitor.go#L48-L51
17,631
thriftrw/thriftrw-go
internal/plugin/flag.go
Handle
func (f *Flag) Handle() (Handle, error) { transport, err := process.NewClient(f.Command) if err != nil { return nil, fmt.Errorf("failed to open plugin %q: %v", f.Name, err) } handle, err := NewTransportHandle(f.Name, transport) if err != nil { return nil, multierr.Combine( fmt.Errorf("failed to open plugin...
go
func (f *Flag) Handle() (Handle, error) { transport, err := process.NewClient(f.Command) if err != nil { return nil, fmt.Errorf("failed to open plugin %q: %v", f.Name, err) } handle, err := NewTransportHandle(f.Name, transport) if err != nil { return nil, multierr.Combine( fmt.Errorf("failed to open plugin...
[ "func", "(", "f", "*", "Flag", ")", "Handle", "(", ")", "(", "Handle", ",", "error", ")", "{", "transport", ",", "err", ":=", "process", ".", "NewClient", "(", "f", ".", "Command", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", ...
// Handle gets a Handle to this plugin specification. // // The returned handle MUST be closed by the caller if error was nil.
[ "Handle", "gets", "a", "Handle", "to", "this", "plugin", "specification", ".", "The", "returned", "handle", "MUST", "be", "closed", "by", "the", "caller", "if", "error", "was", "nil", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/internal/plugin/flag.go#L57-L72
17,632
thriftrw/thriftrw-go
internal/plugin/flag.go
UnmarshalFlag
func (f *Flag) UnmarshalFlag(value string) error { tokens, err := shlex.Split(value, true /* posix */) if err != nil { return fmt.Errorf("invalid plugin %q: %v", value, err) } if len(tokens) < 1 { return fmt.Errorf("invalid plugin %q: please provide a name", value) } f.Name = tokens[0] exe := _pluginExecPr...
go
func (f *Flag) UnmarshalFlag(value string) error { tokens, err := shlex.Split(value, true /* posix */) if err != nil { return fmt.Errorf("invalid plugin %q: %v", value, err) } if len(tokens) < 1 { return fmt.Errorf("invalid plugin %q: please provide a name", value) } f.Name = tokens[0] exe := _pluginExecPr...
[ "func", "(", "f", "*", "Flag", ")", "UnmarshalFlag", "(", "value", "string", ")", "error", "{", "tokens", ",", "err", ":=", "shlex", ".", "Split", "(", "value", ",", "true", "/* posix */", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ...
// UnmarshalFlag parses a string specification of a plugin.
[ "UnmarshalFlag", "parses", "a", "string", "specification", "of", "a", "plugin", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/internal/plugin/flag.go#L75-L97
17,633
thriftrw/thriftrw-go
internal/plugin/flag.go
Handle
func (fs Flags) Handle() (MultiHandle, error) { var ( lock sync.Mutex multi MultiHandle ) err := concurrent.Range(fs, func(_ int, f Flag) error { h, err := f.Handle() if err != nil { return err } lock.Lock() defer lock.Unlock() multi = append(multi, h) return nil }) if err == nil { retu...
go
func (fs Flags) Handle() (MultiHandle, error) { var ( lock sync.Mutex multi MultiHandle ) err := concurrent.Range(fs, func(_ int, f Flag) error { h, err := f.Handle() if err != nil { return err } lock.Lock() defer lock.Unlock() multi = append(multi, h) return nil }) if err == nil { retu...
[ "func", "(", "fs", "Flags", ")", "Handle", "(", ")", "(", "MultiHandle", ",", "error", ")", "{", "var", "(", "lock", "sync", ".", "Mutex", "\n", "multi", "MultiHandle", "\n", ")", "\n\n", "err", ":=", "concurrent", ".", "Range", "(", "fs", ",", "fu...
// Handle gets a MultiHandle to all the plugins in this list or nil if the // list is empty. // // The returned handle MUST be closed by the caller if error was nil.
[ "Handle", "gets", "a", "MultiHandle", "to", "all", "the", "plugins", "in", "this", "list", "or", "nil", "if", "the", "list", "is", "empty", ".", "The", "returned", "handle", "MUST", "be", "closed", "by", "the", "caller", "if", "error", "was", "nil", "....
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/internal/plugin/flag.go#L106-L130
17,634
thriftrw/thriftrw-go
gen/wire.go
ToWirePtr
func (w *WireGenerator) ToWirePtr(g Generator, spec compile.TypeSpec, varName string) (string, error) { switch spec.(type) { case *compile.BoolSpec, *compile.I8Spec, *compile.I16Spec, *compile.I32Spec, *compile.I64Spec, *compile.DoubleSpec, *compile.StringSpec: return w.ToWire(g, spec, fmt.Sprintf("*(%s)", varNam...
go
func (w *WireGenerator) ToWirePtr(g Generator, spec compile.TypeSpec, varName string) (string, error) { switch spec.(type) { case *compile.BoolSpec, *compile.I8Spec, *compile.I16Spec, *compile.I32Spec, *compile.I64Spec, *compile.DoubleSpec, *compile.StringSpec: return w.ToWire(g, spec, fmt.Sprintf("*(%s)", varNam...
[ "func", "(", "w", "*", "WireGenerator", ")", "ToWirePtr", "(", "g", "Generator", ",", "spec", "compile", ".", "TypeSpec", ",", "varName", "string", ")", "(", "string", ",", "error", ")", "{", "switch", "spec", ".", "(", "type", ")", "{", "case", "*",...
// ToWirePtr is the same as ToWire expect `varName` is expected to be a // reference to a value of the given type.
[ "ToWirePtr", "is", "the", "same", "as", "ToWire", "expect", "varName", "is", "expected", "to", "be", "a", "reference", "to", "a", "value", "of", "the", "given", "type", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/gen/wire.go#L115-L125
17,635
thriftrw/thriftrw-go
gen/wire.go
FromWirePtr
func (w *WireGenerator) FromWirePtr(g Generator, spec compile.TypeSpec, lhs string, value string) (string, error) { if !isPrimitiveType(spec) { // Everything else can be assigned to directly. out, err := w.FromWire(g, spec, value) if err != nil { return "", err } return fmt.Sprintf("%s, err = %s", lhs, ou...
go
func (w *WireGenerator) FromWirePtr(g Generator, spec compile.TypeSpec, lhs string, value string) (string, error) { if !isPrimitiveType(spec) { // Everything else can be assigned to directly. out, err := w.FromWire(g, spec, value) if err != nil { return "", err } return fmt.Sprintf("%s, err = %s", lhs, ou...
[ "func", "(", "w", "*", "WireGenerator", ")", "FromWirePtr", "(", "g", "Generator", ",", "spec", "compile", ".", "TypeSpec", ",", "lhs", "string", ",", "value", "string", ")", "(", "string", ",", "error", ")", "{", "if", "!", "isPrimitiveType", "(", "sp...
// FromWirePtr generates a string assigning the given Value to the given lhs, // which is a pointer to a value of the given type. // // A variable err of type error MUST be in scope and will be assigned the // parse error, if any.
[ "FromWirePtr", "generates", "a", "string", "assigning", "the", "given", "Value", "to", "the", "given", "lhs", "which", "is", "a", "pointer", "to", "a", "value", "of", "the", "given", "type", ".", "A", "variable", "err", "of", "type", "error", "MUST", "be...
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/gen/wire.go#L193-L215
17,636
thriftrw/thriftrw-go
gen/wire.go
TypeCode
func TypeCode(g Generator, spec compile.TypeSpec) string { wire := g.Import("go.uber.org/thriftrw/wire") spec = compile.RootTypeSpec(spec) switch spec.(type) { case *compile.BoolSpec: return fmt.Sprintf("%s.TBool", wire) case *compile.I8Spec: return fmt.Sprintf("%s.TI8", wire) case *compile.I16Spec: return...
go
func TypeCode(g Generator, spec compile.TypeSpec) string { wire := g.Import("go.uber.org/thriftrw/wire") spec = compile.RootTypeSpec(spec) switch spec.(type) { case *compile.BoolSpec: return fmt.Sprintf("%s.TBool", wire) case *compile.I8Spec: return fmt.Sprintf("%s.TI8", wire) case *compile.I16Spec: return...
[ "func", "TypeCode", "(", "g", "Generator", ",", "spec", "compile", ".", "TypeSpec", ")", "string", "{", "wire", ":=", "g", ".", "Import", "(", "\"", "\"", ")", "\n", "spec", "=", "compile", ".", "RootTypeSpec", "(", "spec", ")", "\n\n", "switch", "sp...
// TypeCode gets an expression of type 'wire.Type' that represents the // over-the-wire type code for the given TypeSpec.
[ "TypeCode", "gets", "an", "expression", "of", "type", "wire", ".", "Type", "that", "represents", "the", "over", "-", "the", "-", "wire", "type", "code", "for", "the", "given", "TypeSpec", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/gen/wire.go#L219-L251
17,637
thriftrw/thriftrw-go
compile/field.go
isRequired
func (r fieldRequiredness) isRequired(src *ast.Field) (bool, error) { switch r { case explicitRequiredness: if src.Requiredness == ast.Unspecified { return false, requirednessRequiredError{ FieldName: src.Name, Line: src.Line, } } case noRequiredFields: if src.Requiredness == ast.Required { ...
go
func (r fieldRequiredness) isRequired(src *ast.Field) (bool, error) { switch r { case explicitRequiredness: if src.Requiredness == ast.Unspecified { return false, requirednessRequiredError{ FieldName: src.Name, Line: src.Line, } } case noRequiredFields: if src.Requiredness == ast.Required { ...
[ "func", "(", "r", "fieldRequiredness", ")", "isRequired", "(", "src", "*", "ast", ".", "Field", ")", "(", "bool", ",", "error", ")", "{", "switch", "r", "{", "case", "explicitRequiredness", ":", "if", "src", ".", "Requiredness", "==", "ast", ".", "Unsp...
// isRequired checks if a field should be required based on the // fieldRequiredness setting. An error is returned if the specified requiredness // is disallowed by this configuration.
[ "isRequired", "checks", "if", "a", "field", "should", "be", "required", "based", "on", "the", "fieldRequiredness", "setting", ".", "An", "error", "is", "returned", "if", "the", "specified", "requiredness", "is", "disallowed", "by", "this", "configuration", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/field.go#L56-L79
17,638
thriftrw/thriftrw-go
compile/field.go
compileField
func compileField(src *ast.Field, options fieldOptions) (*FieldSpec, error) { if src.ID < 1 || src.ID > math.MaxInt16 { return nil, fieldIDOutOfBoundsError{ID: src.ID, Name: src.Name} } required, err := options.requiredness.isRequired(src) if err != nil { return nil, err } if options.disallowDefaultValue &&...
go
func compileField(src *ast.Field, options fieldOptions) (*FieldSpec, error) { if src.ID < 1 || src.ID > math.MaxInt16 { return nil, fieldIDOutOfBoundsError{ID: src.ID, Name: src.Name} } required, err := options.requiredness.isRequired(src) if err != nil { return nil, err } if options.disallowDefaultValue &&...
[ "func", "compileField", "(", "src", "*", "ast", ".", "Field", ",", "options", "fieldOptions", ")", "(", "*", "FieldSpec", ",", "error", ")", "{", "if", "src", ".", "ID", "<", "1", "||", "src", ".", "ID", ">", "math", ".", "MaxInt16", "{", "return",...
// compileField compiles the given Field source into a FieldSpec.
[ "compileField", "compiles", "the", "given", "Field", "source", "into", "a", "FieldSpec", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/field.go#L105-L150
17,639
thriftrw/thriftrw-go
compile/field.go
Link
func (f *FieldSpec) Link(scope Scope) (err error) { if f.Type, err = f.Type.Link(scope); err != nil { return err } if f.Default != nil { f.Default, err = f.Default.Link(scope, f.Type) } return err }
go
func (f *FieldSpec) Link(scope Scope) (err error) { if f.Type, err = f.Type.Link(scope); err != nil { return err } if f.Default != nil { f.Default, err = f.Default.Link(scope, f.Type) } return err }
[ "func", "(", "f", "*", "FieldSpec", ")", "Link", "(", "scope", "Scope", ")", "(", "err", "error", ")", "{", "if", "f", ".", "Type", ",", "err", "=", "f", ".", "Type", ".", "Link", "(", "scope", ")", ";", "err", "!=", "nil", "{", "return", "er...
// Link links together any references made by the FieldSpec.
[ "Link", "links", "together", "any", "references", "made", "by", "the", "FieldSpec", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/field.go#L158-L166
17,640
thriftrw/thriftrw-go
compile/field.go
compileFields
func compileFields(src []*ast.Field, options fieldOptions) (FieldGroup, error) { fieldsNS := newNamespace(caseInsensitive) usedIDs := make(map[int16]string) fields := make([]*FieldSpec, 0, len(src)) for _, astField := range src { if err := fieldsNS.claim(astField.Name, astField.Line); err != nil { return nil,...
go
func compileFields(src []*ast.Field, options fieldOptions) (FieldGroup, error) { fieldsNS := newNamespace(caseInsensitive) usedIDs := make(map[int16]string) fields := make([]*FieldSpec, 0, len(src)) for _, astField := range src { if err := fieldsNS.claim(astField.Name, astField.Line); err != nil { return nil,...
[ "func", "compileFields", "(", "src", "[", "]", "*", "ast", ".", "Field", ",", "options", "fieldOptions", ")", "(", "FieldGroup", ",", "error", ")", "{", "fieldsNS", ":=", "newNamespace", "(", "caseInsensitive", ")", "\n", "usedIDs", ":=", "make", "(", "m...
// compileFields compiles a collection of AST fields into a FieldGroup.
[ "compileFields", "compiles", "a", "collection", "of", "AST", "fields", "into", "a", "FieldGroup", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/field.go#L177-L216
17,641
thriftrw/thriftrw-go
compile/field.go
FindByName
func (fg FieldGroup) FindByName(name string) (*FieldSpec, error) { for _, field := range fg { if field.Name == name { return field, nil } } return nil, fmt.Errorf("unknown field %v", name) }
go
func (fg FieldGroup) FindByName(name string) (*FieldSpec, error) { for _, field := range fg { if field.Name == name { return field, nil } } return nil, fmt.Errorf("unknown field %v", name) }
[ "func", "(", "fg", "FieldGroup", ")", "FindByName", "(", "name", "string", ")", "(", "*", "FieldSpec", ",", "error", ")", "{", "for", "_", ",", "field", ":=", "range", "fg", "{", "if", "field", ".", "Name", "==", "name", "{", "return", "field", ","...
// FindByName retrieves the FieldSpec for the field with the given name.
[ "FindByName", "retrieves", "the", "FieldSpec", "for", "the", "field", "with", "the", "given", "name", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/field.go#L219-L226
17,642
thriftrw/thriftrw-go
compile/field.go
Link
func (fg FieldGroup) Link(scope Scope) error { for _, field := range fg { if err := field.Link(scope); err != nil { return err } } return nil }
go
func (fg FieldGroup) Link(scope Scope) error { for _, field := range fg { if err := field.Link(scope); err != nil { return err } } return nil }
[ "func", "(", "fg", "FieldGroup", ")", "Link", "(", "scope", "Scope", ")", "error", "{", "for", "_", ",", "field", ":=", "range", "fg", "{", "if", "err", ":=", "field", ".", "Link", "(", "scope", ")", ";", "err", "!=", "nil", "{", "return", "err",...
// Link resolves references made by fields inside the FieldGroup.
[ "Link", "resolves", "references", "made", "by", "fields", "inside", "the", "FieldGroup", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/field.go#L229-L237
17,643
thriftrw/thriftrw-go
compile/field.go
ForEachTypeReference
func (fg FieldGroup) ForEachTypeReference(f func(TypeSpec) error) error { for _, field := range fg { if err := f(field.Type); err != nil { return err } } return nil }
go
func (fg FieldGroup) ForEachTypeReference(f func(TypeSpec) error) error { for _, field := range fg { if err := f(field.Type); err != nil { return err } } return nil }
[ "func", "(", "fg", "FieldGroup", ")", "ForEachTypeReference", "(", "f", "func", "(", "TypeSpec", ")", "error", ")", "error", "{", "for", "_", ",", "field", ":=", "range", "fg", "{", "if", "err", ":=", "f", "(", "field", ".", "Type", ")", ";", "err"...
// ForEachTypeReference applies the given function on each TypeSpec in the // FieldGroup.
[ "ForEachTypeReference", "applies", "the", "given", "function", "on", "each", "TypeSpec", "in", "the", "FieldGroup", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/field.go#L241-L248
17,644
thriftrw/thriftrw-go
compile/module.go
LookupType
func (m *Module) LookupType(name string) (TypeSpec, error) { if t, ok := m.Types[name]; ok { return t, nil } return nil, lookupError{Name: name} }
go
func (m *Module) LookupType(name string) (TypeSpec, error) { if t, ok := m.Types[name]; ok { return t, nil } return nil, lookupError{Name: name} }
[ "func", "(", "m", "*", "Module", ")", "LookupType", "(", "name", "string", ")", "(", "TypeSpec", ",", "error", ")", "{", "if", "t", ",", "ok", ":=", "m", ".", "Types", "[", "name", "]", ";", "ok", "{", "return", "t", ",", "nil", "\n", "}", "\...
// LookupType for Module.
[ "LookupType", "for", "Module", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/module.go#L53-L59
17,645
thriftrw/thriftrw-go
compile/module.go
LookupConstant
func (m *Module) LookupConstant(name string) (*Constant, error) { if c, ok := m.Constants[name]; ok { return c, nil } return nil, lookupError{Name: name} }
go
func (m *Module) LookupConstant(name string) (*Constant, error) { if c, ok := m.Constants[name]; ok { return c, nil } return nil, lookupError{Name: name} }
[ "func", "(", "m", "*", "Module", ")", "LookupConstant", "(", "name", "string", ")", "(", "*", "Constant", ",", "error", ")", "{", "if", "c", ",", "ok", ":=", "m", ".", "Constants", "[", "name", "]", ";", "ok", "{", "return", "c", ",", "nil", "\...
// LookupConstant for Module.
[ "LookupConstant", "for", "Module", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/module.go#L62-L68
17,646
thriftrw/thriftrw-go
compile/module.go
LookupService
func (m *Module) LookupService(name string) (*ServiceSpec, error) { if s, ok := m.Services[name]; ok { return s, nil } return nil, lookupError{Name: name} }
go
func (m *Module) LookupService(name string) (*ServiceSpec, error) { if s, ok := m.Services[name]; ok { return s, nil } return nil, lookupError{Name: name} }
[ "func", "(", "m", "*", "Module", ")", "LookupService", "(", "name", "string", ")", "(", "*", "ServiceSpec", ",", "error", ")", "{", "if", "s", ",", "ok", ":=", "m", ".", "Services", "[", "name", "]", ";", "ok", "{", "return", "s", ",", "nil", "...
// LookupService for Module.
[ "LookupService", "for", "Module", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/module.go#L71-L77
17,647
thriftrw/thriftrw-go
compile/module.go
LookupInclude
func (m *Module) LookupInclude(name string) (Scope, error) { if s, ok := m.Includes[name]; ok { return s.Module, nil } return nil, lookupError{Name: name} }
go
func (m *Module) LookupInclude(name string) (Scope, error) { if s, ok := m.Includes[name]; ok { return s.Module, nil } return nil, lookupError{Name: name} }
[ "func", "(", "m", "*", "Module", ")", "LookupInclude", "(", "name", "string", ")", "(", "Scope", ",", "error", ")", "{", "if", "s", ",", "ok", ":=", "m", ".", "Includes", "[", "name", "]", ";", "ok", "{", "return", "s", ".", "Module", ",", "nil...
// LookupInclude for Module.
[ "LookupInclude", "for", "Module", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/module.go#L80-L86
17,648
thriftrw/thriftrw-go
compile/module.go
Walk
func (m *Module) Walk(f func(*Module) error) error { visited := make(map[string]struct{}) toVisit := make([]*Module, 0, 100) toVisit = append(toVisit, m) for len(toVisit) > 0 { m := toVisit[0] toVisit = toVisit[1:] if _, ok := visited[m.ThriftPath]; ok { continue } visited[m.ThriftPath] = struct{}{...
go
func (m *Module) Walk(f func(*Module) error) error { visited := make(map[string]struct{}) toVisit := make([]*Module, 0, 100) toVisit = append(toVisit, m) for len(toVisit) > 0 { m := toVisit[0] toVisit = toVisit[1:] if _, ok := visited[m.ThriftPath]; ok { continue } visited[m.ThriftPath] = struct{}{...
[ "func", "(", "m", "*", "Module", ")", "Walk", "(", "f", "func", "(", "*", "Module", ")", "error", ")", "error", "{", "visited", ":=", "make", "(", "map", "[", "string", "]", "struct", "{", "}", ")", "\n\n", "toVisit", ":=", "make", "(", "[", "]...
// Walk the module tree starting at the given module. This module and all its // direct and transitive dependencies will be visited exactly once in an // unspecified order. The walk will stop on the first error returned by `f`.
[ "Walk", "the", "module", "tree", "starting", "at", "the", "given", "module", ".", "This", "module", "and", "all", "its", "direct", "and", "transitive", "dependencies", "will", "be", "visited", "exactly", "once", "in", "an", "unspecified", "order", ".", "The"...
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/module.go#L91-L116
17,649
thriftrw/thriftrw-go
compile/constant_value.go
compileConstantValue
func compileConstantValue(v ast.ConstantValue) ConstantValue { if v == nil { return nil } // TODO(abg): Support typedefs switch src := v.(type) { case ast.ConstantReference: return constantReference(src) case ast.ConstantMap: return compileConstantMap(src) case ast.ConstantList: return compileConstantL...
go
func compileConstantValue(v ast.ConstantValue) ConstantValue { if v == nil { return nil } // TODO(abg): Support typedefs switch src := v.(type) { case ast.ConstantReference: return constantReference(src) case ast.ConstantMap: return compileConstantMap(src) case ast.ConstantList: return compileConstantL...
[ "func", "compileConstantValue", "(", "v", "ast", ".", "ConstantValue", ")", "ConstantValue", "{", "if", "v", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "// TODO(abg): Support typedefs", "switch", "src", ":=", "v", ".", "(", "type", ")", "{", "ca...
// compileConstantValue compiles a constant value AST into a ConstantValue.
[ "compileConstantValue", "compiles", "a", "constant", "value", "AST", "into", "a", "ConstantValue", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/constant_value.go#L38-L63
17,650
thriftrw/thriftrw-go
compile/constant_value.go
Link
func (c ConstantBool) Link(scope Scope, t TypeSpec) (ConstantValue, error) { if _, ok := RootTypeSpec(t).(*BoolSpec); !ok { return nil, constantValueCastError{Value: c, Type: t} } return c, nil }
go
func (c ConstantBool) Link(scope Scope, t TypeSpec) (ConstantValue, error) { if _, ok := RootTypeSpec(t).(*BoolSpec); !ok { return nil, constantValueCastError{Value: c, Type: t} } return c, nil }
[ "func", "(", "c", "ConstantBool", ")", "Link", "(", "scope", "Scope", ",", "t", "TypeSpec", ")", "(", "ConstantValue", ",", "error", ")", "{", "if", "_", ",", "ok", ":=", "RootTypeSpec", "(", "t", ")", ".", "(", "*", "BoolSpec", ")", ";", "!", "o...
// Link for ConstantBool
[ "Link", "for", "ConstantBool" ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/constant_value.go#L80-L85
17,651
thriftrw/thriftrw-go
compile/constant_value.go
Link
func (c ConstantInt) Link(scope Scope, t TypeSpec) (ConstantValue, error) { rt := RootTypeSpec(t) switch spec := rt.(type) { case *I8Spec, *I16Spec, *I32Spec, *I64Spec: // TODO bounds checks? return c, nil case *DoubleSpec: return ConstantDouble(float64(c)).Link(scope, t) case *BoolSpec: switch v := int64(...
go
func (c ConstantInt) Link(scope Scope, t TypeSpec) (ConstantValue, error) { rt := RootTypeSpec(t) switch spec := rt.(type) { case *I8Spec, *I16Spec, *I32Spec, *I64Spec: // TODO bounds checks? return c, nil case *DoubleSpec: return ConstantDouble(float64(c)).Link(scope, t) case *BoolSpec: switch v := int64(...
[ "func", "(", "c", "ConstantInt", ")", "Link", "(", "scope", "Scope", ",", "t", "TypeSpec", ")", "(", "ConstantValue", ",", "error", ")", "{", "rt", ":=", "RootTypeSpec", "(", "t", ")", "\n", "switch", "spec", ":=", "rt", ".", "(", "type", ")", "{",...
// Link for ConstantInt.
[ "Link", "for", "ConstantInt", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/constant_value.go#L88-L125
17,652
thriftrw/thriftrw-go
compile/constant_value.go
Link
func (c ConstantString) Link(scope Scope, t TypeSpec) (ConstantValue, error) { // TODO(abg): Are binary literals a thing? if _, ok := RootTypeSpec(t).(*StringSpec); !ok { return nil, constantValueCastError{Value: c, Type: t} } return c, nil }
go
func (c ConstantString) Link(scope Scope, t TypeSpec) (ConstantValue, error) { // TODO(abg): Are binary literals a thing? if _, ok := RootTypeSpec(t).(*StringSpec); !ok { return nil, constantValueCastError{Value: c, Type: t} } return c, nil }
[ "func", "(", "c", "ConstantString", ")", "Link", "(", "scope", "Scope", ",", "t", "TypeSpec", ")", "(", "ConstantValue", ",", "error", ")", "{", "// TODO(abg): Are binary literals a thing?", "if", "_", ",", "ok", ":=", "RootTypeSpec", "(", "t", ")", ".", "...
// Link for ConstantString.
[ "Link", "for", "ConstantString", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/constant_value.go#L128-L134
17,653
thriftrw/thriftrw-go
compile/constant_value.go
Link
func (c ConstantDouble) Link(scope Scope, t TypeSpec) (ConstantValue, error) { if _, ok := RootTypeSpec(t).(*DoubleSpec); !ok { return nil, constantValueCastError{Value: c, Type: t} } return c, nil }
go
func (c ConstantDouble) Link(scope Scope, t TypeSpec) (ConstantValue, error) { if _, ok := RootTypeSpec(t).(*DoubleSpec); !ok { return nil, constantValueCastError{Value: c, Type: t} } return c, nil }
[ "func", "(", "c", "ConstantDouble", ")", "Link", "(", "scope", "Scope", ",", "t", "TypeSpec", ")", "(", "ConstantValue", ",", "error", ")", "{", "if", "_", ",", "ok", ":=", "RootTypeSpec", "(", "t", ")", ".", "(", "*", "DoubleSpec", ")", ";", "!", ...
// Link for ConstantDouble.
[ "Link", "for", "ConstantDouble", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/constant_value.go#L137-L142
17,654
thriftrw/thriftrw-go
compile/constant_value.go
buildConstantStruct
func buildConstantStruct(c ConstantMap) (*ConstantStruct, error) { fields := make(map[string]ConstantValue, len(c)) for _, pair := range c { s, isString := pair.Key.(ConstantString) if !isString { return nil, fmt.Errorf( "%v is not a string: all keys must be strings", pair.Key) } fields[string(s)] = pa...
go
func buildConstantStruct(c ConstantMap) (*ConstantStruct, error) { fields := make(map[string]ConstantValue, len(c)) for _, pair := range c { s, isString := pair.Key.(ConstantString) if !isString { return nil, fmt.Errorf( "%v is not a string: all keys must be strings", pair.Key) } fields[string(s)] = pa...
[ "func", "buildConstantStruct", "(", "c", "ConstantMap", ")", "(", "*", "ConstantStruct", ",", "error", ")", "{", "fields", ":=", "make", "(", "map", "[", "string", "]", "ConstantValue", ",", "len", "(", "c", ")", ")", "\n", "for", "_", ",", "pair", "...
// buildConstantStruct builds a constant struct from a ConstantMap.
[ "buildConstantStruct", "builds", "a", "constant", "struct", "from", "a", "ConstantMap", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/constant_value.go#L150-L161
17,655
thriftrw/thriftrw-go
compile/constant_value.go
Link
func (c *ConstantStruct) Link(scope Scope, t TypeSpec) (ConstantValue, error) { s, ok := RootTypeSpec(t).(*StructSpec) if !ok { return nil, constantValueCastError{Value: c, Type: t} } for _, field := range s.Fields { f, ok := c.Fields[field.Name] if !ok { if field.Default == nil { if field.Required { ...
go
func (c *ConstantStruct) Link(scope Scope, t TypeSpec) (ConstantValue, error) { s, ok := RootTypeSpec(t).(*StructSpec) if !ok { return nil, constantValueCastError{Value: c, Type: t} } for _, field := range s.Fields { f, ok := c.Fields[field.Name] if !ok { if field.Default == nil { if field.Required { ...
[ "func", "(", "c", "*", "ConstantStruct", ")", "Link", "(", "scope", "Scope", ",", "t", "TypeSpec", ")", "(", "ConstantValue", ",", "error", ")", "{", "s", ",", "ok", ":=", "RootTypeSpec", "(", "t", ")", ".", "(", "*", "StructSpec", ")", "\n", "if",...
// Link for ConstantStruct
[ "Link", "for", "ConstantStruct" ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/constant_value.go#L164-L203
17,656
thriftrw/thriftrw-go
compile/constant_value.go
Link
func (c ConstantMap) Link(scope Scope, t TypeSpec) (ConstantValue, error) { rt := RootTypeSpec(t) if _, isStruct := rt.(*StructSpec); isStruct { cs, err := buildConstantStruct(c) if err != nil { return nil, constantValueCastError{ Value: c, Type: t, Reason: err, } } return cs.Link(scope, ...
go
func (c ConstantMap) Link(scope Scope, t TypeSpec) (ConstantValue, error) { rt := RootTypeSpec(t) if _, isStruct := rt.(*StructSpec); isStruct { cs, err := buildConstantStruct(c) if err != nil { return nil, constantValueCastError{ Value: c, Type: t, Reason: err, } } return cs.Link(scope, ...
[ "func", "(", "c", "ConstantMap", ")", "Link", "(", "scope", "Scope", ",", "t", "TypeSpec", ")", "(", "ConstantValue", ",", "error", ")", "{", "rt", ":=", "RootTypeSpec", "(", "t", ")", "\n", "if", "_", ",", "isStruct", ":=", "rt", ".", "(", "*", ...
// Link for ConstantMap.
[ "Link", "for", "ConstantMap", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/constant_value.go#L226-L262
17,657
thriftrw/thriftrw-go
compile/constant_value.go
Link
func (c ConstantSet) Link(scope Scope, t TypeSpec) (ConstantValue, error) { s, ok := RootTypeSpec(t).(*SetSpec) if !ok { return nil, constantValueCastError{Value: c, Type: t} } // TODO(abg): Track whether things are linked so that we don't re-link here // TODO(abg): Fail for duplicates values := make([]Constan...
go
func (c ConstantSet) Link(scope Scope, t TypeSpec) (ConstantValue, error) { s, ok := RootTypeSpec(t).(*SetSpec) if !ok { return nil, constantValueCastError{Value: c, Type: t} } // TODO(abg): Track whether things are linked so that we don't re-link here // TODO(abg): Fail for duplicates values := make([]Constan...
[ "func", "(", "c", "ConstantSet", ")", "Link", "(", "scope", "Scope", ",", "t", "TypeSpec", ")", "(", "ConstantValue", ",", "error", ")", "{", "s", ",", "ok", ":=", "RootTypeSpec", "(", "t", ")", ".", "(", "*", "SetSpec", ")", "\n", "if", "!", "ok...
// Link for ConstantSet.
[ "Link", "for", "ConstantSet", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/constant_value.go#L268-L286
17,658
thriftrw/thriftrw-go
compile/constant_value.go
Link
func (c ConstantList) Link(scope Scope, t TypeSpec) (ConstantValue, error) { rt := RootTypeSpec(t) if _, isSet := rt.(*SetSpec); isSet { return ConstantSet(c).Link(scope, t) } l, ok := rt.(*ListSpec) if !ok { return nil, constantValueCastError{Value: c, Type: t} } values := make([]ConstantValue, len(c)) f...
go
func (c ConstantList) Link(scope Scope, t TypeSpec) (ConstantValue, error) { rt := RootTypeSpec(t) if _, isSet := rt.(*SetSpec); isSet { return ConstantSet(c).Link(scope, t) } l, ok := rt.(*ListSpec) if !ok { return nil, constantValueCastError{Value: c, Type: t} } values := make([]ConstantValue, len(c)) f...
[ "func", "(", "c", "ConstantList", ")", "Link", "(", "scope", "Scope", ",", "t", "TypeSpec", ")", "(", "ConstantValue", ",", "error", ")", "{", "rt", ":=", "RootTypeSpec", "(", "t", ")", "\n", "if", "_", ",", "isSet", ":=", "rt", ".", "(", "*", "S...
// Link for ConstantList.
[ "Link", "for", "ConstantList", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/constant_value.go#L300-L321
17,659
thriftrw/thriftrw-go
compile/constant_value.go
Link
func (c ConstReference) Link(scope Scope, t TypeSpec) (ConstantValue, error) { if t == c.Target.Type { return c, nil } return c.Target.Value.Link(scope, t) }
go
func (c ConstReference) Link(scope Scope, t TypeSpec) (ConstantValue, error) { if t == c.Target.Type { return c, nil } return c.Target.Value.Link(scope, t) }
[ "func", "(", "c", "ConstReference", ")", "Link", "(", "scope", "Scope", ",", "t", "TypeSpec", ")", "(", "ConstantValue", ",", "error", ")", "{", "if", "t", "==", "c", ".", "Target", ".", "Type", "{", "return", "c", ",", "nil", "\n", "}", "\n", "r...
// Link for ConstReference.
[ "Link", "for", "ConstReference", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/constant_value.go#L330-L335
17,660
thriftrw/thriftrw-go
compile/constant_value.go
Link
func (e EnumItemReference) Link(scope Scope, t TypeSpec) (ConstantValue, error) { if RootTypeSpec(t) != e.Enum { return nil, constantValueCastError{Value: e, Type: t} } return e, nil }
go
func (e EnumItemReference) Link(scope Scope, t TypeSpec) (ConstantValue, error) { if RootTypeSpec(t) != e.Enum { return nil, constantValueCastError{Value: e, Type: t} } return e, nil }
[ "func", "(", "e", "EnumItemReference", ")", "Link", "(", "scope", "Scope", ",", "t", "TypeSpec", ")", "(", "ConstantValue", ",", "error", ")", "{", "if", "RootTypeSpec", "(", "t", ")", "!=", "e", ".", "Enum", "{", "return", "nil", ",", "constantValueCa...
// Link for EnumItemReference.
[ "Link", "for", "EnumItemReference", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/constant_value.go#L345-L350
17,661
thriftrw/thriftrw-go
compile/constant_value.go
Link
func (r constantReference) Link(scope Scope, t TypeSpec) (ConstantValue, error) { src := ast.ConstantReference(r) c, err := scope.LookupConstant(src.Name) if err == nil { if err := c.Link(scope); err != nil { return nil, err } return ConstReference{Target: c}.Link(scope, t) } mname, iname := splitInclud...
go
func (r constantReference) Link(scope Scope, t TypeSpec) (ConstantValue, error) { src := ast.ConstantReference(r) c, err := scope.LookupConstant(src.Name) if err == nil { if err := c.Link(scope); err != nil { return nil, err } return ConstReference{Target: c}.Link(scope, t) } mname, iname := splitInclud...
[ "func", "(", "r", "constantReference", ")", "Link", "(", "scope", "Scope", ",", "t", "TypeSpec", ")", "(", "ConstantValue", ",", "error", ")", "{", "src", ":=", "ast", ".", "ConstantReference", "(", "r", ")", "\n\n", "c", ",", "err", ":=", "scope", "...
// Link a constantReference. // // This resolves the reference to a ConstReference or an EnumItemReference.
[ "Link", "a", "constantReference", ".", "This", "resolves", "the", "reference", "to", "a", "ConstReference", "or", "an", "EnumItemReference", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/constant_value.go#L361-L422
17,662
thriftrw/thriftrw-go
compile/constant_value.go
lookupEnum
func lookupEnum(scope Scope, name string) (*EnumSpec, bool) { t, err := scope.LookupType(name) if err != nil { return nil, false } if enum, ok := t.(*EnumSpec); ok { return enum, true } return nil, false }
go
func lookupEnum(scope Scope, name string) (*EnumSpec, bool) { t, err := scope.LookupType(name) if err != nil { return nil, false } if enum, ok := t.(*EnumSpec); ok { return enum, true } return nil, false }
[ "func", "lookupEnum", "(", "scope", "Scope", ",", "name", "string", ")", "(", "*", "EnumSpec", ",", "bool", ")", "{", "t", ",", "err", ":=", "scope", ".", "LookupType", "(", "name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", ...
// lookupEnum looks up an enum with the given name in the given scope.
[ "lookupEnum", "looks", "up", "an", "enum", "with", "the", "given", "name", "in", "the", "given", "scope", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/constant_value.go#L425-L435
17,663
thriftrw/thriftrw-go
internal/process/client.go
NewClient
func NewClient(cmd *exec.Cmd) (*Client, error) { stdout, err := cmd.StdoutPipe() if err != nil { return nil, fmt.Errorf("failed to create stdout pipe to %q: %v", cmd.Path, err) } stdin, err := cmd.StdinPipe() if err != nil { return nil, fmt.Errorf("failed to create stdin pipe to %q: %v", cmd.Path, err) } i...
go
func NewClient(cmd *exec.Cmd) (*Client, error) { stdout, err := cmd.StdoutPipe() if err != nil { return nil, fmt.Errorf("failed to create stdout pipe to %q: %v", cmd.Path, err) } stdin, err := cmd.StdinPipe() if err != nil { return nil, fmt.Errorf("failed to create stdin pipe to %q: %v", cmd.Path, err) } i...
[ "func", "NewClient", "(", "cmd", "*", "exec", ".", "Cmd", ")", "(", "*", "Client", ",", "error", ")", "{", "stdout", ",", "err", ":=", "cmd", ".", "StdoutPipe", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "E...
// NewClient starts up the given external process and communicates with it over // stdin and stdout using framed requests and responses. // // The Cmd MUST NOT have Stdout or Stdin set.
[ "NewClient", "starts", "up", "the", "given", "external", "process", "and", "communicates", "with", "it", "over", "stdin", "and", "stdout", "using", "framed", "requests", "and", "responses", ".", "The", "Cmd", "MUST", "NOT", "have", "Stdout", "or", "Stdin", "...
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/internal/process/client.go#L48-L70
17,664
thriftrw/thriftrw-go
internal/process/client.go
Send
func (c *Client) Send(data []byte) ([]byte, error) { if !c.running.Load() { panic(fmt.Sprintf("process.Client for %q has been closed", c.cmd.Path)) } return c.client.Send(data) }
go
func (c *Client) Send(data []byte) ([]byte, error) { if !c.running.Load() { panic(fmt.Sprintf("process.Client for %q has been closed", c.cmd.Path)) } return c.client.Send(data) }
[ "func", "(", "c", "*", "Client", ")", "Send", "(", "data", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "!", "c", ".", "running", ".", "Load", "(", ")", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"...
// Send sends the given frame to the external process and returns the response. // // Panics if Close was already called.
[ "Send", "sends", "the", "given", "frame", "to", "the", "external", "process", "and", "returns", "the", "response", ".", "Panics", "if", "Close", "was", "already", "called", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/internal/process/client.go#L75-L81
17,665
thriftrw/thriftrw-go
internal/process/client.go
Close
func (c *Client) Close() error { if !c.running.Swap(false) { return nil // already stopped } var errors []error if err := c.stdout.Close(); err != nil { errors = append(errors, fmt.Errorf("failed to detach stdout from %q: %v", c.cmd.Path, err)) } if err := c.stdin.Close(); err != nil { errors = append(erro...
go
func (c *Client) Close() error { if !c.running.Swap(false) { return nil // already stopped } var errors []error if err := c.stdout.Close(); err != nil { errors = append(errors, fmt.Errorf("failed to detach stdout from %q: %v", c.cmd.Path, err)) } if err := c.stdin.Close(); err != nil { errors = append(erro...
[ "func", "(", "c", "*", "Client", ")", "Close", "(", ")", "error", "{", "if", "!", "c", ".", "running", ".", "Swap", "(", "false", ")", "{", "return", "nil", "// already stopped", "\n", "}", "\n\n", "var", "errors", "[", "]", "error", "\n", "if", ...
// Close detaches from the external process and waits for it to exit.
[ "Close", "detaches", "from", "the", "external", "process", "and", "waits", "for", "it", "to", "exit", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/internal/process/client.go#L84-L100
17,666
thriftrw/thriftrw-go
plugin/api/plugin_goodbye.go
Equals
func (v *Plugin_Goodbye_Args) Equals(rhs *Plugin_Goodbye_Args) bool { if v == nil { return rhs == nil } else if rhs == nil { return false } return true }
go
func (v *Plugin_Goodbye_Args) Equals(rhs *Plugin_Goodbye_Args) bool { if v == nil { return rhs == nil } else if rhs == nil { return false } return true }
[ "func", "(", "v", "*", "Plugin_Goodbye_Args", ")", "Equals", "(", "rhs", "*", "Plugin_Goodbye_Args", ")", "bool", "{", "if", "v", "==", "nil", "{", "return", "rhs", "==", "nil", "\n", "}", "else", "if", "rhs", "==", "nil", "{", "return", "false", "\n...
// Equals returns true if all the fields of this Plugin_Goodbye_Args match the // provided Plugin_Goodbye_Args. // // This function performs a deep comparison.
[ "Equals", "returns", "true", "if", "all", "the", "fields", "of", "this", "Plugin_Goodbye_Args", "match", "the", "provided", "Plugin_Goodbye_Args", ".", "This", "function", "performs", "a", "deep", "comparison", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/plugin/api/plugin_goodbye.go#L107-L115
17,667
thriftrw/thriftrw-go
plugin/api/plugin_goodbye.go
Equals
func (v *Plugin_Goodbye_Result) Equals(rhs *Plugin_Goodbye_Result) bool { if v == nil { return rhs == nil } else if rhs == nil { return false } return true }
go
func (v *Plugin_Goodbye_Result) Equals(rhs *Plugin_Goodbye_Result) bool { if v == nil { return rhs == nil } else if rhs == nil { return false } return true }
[ "func", "(", "v", "*", "Plugin_Goodbye_Result", ")", "Equals", "(", "rhs", "*", "Plugin_Goodbye_Result", ")", "bool", "{", "if", "v", "==", "nil", "{", "return", "rhs", "==", "nil", "\n", "}", "else", "if", "rhs", "==", "nil", "{", "return", "false", ...
// Equals returns true if all the fields of this Plugin_Goodbye_Result match the // provided Plugin_Goodbye_Result. // // This function performs a deep comparison.
[ "Equals", "returns", "true", "if", "all", "the", "fields", "of", "this", "Plugin_Goodbye_Result", "match", "the", "provided", "Plugin_Goodbye_Result", ".", "This", "function", "performs", "a", "deep", "comparison", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/plugin/api/plugin_goodbye.go#L284-L292
17,668
thriftrw/thriftrw-go
ast/line_no.go
LineNumber
func LineNumber(n Node) int { if nl, ok := n.(nodeWithLine); ok { return nl.lineNumber() } return 0 }
go
func LineNumber(n Node) int { if nl, ok := n.(nodeWithLine); ok { return nl.lineNumber() } return 0 }
[ "func", "LineNumber", "(", "n", "Node", ")", "int", "{", "if", "nl", ",", "ok", ":=", "n", ".", "(", "nodeWithLine", ")", ";", "ok", "{", "return", "nl", ".", "lineNumber", "(", ")", "\n", "}", "\n", "return", "0", "\n", "}" ]
// LineNumber returns the line in the file at which the given node was defined // or 0 if the Node does not record its line number.
[ "LineNumber", "returns", "the", "line", "in", "the", "file", "at", "which", "the", "given", "node", "was", "defined", "or", "0", "if", "the", "Node", "does", "not", "record", "its", "line", "number", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/ast/line_no.go#L33-L38
17,669
thriftrw/thriftrw-go
internal/frame/reader.go
Read
func (r *Reader) Read() ([]byte, error) { r.Lock() defer r.Unlock() if _, err := io.ReadFull(r.r, r.buff[:]); err != nil { return nil, err } length := int64(binary.BigEndian.Uint32(r.buff[:])) if length < _fastPathFrameSize { return r.readFastPath(length) } var buff bytes.Buffer _, err := io.CopyN(&buff...
go
func (r *Reader) Read() ([]byte, error) { r.Lock() defer r.Unlock() if _, err := io.ReadFull(r.r, r.buff[:]); err != nil { return nil, err } length := int64(binary.BigEndian.Uint32(r.buff[:])) if length < _fastPathFrameSize { return r.readFastPath(length) } var buff bytes.Buffer _, err := io.CopyN(&buff...
[ "func", "(", "r", "*", "Reader", ")", "Read", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "r", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "Unlock", "(", ")", "\n\n", "if", "_", ",", "err", ":=", "io", ".", "ReadFull", "(",...
// Read reads the next frame from the Reader.
[ "Read", "reads", "the", "next", "frame", "from", "the", "Reader", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/internal/frame/reader.go#L53-L73
17,670
thriftrw/thriftrw-go
internal/frame/reader.go
Close
func (r *Reader) Close() error { if r.closed.Swap(true) { return nil // already closed } if c, ok := r.r.(io.Closer); ok { return c.Close() } return nil }
go
func (r *Reader) Close() error { if r.closed.Swap(true) { return nil // already closed } if c, ok := r.r.(io.Closer); ok { return c.Close() } return nil }
[ "func", "(", "r", "*", "Reader", ")", "Close", "(", ")", "error", "{", "if", "r", ".", "closed", ".", "Swap", "(", "true", ")", "{", "return", "nil", "// already closed", "\n", "}", "\n\n", "if", "c", ",", "ok", ":=", "r", ".", "r", ".", "(", ...
// Close closes the given Reader.
[ "Close", "closes", "the", "given", "Reader", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/internal/frame/reader.go#L85-L94
17,671
thriftrw/thriftrw-go
wire/unsafe.go
unsafeStringToBytes
func unsafeStringToBytes(s string) []byte { sh := (*reflect.StringHeader)(unsafe.Pointer(&s)) sliceHeader := reflect.SliceHeader{ Data: sh.Data, Len: sh.Len, Cap: sh.Len, } return *(*[]byte)(unsafe.Pointer(&sliceHeader)) }
go
func unsafeStringToBytes(s string) []byte { sh := (*reflect.StringHeader)(unsafe.Pointer(&s)) sliceHeader := reflect.SliceHeader{ Data: sh.Data, Len: sh.Len, Cap: sh.Len, } return *(*[]byte)(unsafe.Pointer(&sliceHeader)) }
[ "func", "unsafeStringToBytes", "(", "s", "string", ")", "[", "]", "byte", "{", "sh", ":=", "(", "*", "reflect", ".", "StringHeader", ")", "(", "unsafe", ".", "Pointer", "(", "&", "s", ")", ")", "\n", "sliceHeader", ":=", "reflect", ".", "SliceHeader", ...
// unsafeStringToBytes converts a string into a byte slice without allocating // new memory for it with the assumption that the resulting byte slice will not // be mutated.
[ "unsafeStringToBytes", "converts", "a", "string", "into", "a", "byte", "slice", "without", "allocating", "new", "memory", "for", "it", "with", "the", "assumption", "that", "the", "resulting", "byte", "slice", "will", "not", "be", "mutated", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/wire/unsafe.go#L31-L39
17,672
thriftrw/thriftrw-go
gen/typedef.go
typedef
func typedef(g Generator, spec *compile.TypedefSpec) error { err := g.DeclareFromTemplate( ` <$fmt := import "fmt"> <$wire := import "go.uber.org/thriftrw/wire"> <$typedefType := typeReference .> <formatDoc .Doc>type <typeName .> <typeName .Target> <$v := newVar "v"> <$x := newVar "x"> <- if isPrimi...
go
func typedef(g Generator, spec *compile.TypedefSpec) error { err := g.DeclareFromTemplate( ` <$fmt := import "fmt"> <$wire := import "go.uber.org/thriftrw/wire"> <$typedefType := typeReference .> <formatDoc .Doc>type <typeName .> <typeName .Target> <$v := newVar "v"> <$x := newVar "x"> <- if isPrimi...
[ "func", "typedef", "(", "g", "Generator", ",", "spec", "*", "compile", ".", "TypedefSpec", ")", "error", "{", "err", ":=", "g", ".", "DeclareFromTemplate", "(", "`\n\t\t<$fmt := import \"fmt\">\n\t\t<$wire := import \"go.uber.org/thriftrw/wire\">\n\t\t<$typedefType := typeRef...
// typedef generates code for the given typedef.
[ "typedef", "generates", "code", "for", "the", "given", "typedef", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/gen/typedef.go#L56-L138
17,673
thriftrw/thriftrw-go
protocol/binary.go
EncodeResponse
func (r EnvelopeV0Responder) EncodeResponse(v wire.Value, t wire.EnvelopeType, w io.Writer) error { writer := binary.BorrowWriter(w) err := writer.WriteLegacyEnveloped(wire.Envelope{ Name: r.Name, Type: t, SeqID: r.SeqID, Value: v, }) binary.ReturnWriter(writer) return err }
go
func (r EnvelopeV0Responder) EncodeResponse(v wire.Value, t wire.EnvelopeType, w io.Writer) error { writer := binary.BorrowWriter(w) err := writer.WriteLegacyEnveloped(wire.Envelope{ Name: r.Name, Type: t, SeqID: r.SeqID, Value: v, }) binary.ReturnWriter(writer) return err }
[ "func", "(", "r", "EnvelopeV0Responder", ")", "EncodeResponse", "(", "v", "wire", ".", "Value", ",", "t", "wire", ".", "EnvelopeType", ",", "w", "io", ".", "Writer", ")", "error", "{", "writer", ":=", "binary", ".", "BorrowWriter", "(", "w", ")", "\n",...
// EncodeResponse writes the response to the writer using a non-strict // envelope.
[ "EncodeResponse", "writes", "the", "response", "to", "the", "writer", "using", "a", "non", "-", "strict", "envelope", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/protocol/binary.go#L235-L245
17,674
thriftrw/thriftrw-go
compile/cycle.go
visited
func (f typeCycleFinder) visited(s TypeSpec) bool { for _, t := range f { if t == s { return true } } return false }
go
func (f typeCycleFinder) visited(s TypeSpec) bool { for _, t := range f { if t == s { return true } } return false }
[ "func", "(", "f", "typeCycleFinder", ")", "visited", "(", "s", "TypeSpec", ")", "bool", "{", "for", "_", ",", "t", ":=", "range", "f", "{", "if", "t", "==", "s", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
// visited returns true if the given TypeSpec has already been visited. // Otherwise it returns false, and marks the TypeSpec as visited.
[ "visited", "returns", "true", "if", "the", "given", "TypeSpec", "has", "already", "been", "visited", ".", "Otherwise", "it", "returns", "false", "and", "marks", "the", "TypeSpec", "as", "visited", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/cycle.go#L33-L40
17,675
thriftrw/thriftrw-go
compile/cycle.go
cloneWithPart
func (f typeCycleFinder) cloneWithPart(s TypeSpec) typeCycleFinder { newf := make(typeCycleFinder, 0, len(f)+1) newf = append(newf, f...) newf = append(newf, s) return newf }
go
func (f typeCycleFinder) cloneWithPart(s TypeSpec) typeCycleFinder { newf := make(typeCycleFinder, 0, len(f)+1) newf = append(newf, f...) newf = append(newf, s) return newf }
[ "func", "(", "f", "typeCycleFinder", ")", "cloneWithPart", "(", "s", "TypeSpec", ")", "typeCycleFinder", "{", "newf", ":=", "make", "(", "typeCycleFinder", ",", "0", ",", "len", "(", "f", ")", "+", "1", ")", "\n", "newf", "=", "append", "(", "newf", ...
// cloneWithPart creates a copy of this typeCycleFinder with the given // TypeSpec added to the chain.
[ "cloneWithPart", "creates", "a", "copy", "of", "this", "typeCycleFinder", "with", "the", "given", "TypeSpec", "added", "to", "the", "chain", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/cycle.go#L44-L49
17,676
thriftrw/thriftrw-go
gen/imports.go
newImporter
func newImporter(ns Namespace) importer { return importer{ ns: ns, imports: make(map[string]*ast.ImportSpec), } }
go
func newImporter(ns Namespace) importer { return importer{ ns: ns, imports: make(map[string]*ast.ImportSpec), } }
[ "func", "newImporter", "(", "ns", "Namespace", ")", "importer", "{", "return", "importer", "{", "ns", ":", "ns", ",", "imports", ":", "make", "(", "map", "[", "string", "]", "*", "ast", ".", "ImportSpec", ")", ",", "}", "\n", "}" ]
// newImporter builds a new importer.
[ "newImporter", "builds", "a", "new", "importer", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/gen/imports.go#L39-L44
17,677
thriftrw/thriftrw-go
gen/imports.go
AddImportSpec
func (i importer) AddImportSpec(spec *ast.ImportSpec) error { path := spec.Path.Value name := filepath.Base(path) if spec.Name != nil { name = spec.Name.Name } if err := i.ns.Reserve(name); err != nil { return err } i.imports[path] = spec return nil }
go
func (i importer) AddImportSpec(spec *ast.ImportSpec) error { path := spec.Path.Value name := filepath.Base(path) if spec.Name != nil { name = spec.Name.Name } if err := i.ns.Reserve(name); err != nil { return err } i.imports[path] = spec return nil }
[ "func", "(", "i", "importer", ")", "AddImportSpec", "(", "spec", "*", "ast", ".", "ImportSpec", ")", "error", "{", "path", ":=", "spec", ".", "Path", ".", "Value", "\n", "name", ":=", "filepath", ".", "Base", "(", "path", ")", "\n", "if", "spec", "...
// AddImportSpec allows adding existing import specs to the importer. // // An error is returned if there's a naming conflict.
[ "AddImportSpec", "allows", "adding", "existing", "import", "specs", "to", "the", "importer", ".", "An", "error", "is", "returned", "if", "there", "s", "a", "naming", "conflict", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/gen/imports.go#L49-L62
17,678
thriftrw/thriftrw-go
gen/imports.go
Import
func (i importer) Import(path string) string { if imp, ok := i.imports[path]; ok { if imp.Name != nil { return imp.Name.Name } return filepath.Base(path) } name := i.ns.NewName(goast.DeterminePackageName(path)) astImport := &ast.ImportSpec{ Name: ast.NewIdent(name), Path: stringLiteral(path), } i.i...
go
func (i importer) Import(path string) string { if imp, ok := i.imports[path]; ok { if imp.Name != nil { return imp.Name.Name } return filepath.Base(path) } name := i.ns.NewName(goast.DeterminePackageName(path)) astImport := &ast.ImportSpec{ Name: ast.NewIdent(name), Path: stringLiteral(path), } i.i...
[ "func", "(", "i", "importer", ")", "Import", "(", "path", "string", ")", "string", "{", "if", "imp", ",", "ok", ":=", "i", ".", "imports", "[", "path", "]", ";", "ok", "{", "if", "imp", ".", "Name", "!=", "nil", "{", "return", "imp", ".", "Name...
// Import ensures that the generated module has the given module imported and // returns the name that should be used by the generated code to reference items // defined in the module.
[ "Import", "ensures", "that", "the", "generated", "module", "has", "the", "given", "module", "imported", "and", "returns", "the", "name", "that", "should", "be", "used", "by", "the", "generated", "code", "to", "reference", "items", "defined", "in", "the", "mo...
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/gen/imports.go#L67-L83
17,679
thriftrw/thriftrw-go
gen/imports.go
importDecl
func (i importer) importDecl() ast.Decl { imports := i.imports if imports == nil || len(imports) == 0 { return nil } specs := make([]ast.Spec, 0, len(imports)) for _, iname := range sortStringKeys(imports) { imp := imports[iname] specs = append(specs, imp) } decl := &ast.GenDecl{Tok: token.IMPORT, Specs:...
go
func (i importer) importDecl() ast.Decl { imports := i.imports if imports == nil || len(imports) == 0 { return nil } specs := make([]ast.Spec, 0, len(imports)) for _, iname := range sortStringKeys(imports) { imp := imports[iname] specs = append(specs, imp) } decl := &ast.GenDecl{Tok: token.IMPORT, Specs:...
[ "func", "(", "i", "importer", ")", "importDecl", "(", ")", "ast", ".", "Decl", "{", "imports", ":=", "i", ".", "imports", "\n", "if", "imports", "==", "nil", "||", "len", "(", "imports", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n\n", "s...
// importDecl builds an import declation from the given list of imports.
[ "importDecl", "builds", "an", "import", "declation", "from", "the", "given", "list", "of", "imports", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/gen/imports.go#L86-L105
17,680
thriftrw/thriftrw-go
envelope/envelope.go
Write
func Write(p protocol.Protocol, w io.Writer, seqID int32, e Enveloper) error { body, err := e.ToWire() if err != nil { return err } return p.EncodeEnveloped(wire.Envelope{ SeqID: seqID, Name: e.MethodName(), Type: e.EnvelopeType(), Value: body, }, w) }
go
func Write(p protocol.Protocol, w io.Writer, seqID int32, e Enveloper) error { body, err := e.ToWire() if err != nil { return err } return p.EncodeEnveloped(wire.Envelope{ SeqID: seqID, Name: e.MethodName(), Type: e.EnvelopeType(), Value: body, }, w) }
[ "func", "Write", "(", "p", "protocol", ".", "Protocol", ",", "w", "io", ".", "Writer", ",", "seqID", "int32", ",", "e", "Enveloper", ")", "error", "{", "body", ",", "err", ":=", "e", ".", "ToWire", "(", ")", "\n", "if", "err", "!=", "nil", "{", ...
// Write writes an Envelope to the given writer.
[ "Write", "writes", "an", "Envelope", "to", "the", "given", "writer", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/envelope/envelope.go#L41-L52
17,681
thriftrw/thriftrw-go
envelope/envelope.go
ReadReply
func ReadReply(p protocol.Protocol, r io.ReaderAt) (_ wire.Value, seqID int32, _ error) { envelope, err := p.DecodeEnveloped(r) if err != nil { return wire.Value{}, 0, err } switch { case envelope.Type == wire.Reply: return envelope.Value, envelope.SeqID, nil case envelope.Type != wire.Exception: return en...
go
func ReadReply(p protocol.Protocol, r io.ReaderAt) (_ wire.Value, seqID int32, _ error) { envelope, err := p.DecodeEnveloped(r) if err != nil { return wire.Value{}, 0, err } switch { case envelope.Type == wire.Reply: return envelope.Value, envelope.SeqID, nil case envelope.Type != wire.Exception: return en...
[ "func", "ReadReply", "(", "p", "protocol", ".", "Protocol", ",", "r", "io", ".", "ReaderAt", ")", "(", "_", "wire", ".", "Value", ",", "seqID", "int32", ",", "_", "error", ")", "{", "envelope", ",", "err", ":=", "p", ".", "DecodeEnveloped", "(", "r...
// ReadReply reads enveloped responses from the given reader.
[ "ReadReply", "reads", "enveloped", "responses", "from", "the", "given", "reader", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/envelope/envelope.go#L55-L75
17,682
thriftrw/thriftrw-go
compile/container.go
compileMapType
func compileMapType(src ast.MapType) (*MapSpec, error) { annots, err := compileAnnotations(src.Annotations) if err != nil { return nil, err } keySpec, err := compileTypeReference(src.KeyType) if err != nil { return nil, err } valueSpec, err := compileTypeReference(src.ValueType) if err != nil { return n...
go
func compileMapType(src ast.MapType) (*MapSpec, error) { annots, err := compileAnnotations(src.Annotations) if err != nil { return nil, err } keySpec, err := compileTypeReference(src.KeyType) if err != nil { return nil, err } valueSpec, err := compileTypeReference(src.ValueType) if err != nil { return n...
[ "func", "compileMapType", "(", "src", "ast", ".", "MapType", ")", "(", "*", "MapSpec", ",", "error", ")", "{", "annots", ",", "err", ":=", "compileAnnotations", "(", "src", ".", "Annotations", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ...
// compileMapType compiles the given MapType AST into a MapSpec.
[ "compileMapType", "compiles", "the", "given", "MapType", "AST", "into", "a", "MapSpec", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/container.go#L40-L61
17,683
thriftrw/thriftrw-go
compile/container.go
Link
func (m *MapSpec) Link(scope Scope) (TypeSpec, error) { if m.linked() { return m, nil } var err error m.KeySpec, err = m.KeySpec.Link(scope) if err != nil { return m, err } m.ValueSpec, err = m.ValueSpec.Link(scope) if err != nil { return m, err } return m, nil }
go
func (m *MapSpec) Link(scope Scope) (TypeSpec, error) { if m.linked() { return m, nil } var err error m.KeySpec, err = m.KeySpec.Link(scope) if err != nil { return m, err } m.ValueSpec, err = m.ValueSpec.Link(scope) if err != nil { return m, err } return m, nil }
[ "func", "(", "m", "*", "MapSpec", ")", "Link", "(", "scope", "Scope", ")", "(", "TypeSpec", ",", "error", ")", "{", "if", "m", ".", "linked", "(", ")", "{", "return", "m", ",", "nil", "\n", "}", "\n\n", "var", "err", "error", "\n", "m", ".", ...
// Link resolves the type references in the MapSpec.
[ "Link", "resolves", "the", "type", "references", "in", "the", "MapSpec", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/container.go#L64-L81
17,684
thriftrw/thriftrw-go
compile/container.go
ThriftName
func (m *MapSpec) ThriftName() string { return fmt.Sprintf( "map<%s, %s>", m.KeySpec.ThriftName(), m.ValueSpec.ThriftName(), ) }
go
func (m *MapSpec) ThriftName() string { return fmt.Sprintf( "map<%s, %s>", m.KeySpec.ThriftName(), m.ValueSpec.ThriftName(), ) }
[ "func", "(", "m", "*", "MapSpec", ")", "ThriftName", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "m", ".", "KeySpec", ".", "ThriftName", "(", ")", ",", "m", ".", "ValueSpec", ".", "ThriftName", "(", ")", ",", "...
// ThriftName for MapSpec
[ "ThriftName", "for", "MapSpec" ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/container.go#L84-L88
17,685
thriftrw/thriftrw-go
compile/container.go
ForEachTypeReference
func (m *MapSpec) ForEachTypeReference(f func(TypeSpec) error) error { if err := f(m.KeySpec); err != nil { return err } return f(m.ValueSpec) }
go
func (m *MapSpec) ForEachTypeReference(f func(TypeSpec) error) error { if err := f(m.KeySpec); err != nil { return err } return f(m.ValueSpec) }
[ "func", "(", "m", "*", "MapSpec", ")", "ForEachTypeReference", "(", "f", "func", "(", "TypeSpec", ")", "error", ")", "error", "{", "if", "err", ":=", "f", "(", "m", ".", "KeySpec", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\...
// ForEachTypeReference for MapSpec
[ "ForEachTypeReference", "for", "MapSpec" ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/container.go#L96-L101
17,686
thriftrw/thriftrw-go
compile/container.go
compileListType
func compileListType(src ast.ListType) (*ListSpec, error) { annots, err := compileAnnotations(src.Annotations) if err != nil { return nil, err } valueSpec, err := compileTypeReference(src.ValueType) if err != nil { return nil, err } return &ListSpec{ ValueSpec: valueSpec, Annotations: annots, }, nil...
go
func compileListType(src ast.ListType) (*ListSpec, error) { annots, err := compileAnnotations(src.Annotations) if err != nil { return nil, err } valueSpec, err := compileTypeReference(src.ValueType) if err != nil { return nil, err } return &ListSpec{ ValueSpec: valueSpec, Annotations: annots, }, nil...
[ "func", "compileListType", "(", "src", "ast", ".", "ListType", ")", "(", "*", "ListSpec", ",", "error", ")", "{", "annots", ",", "err", ":=", "compileAnnotations", "(", "src", ".", "Annotations", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil...
// compileListSpec compiles the given ListType AST into a ListSpec.
[ "compileListSpec", "compiles", "the", "given", "ListType", "AST", "into", "a", "ListSpec", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/container.go#L120-L135
17,687
thriftrw/thriftrw-go
compile/container.go
Link
func (l *ListSpec) Link(scope Scope) (TypeSpec, error) { if l.linked() { return l, nil } var err error l.ValueSpec, err = l.ValueSpec.Link(scope) return l, err }
go
func (l *ListSpec) Link(scope Scope) (TypeSpec, error) { if l.linked() { return l, nil } var err error l.ValueSpec, err = l.ValueSpec.Link(scope) return l, err }
[ "func", "(", "l", "*", "ListSpec", ")", "Link", "(", "scope", "Scope", ")", "(", "TypeSpec", ",", "error", ")", "{", "if", "l", ".", "linked", "(", ")", "{", "return", "l", ",", "nil", "\n", "}", "\n\n", "var", "err", "error", "\n", "l", ".", ...
// Link resolves the type references in the ListSpec.
[ "Link", "resolves", "the", "type", "references", "in", "the", "ListSpec", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/container.go#L138-L146
17,688
thriftrw/thriftrw-go
compile/container.go
ForEachTypeReference
func (l *ListSpec) ForEachTypeReference(f func(TypeSpec) error) error { return f(l.ValueSpec) }
go
func (l *ListSpec) ForEachTypeReference(f func(TypeSpec) error) error { return f(l.ValueSpec) }
[ "func", "(", "l", "*", "ListSpec", ")", "ForEachTypeReference", "(", "f", "func", "(", "TypeSpec", ")", "error", ")", "error", "{", "return", "f", "(", "l", ".", "ValueSpec", ")", "\n", "}" ]
// ForEachTypeReference for ListSpec
[ "ForEachTypeReference", "for", "ListSpec" ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/container.go#L159-L161
17,689
thriftrw/thriftrw-go
compile/container.go
compileSetType
func compileSetType(src ast.SetType) (*SetSpec, error) { annots, err := compileAnnotations(src.Annotations) if err != nil { return nil, err } valueSpec, err := compileTypeReference(src.ValueType) if err != nil { return nil, err } return &SetSpec{ ValueSpec: valueSpec, Annotations: annots, }, nil }
go
func compileSetType(src ast.SetType) (*SetSpec, error) { annots, err := compileAnnotations(src.Annotations) if err != nil { return nil, err } valueSpec, err := compileTypeReference(src.ValueType) if err != nil { return nil, err } return &SetSpec{ ValueSpec: valueSpec, Annotations: annots, }, nil }
[ "func", "compileSetType", "(", "src", "ast", ".", "SetType", ")", "(", "*", "SetSpec", ",", "error", ")", "{", "annots", ",", "err", ":=", "compileAnnotations", "(", "src", ".", "Annotations", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ...
// compileSetSpec compiles the given SetType AST into a SetSpec.
[ "compileSetSpec", "compiles", "the", "given", "SetType", "AST", "into", "a", "SetSpec", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/container.go#L180-L195
17,690
thriftrw/thriftrw-go
compile/container.go
Link
func (s *SetSpec) Link(scope Scope) (TypeSpec, error) { if s.linked() { return s, nil } var err error s.ValueSpec, err = s.ValueSpec.Link(scope) return s, err }
go
func (s *SetSpec) Link(scope Scope) (TypeSpec, error) { if s.linked() { return s, nil } var err error s.ValueSpec, err = s.ValueSpec.Link(scope) return s, err }
[ "func", "(", "s", "*", "SetSpec", ")", "Link", "(", "scope", "Scope", ")", "(", "TypeSpec", ",", "error", ")", "{", "if", "s", ".", "linked", "(", ")", "{", "return", "s", ",", "nil", "\n", "}", "\n\n", "var", "err", "error", "\n", "s", ".", ...
// Link resolves the type references in the SetSpec.
[ "Link", "resolves", "the", "type", "references", "in", "the", "SetSpec", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/container.go#L198-L206
17,691
thriftrw/thriftrw-go
compile/container.go
ForEachTypeReference
func (s *SetSpec) ForEachTypeReference(f func(TypeSpec) error) error { return f(s.ValueSpec) }
go
func (s *SetSpec) ForEachTypeReference(f func(TypeSpec) error) error { return f(s.ValueSpec) }
[ "func", "(", "s", "*", "SetSpec", ")", "ForEachTypeReference", "(", "f", "func", "(", "TypeSpec", ")", "error", ")", "error", "{", "return", "f", "(", "s", ".", "ValueSpec", ")", "\n", "}" ]
// ForEachTypeReference for SetSpec
[ "ForEachTypeReference", "for", "SetSpec" ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/container.go#L219-L221
17,692
thriftrw/thriftrw-go
compile/struct.go
compileStruct
func compileStruct(file string, src *ast.Struct, requiredness fieldRequiredness) (*StructSpec, error) { opts := fieldOptions{requiredness: requiredness} if src.Type == ast.UnionType { opts.requiredness = noRequiredFields opts.disallowDefaultValue = true } fields, err := compileFields(src.Fields, opts) if err...
go
func compileStruct(file string, src *ast.Struct, requiredness fieldRequiredness) (*StructSpec, error) { opts := fieldOptions{requiredness: requiredness} if src.Type == ast.UnionType { opts.requiredness = noRequiredFields opts.disallowDefaultValue = true } fields, err := compileFields(src.Fields, opts) if err...
[ "func", "compileStruct", "(", "file", "string", ",", "src", "*", "ast", ".", "Struct", ",", "requiredness", "fieldRequiredness", ")", "(", "*", "StructSpec", ",", "error", ")", "{", "opts", ":=", "fieldOptions", "{", "requiredness", ":", "requiredness", "}",...
// compileStruct compiles a struct AST into a StructSpec.
[ "compileStruct", "compiles", "a", "struct", "AST", "into", "a", "StructSpec", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/struct.go#L41-L75
17,693
thriftrw/thriftrw-go
compile/struct.go
Link
func (s *StructSpec) Link(scope Scope) (TypeSpec, error) { if s.linked() { return s, nil } err := s.Fields.Link(scope) return s, err }
go
func (s *StructSpec) Link(scope Scope) (TypeSpec, error) { if s.linked() { return s, nil } err := s.Fields.Link(scope) return s, err }
[ "func", "(", "s", "*", "StructSpec", ")", "Link", "(", "scope", "Scope", ")", "(", "TypeSpec", ",", "error", ")", "{", "if", "s", ".", "linked", "(", ")", "{", "return", "s", ",", "nil", "\n", "}", "\n\n", "err", ":=", "s", ".", "Fields", ".", ...
// Link links together all references in the StructSpec.
[ "Link", "links", "together", "all", "references", "in", "the", "StructSpec", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/struct.go#L78-L85
17,694
thriftrw/thriftrw-go
compile/struct.go
ForEachTypeReference
func (s *StructSpec) ForEachTypeReference(f func(TypeSpec) error) error { return s.Fields.ForEachTypeReference(f) }
go
func (s *StructSpec) ForEachTypeReference(f func(TypeSpec) error) error { return s.Fields.ForEachTypeReference(f) }
[ "func", "(", "s", "*", "StructSpec", ")", "ForEachTypeReference", "(", "f", "func", "(", "TypeSpec", ")", "error", ")", "error", "{", "return", "s", ".", "Fields", ".", "ForEachTypeReference", "(", "f", ")", "\n", "}" ]
// ForEachTypeReference for StructSpec
[ "ForEachTypeReference", "for", "StructSpec" ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/compile/struct.go#L109-L111
17,695
thriftrw/thriftrw-go
main.go
verifyAncestry
func verifyAncestry(m *compile.Module, root string) error { return m.Walk(func(m *compile.Module) error { path, err := filepath.Rel(root, m.ThriftPath) if err != nil { return fmt.Errorf( "could not resolve path for %q: %v", m.ThriftPath, err) } if strings.HasPrefix(path, "..") { return fmt.Errorf( ...
go
func verifyAncestry(m *compile.Module, root string) error { return m.Walk(func(m *compile.Module) error { path, err := filepath.Rel(root, m.ThriftPath) if err != nil { return fmt.Errorf( "could not resolve path for %q: %v", m.ThriftPath, err) } if strings.HasPrefix(path, "..") { return fmt.Errorf( ...
[ "func", "verifyAncestry", "(", "m", "*", "compile", ".", "Module", ",", "root", "string", ")", "error", "{", "return", "m", ".", "Walk", "(", "func", "(", "m", "*", "compile", ".", "Module", ")", "error", "{", "path", ",", "err", ":=", "filepath", ...
// verifyAncestry verifies that the Thrift file for the given module and the // Thrift files for all imported modules are contained within the directory // tree rooted at the given path.
[ "verifyAncestry", "verifies", "that", "the", "Thrift", "file", "for", "the", "given", "module", "and", "the", "Thrift", "files", "for", "all", "imported", "modules", "are", "contained", "within", "the", "directory", "tree", "rooted", "at", "the", "given", "pat...
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/main.go#L193-L209
17,696
thriftrw/thriftrw-go
main.go
findCommonAncestor
func findCommonAncestor(m *compile.Module) (string, error) { var result []string var lastString string err := m.Walk(func(m *compile.Module) error { thriftPath := m.ThriftPath if !filepath.IsAbs(thriftPath) { return fmt.Errorf( "ThriftPath must be absolute: %q is not absolute", thriftPath) } thriftD...
go
func findCommonAncestor(m *compile.Module) (string, error) { var result []string var lastString string err := m.Walk(func(m *compile.Module) error { thriftPath := m.ThriftPath if !filepath.IsAbs(thriftPath) { return fmt.Errorf( "ThriftPath must be absolute: %q is not absolute", thriftPath) } thriftD...
[ "func", "findCommonAncestor", "(", "m", "*", "compile", ".", "Module", ")", "(", "string", ",", "error", ")", "{", "var", "result", "[", "]", "string", "\n", "var", "lastString", "string", "\n\n", "err", ":=", "m", ".", "Walk", "(", "func", "(", "m",...
// findCommonAncestor finds the deepest common ancestor for the given module // and all modules imported by it.
[ "findCommonAncestor", "finds", "the", "deepest", "common", "ancestor", "for", "the", "given", "module", "and", "all", "modules", "imported", "by", "it", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/main.go#L213-L249
17,697
thriftrw/thriftrw-go
main.go
commonPrefix
func commonPrefix(l, r []string) []string { var i int for i = 0; i < len(l) && i < len(r); i++ { if l[i] != r[i] { break } } return l[:i] }
go
func commonPrefix(l, r []string) []string { var i int for i = 0; i < len(l) && i < len(r); i++ { if l[i] != r[i] { break } } return l[:i] }
[ "func", "commonPrefix", "(", "l", ",", "r", "[", "]", "string", ")", "[", "]", "string", "{", "var", "i", "int", "\n", "for", "i", "=", "0", ";", "i", "<", "len", "(", "l", ")", "&&", "i", "<", "len", "(", "r", ")", ";", "i", "++", "{", ...
// commonPrefix finds the shortest common prefix for the two lists. // // An empty slice may be returned if the two lists don't have a common prefix.
[ "commonPrefix", "finds", "the", "shortest", "common", "prefix", "for", "the", "two", "lists", ".", "An", "empty", "slice", "may", "be", "returned", "if", "the", "two", "lists", "don", "t", "have", "a", "common", "prefix", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/main.go#L254-L262
17,698
thriftrw/thriftrw-go
main.go
determinePackagePrefix
func determinePackagePrefix(dir string) (string, error) { gopathList := os.Getenv("GOPATH") if gopathList == "" { return "", errors.New("$GOPATH is not set") } for _, gopath := range filepath.SplitList(gopathList) { packagePath, err := filepath.Rel(filepath.Join(gopath, "src"), dir) if err != nil { return...
go
func determinePackagePrefix(dir string) (string, error) { gopathList := os.Getenv("GOPATH") if gopathList == "" { return "", errors.New("$GOPATH is not set") } for _, gopath := range filepath.SplitList(gopathList) { packagePath, err := filepath.Rel(filepath.Join(gopath, "src"), dir) if err != nil { return...
[ "func", "determinePackagePrefix", "(", "dir", "string", ")", "(", "string", ",", "error", ")", "{", "gopathList", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "if", "gopathList", "==", "\"", "\"", "{", "return", "\"", "\"", ",", "errors", "...
// determinePackagePrefix determines the package prefix for Go packages // generated in this file. // // dir must be an absolute path.
[ "determinePackagePrefix", "determines", "the", "package", "prefix", "for", "Go", "packages", "generated", "in", "this", "file", ".", "dir", "must", "be", "an", "absolute", "path", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/main.go#L268-L287
17,699
thriftrw/thriftrw-go
internal/semver/semver.go
Parse
func Parse(v string) (r Version, err error) { parts := semVerRegex.FindStringSubmatch(v) if parts == nil { return r, fmt.Errorf(`cannot parse as semantic version: %q`, v) } if r.Major, err = parseUint(parts[1]); err != nil { return r, err } if r.Minor, err = parseUint(parts[2]); err != nil { return r, err ...
go
func Parse(v string) (r Version, err error) { parts := semVerRegex.FindStringSubmatch(v) if parts == nil { return r, fmt.Errorf(`cannot parse as semantic version: %q`, v) } if r.Major, err = parseUint(parts[1]); err != nil { return r, err } if r.Minor, err = parseUint(parts[2]); err != nil { return r, err ...
[ "func", "Parse", "(", "v", "string", ")", "(", "r", "Version", ",", "err", "error", ")", "{", "parts", ":=", "semVerRegex", ".", "FindStringSubmatch", "(", "v", ")", "\n", "if", "parts", "==", "nil", "{", "return", "r", ",", "fmt", ".", "Errorf", "...
// Parse a semantic version string.
[ "Parse", "a", "semantic", "version", "string", "." ]
a9a6ad793beab07cc3385954d2e8af8abfaa83e2
https://github.com/thriftrw/thriftrw-go/blob/a9a6ad793beab07cc3385954d2e8af8abfaa83e2/internal/semver/semver.go#L49-L70