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
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
hprose/hprose-golang
io/reader.go
ReadSliceWithoutTag
func (r *Reader) ReadSliceWithoutTag() []reflect.Value { l := r.ReadCount() v := make([]reflect.Value, l) if !r.Simple { setReaderRef(r, nil) } for i := 0; i < l; i++ { v[i] = reflect.New(interfaceType).Elem() r.ReadValue(v[i]) } r.readByte() return v }
go
func (r *Reader) ReadSliceWithoutTag() []reflect.Value { l := r.ReadCount() v := make([]reflect.Value, l) if !r.Simple { setReaderRef(r, nil) } for i := 0; i < l; i++ { v[i] = reflect.New(interfaceType).Elem() r.ReadValue(v[i]) } r.readByte() return v }
[ "func", "(", "r", "*", "Reader", ")", "ReadSliceWithoutTag", "(", ")", "[", "]", "reflect", ".", "Value", "{", "l", ":=", "r", ".", "ReadCount", "(", ")", "\n", "v", ":=", "make", "(", "[", "]", "reflect", ".", "Value", ",", "l", ")", "\n", "if...
// ReadSliceWithoutTag from the reader
[ "ReadSliceWithoutTag", "from", "the", "reader" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/io/reader.go#L288-L300
train
hprose/hprose-golang
io/reader.go
ReadSlice
func (r *Reader) ReadSlice(v []reflect.Value) { l := len(v) if !r.Simple { setReaderRef(r, nil) } for i := 0; i < l; i++ { r.ReadValue(v[i]) } r.readByte() }
go
func (r *Reader) ReadSlice(v []reflect.Value) { l := len(v) if !r.Simple { setReaderRef(r, nil) } for i := 0; i < l; i++ { r.ReadValue(v[i]) } r.readByte() }
[ "func", "(", "r", "*", "Reader", ")", "ReadSlice", "(", "v", "[", "]", "reflect", ".", "Value", ")", "{", "l", ":=", "len", "(", "v", ")", "\n", "if", "!", "r", ".", "Simple", "{", "setReaderRef", "(", "r", ",", "nil", ")", "\n", "}", "\n", ...
// ReadSlice from the reader
[ "ReadSlice", "from", "the", "reader" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/io/reader.go#L303-L312
train
hprose/hprose-golang
io/reader.go
readRef
func (r *Reader) readRef() interface{} { if r.Simple { panic(errors.New("reference unserialization can't support in simple mode")) } return readRef(r, r.readInt()) }
go
func (r *Reader) readRef() interface{} { if r.Simple { panic(errors.New("reference unserialization can't support in simple mode")) } return readRef(r, r.readInt()) }
[ "func", "(", "r", "*", "Reader", ")", "readRef", "(", ")", "interface", "{", "}", "{", "if", "r", ".", "Simple", "{", "panic", "(", "errors", ".", "New", "(", "\"", "\"", ")", ")", "\n", "}", "\n", "return", "readRef", "(", "r", ",", "r", "."...
// private methods & functions
[ "private", "methods", "&", "functions" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/io/reader.go#L337-L342
train
hprose/hprose-golang
rpc/fasthttp/fasthttp_service.go
InitFastHTTPContext
func (context *FastHTTPContext) InitFastHTTPContext( service rpc.Service, ctx *fasthttp.RequestCtx) { context.InitServiceContext(service) context.RequestCtx = ctx }
go
func (context *FastHTTPContext) InitFastHTTPContext( service rpc.Service, ctx *fasthttp.RequestCtx) { context.InitServiceContext(service) context.RequestCtx = ctx }
[ "func", "(", "context", "*", "FastHTTPContext", ")", "InitFastHTTPContext", "(", "service", "rpc", ".", "Service", ",", "ctx", "*", "fasthttp", ".", "RequestCtx", ")", "{", "context", ".", "InitServiceContext", "(", "service", ")", "\n", "context", ".", "Req...
// InitFastHTTPContext initializes FastHTTPContext
[ "InitFastHTTPContext", "initializes", "FastHTTPContext" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/fasthttp/fasthttp_service.go#L42-L46
train
hprose/hprose-golang
rpc/fasthttp/fasthttp_service.go
NewFastHTTPService
func NewFastHTTPService() (service *FastHTTPService) { service = new(FastHTTPService) service.InitBaseHTTPService() service.contextPool = sync.Pool{ New: func() interface{} { return new(FastHTTPContext) }, } service.FixArguments = fasthttpFixArguments return }
go
func NewFastHTTPService() (service *FastHTTPService) { service = new(FastHTTPService) service.InitBaseHTTPService() service.contextPool = sync.Pool{ New: func() interface{} { return new(FastHTTPContext) }, } service.FixArguments = fasthttpFixArguments return }
[ "func", "NewFastHTTPService", "(", ")", "(", "service", "*", "FastHTTPService", ")", "{", "service", "=", "new", "(", "FastHTTPService", ")", "\n", "service", ".", "InitBaseHTTPService", "(", ")", "\n", "service", ".", "contextPool", "=", "sync", ".", "Pool"...
// NewFastHTTPService is the constructor of FastHTTPService
[ "NewFastHTTPService", "is", "the", "constructor", "of", "FastHTTPService" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/fasthttp/fasthttp_service.go#L79-L87
train
hprose/hprose-golang
rpc/fasthttp/fasthttp_service.go
ServeFastHTTP
func (service *FastHTTPService) ServeFastHTTP(ctx *fasthttp.RequestCtx) { if service.clientAccessPolicyXMLHandler(ctx) || service.crossDomainXMLHandler(ctx) { return } context := service.acquireContext() context.InitFastHTTPContext(service, ctx) var resp []byte if err := service.sendHeader(context); err == ni...
go
func (service *FastHTTPService) ServeFastHTTP(ctx *fasthttp.RequestCtx) { if service.clientAccessPolicyXMLHandler(ctx) || service.crossDomainXMLHandler(ctx) { return } context := service.acquireContext() context.InitFastHTTPContext(service, ctx) var resp []byte if err := service.sendHeader(context); err == ni...
[ "func", "(", "service", "*", "FastHTTPService", ")", "ServeFastHTTP", "(", "ctx", "*", "fasthttp", ".", "RequestCtx", ")", "{", "if", "service", ".", "clientAccessPolicyXMLHandler", "(", "ctx", ")", "||", "service", ".", "crossDomainXMLHandler", "(", "ctx", ")...
// ServeFastHTTP is the hprose fasthttp handler method
[ "ServeFastHTTP", "is", "the", "hprose", "fasthttp", "handler", "method" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/fasthttp/fasthttp_service.go#L177-L203
train
hprose/hprose-golang
rpc/unix_service.go
ServeUnixConn
func (service *UnixService) ServeUnixConn(conn *net.UnixConn) { if service.TLSConfig != nil { tlsConn := tls.Server(conn, service.TLSConfig) tlsConn.Handshake() service.serveConn(tlsConn) } else { service.serveConn(conn) } }
go
func (service *UnixService) ServeUnixConn(conn *net.UnixConn) { if service.TLSConfig != nil { tlsConn := tls.Server(conn, service.TLSConfig) tlsConn.Handshake() service.serveConn(tlsConn) } else { service.serveConn(conn) } }
[ "func", "(", "service", "*", "UnixService", ")", "ServeUnixConn", "(", "conn", "*", "net", ".", "UnixConn", ")", "{", "if", "service", ".", "TLSConfig", "!=", "nil", "{", "tlsConn", ":=", "tls", ".", "Server", "(", "conn", ",", "service", ".", "TLSConf...
// ServeUnixConn runs on a single tcp connection. ServeUnixConn blocks, serving // the connection until the client hangs up. The caller typically invokes // ServeUnixConn in a go statement.
[ "ServeUnixConn", "runs", "on", "a", "single", "tcp", "connection", ".", "ServeUnixConn", "blocks", "serving", "the", "connection", "until", "the", "client", "hangs", "up", ".", "The", "caller", "typically", "invokes", "ServeUnixConn", "in", "a", "go", "statement...
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/unix_service.go#L43-L51
train
hprose/hprose-golang
rpc/unix_service.go
ServeUnix
func (service *UnixService) ServeUnix(listener *net.UnixListener) { service.workerPool.Start(); defer service.workerPool.Stop(); var tempDelay time.Duration // how long to sleep on accept failure for { conn, err := listener.AcceptUnix() if err != nil { tempDelay = nextTempDelay(err, service.Event, tempDelay)...
go
func (service *UnixService) ServeUnix(listener *net.UnixListener) { service.workerPool.Start(); defer service.workerPool.Stop(); var tempDelay time.Duration // how long to sleep on accept failure for { conn, err := listener.AcceptUnix() if err != nil { tempDelay = nextTempDelay(err, service.Event, tempDelay)...
[ "func", "(", "service", "*", "UnixService", ")", "ServeUnix", "(", "listener", "*", "net", ".", "UnixListener", ")", "{", "service", ".", "workerPool", ".", "Start", "(", ")", ";", "defer", "service", ".", "workerPool", ".", "Stop", "(", ")", ";", "var...
// ServeUnix runs on the UnixListener. ServeUnix blocks, serving the listener // until the server is stop. The caller typically invokes ServeUnix in a go // statement.
[ "ServeUnix", "runs", "on", "the", "UnixListener", ".", "ServeUnix", "blocks", "serving", "the", "listener", "until", "the", "server", "is", "stop", ".", "The", "caller", "typically", "invokes", "ServeUnix", "in", "a", "go", "statement", "." ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/unix_service.go#L63-L81
train
hprose/hprose-golang
io/byte_reader.go
NewByteReader
func NewByteReader(buf []byte) (reader *ByteReader) { reader = new(ByteReader) reader.buf = buf return }
go
func NewByteReader(buf []byte) (reader *ByteReader) { reader = new(ByteReader) reader.buf = buf return }
[ "func", "NewByteReader", "(", "buf", "[", "]", "byte", ")", "(", "reader", "*", "ByteReader", ")", "{", "reader", "=", "new", "(", "ByteReader", ")", "\n", "reader", ".", "buf", "=", "buf", "\n", "return", "\n", "}" ]
// NewByteReader is a constructor for ByteReader
[ "NewByteReader", "is", "a", "constructor", "for", "ByteReader" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/io/byte_reader.go#L40-L44
train
hprose/hprose-golang
io/byte_reader.go
ReadByte
func (r *ByteReader) ReadByte() (byte, error) { if r.off >= len(r.buf) { return 0, io.EOF } return r.readByte(), nil }
go
func (r *ByteReader) ReadByte() (byte, error) { if r.off >= len(r.buf) { return 0, io.EOF } return r.readByte(), nil }
[ "func", "(", "r", "*", "ByteReader", ")", "ReadByte", "(", ")", "(", "byte", ",", "error", ")", "{", "if", "r", ".", "off", ">=", "len", "(", "r", ".", "buf", ")", "{", "return", "0", ",", "io", ".", "EOF", "\n", "}", "\n", "return", "r", "...
// ReadByte reads and returns a single byte. If no byte is available, // it returns error io.EOF.
[ "ReadByte", "reads", "and", "returns", "a", "single", "byte", ".", "If", "no", "byte", "is", "available", "it", "returns", "error", "io", ".", "EOF", "." ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/io/byte_reader.go#L54-L59
train
hprose/hprose-golang
io/byte_reader.go
Unread
func (r *ByteReader) Unread(n int) { if r.off >= n { r.off -= n } else { r.off = 0 } }
go
func (r *ByteReader) Unread(n int) { if r.off >= n { r.off -= n } else { r.off = 0 } }
[ "func", "(", "r", "*", "ByteReader", ")", "Unread", "(", "n", "int", ")", "{", "if", "r", ".", "off", ">=", "n", "{", "r", ".", "off", "-=", "n", "\n", "}", "else", "{", "r", ".", "off", "=", "0", "\n", "}", "\n", "}" ]
// Unread n bytes from the current position.
[ "Unread", "n", "bytes", "from", "the", "current", "position", "." ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/io/byte_reader.go#L82-L88
train
hprose/hprose-golang
io/byte_reader.go
Next
func (r *ByteReader) Next(n int) (data []byte) { p := r.off + n if p > len(r.buf) { p = len(r.buf) } data = r.buf[r.off:p] r.off = p return }
go
func (r *ByteReader) Next(n int) (data []byte) { p := r.off + n if p > len(r.buf) { p = len(r.buf) } data = r.buf[r.off:p] r.off = p return }
[ "func", "(", "r", "*", "ByteReader", ")", "Next", "(", "n", "int", ")", "(", "data", "[", "]", "byte", ")", "{", "p", ":=", "r", ".", "off", "+", "n", "\n", "if", "p", ">", "len", "(", "r", ".", "buf", ")", "{", "p", "=", "len", "(", "r...
// Next returns a slice containing the next n bytes from the buffer, // advancing the buffer as if the bytes had been returned by Read. // If there are fewer than n bytes, Next returns the entire buffer. // The slice is only valid until the next call to a read or write method.
[ "Next", "returns", "a", "slice", "containing", "the", "next", "n", "bytes", "from", "the", "buffer", "advancing", "the", "buffer", "as", "if", "the", "bytes", "had", "been", "returned", "by", "Read", ".", "If", "there", "are", "fewer", "than", "n", "byte...
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/io/byte_reader.go#L109-L117
train
hprose/hprose-golang
rpc/http_client.go
NewHTTPClient
func NewHTTPClient(uri ...string) (client *HTTPClient) { client = new(HTTPClient) client.InitBaseClient() client.limiter.InitLimiter() client.httpClient.Transport = &client.Transport client.Header = make(http.Header) client.DisableCompression = true client.DisableKeepAlives = false client.MaxIdleConnsPerHost = ...
go
func NewHTTPClient(uri ...string) (client *HTTPClient) { client = new(HTTPClient) client.InitBaseClient() client.limiter.InitLimiter() client.httpClient.Transport = &client.Transport client.Header = make(http.Header) client.DisableCompression = true client.DisableKeepAlives = false client.MaxIdleConnsPerHost = ...
[ "func", "NewHTTPClient", "(", "uri", "...", "string", ")", "(", "client", "*", "HTTPClient", ")", "{", "client", "=", "new", "(", "HTTPClient", ")", "\n", "client", ".", "InitBaseClient", "(", ")", "\n", "client", ".", "limiter", ".", "InitLimiter", "(",...
// NewHTTPClient is the constructor of HTTPClient
[ "NewHTTPClient", "is", "the", "constructor", "of", "HTTPClient" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/http_client.go#L47-L63
train
hprose/hprose-golang
rpc/fasthttp/fasthttp_client.go
NewFastHTTPClient
func NewFastHTTPClient(uri ...string) (client *FastHTTPClient) { client = new(FastHTTPClient) client.InitBaseClient() client.limiter.InitLimiter() client.cookieManager = globalCookieManager if rpc.DisableGlobalCookie { client.cookieManager = newCookieManager() } client.compression = false client.keepAlive = t...
go
func NewFastHTTPClient(uri ...string) (client *FastHTTPClient) { client = new(FastHTTPClient) client.InitBaseClient() client.limiter.InitLimiter() client.cookieManager = globalCookieManager if rpc.DisableGlobalCookie { client.cookieManager = newCookieManager() } client.compression = false client.keepAlive = t...
[ "func", "NewFastHTTPClient", "(", "uri", "...", "string", ")", "(", "client", "*", "FastHTTPClient", ")", "{", "client", "=", "new", "(", "FastHTTPClient", ")", "\n", "client", ".", "InitBaseClient", "(", ")", "\n", "client", ".", "limiter", ".", "InitLimi...
// NewFastHTTPClient is the constructor of FastHTTPClient
[ "NewFastHTTPClient", "is", "the", "constructor", "of", "FastHTTPClient" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/fasthttp/fasthttp_client.go#L97-L110
train
hprose/hprose-golang
rpc/limiter.go
Limit
func (limiter *Limiter) Limit() { for { if limiter.requestCount < limiter.MaxConcurrentRequests { break } limiter.Wait() } limiter.requestCount++ }
go
func (limiter *Limiter) Limit() { for { if limiter.requestCount < limiter.MaxConcurrentRequests { break } limiter.Wait() } limiter.requestCount++ }
[ "func", "(", "limiter", "*", "Limiter", ")", "Limit", "(", ")", "{", "for", "{", "if", "limiter", ".", "requestCount", "<", "limiter", ".", "MaxConcurrentRequests", "{", "break", "\n", "}", "\n", "limiter", ".", "Wait", "(", ")", "\n", "}", "\n", "li...
// Limit the request
[ "Limit", "the", "request" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/limiter.go#L38-L46
train
hprose/hprose-golang
rpc/limiter.go
Reset
func (limiter *Limiter) Reset() { limiter.requestCount = 0 for i := limiter.MaxConcurrentRequests; i > 0; i-- { limiter.Signal() } }
go
func (limiter *Limiter) Reset() { limiter.requestCount = 0 for i := limiter.MaxConcurrentRequests; i > 0; i-- { limiter.Signal() } }
[ "func", "(", "limiter", "*", "Limiter", ")", "Reset", "(", ")", "{", "limiter", ".", "requestCount", "=", "0", "\n", "for", "i", ":=", "limiter", ".", "MaxConcurrentRequests", ";", "i", ">", "0", ";", "i", "--", "{", "limiter", ".", "Signal", "(", ...
// Reset the Limiter
[ "Reset", "the", "Limiter" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/limiter.go#L55-L60
train
hprose/hprose-golang
rpc/basehttp_service.go
InitBaseHTTPService
func (service *BaseHTTPService) InitBaseHTTPService() { t := time.Now().UTC() rand.Seed(t.UnixNano()) service.InitBaseService() service.P3P = true service.GET = true service.CrossDomain = true service.AccessControlAllowOrigins = make(map[string]bool) service.LastModified = t.Format(time.RFC1123) service.Etag =...
go
func (service *BaseHTTPService) InitBaseHTTPService() { t := time.Now().UTC() rand.Seed(t.UnixNano()) service.InitBaseService() service.P3P = true service.GET = true service.CrossDomain = true service.AccessControlAllowOrigins = make(map[string]bool) service.LastModified = t.Format(time.RFC1123) service.Etag =...
[ "func", "(", "service", "*", "BaseHTTPService", ")", "InitBaseHTTPService", "(", ")", "{", "t", ":=", "time", ".", "Now", "(", ")", ".", "UTC", "(", ")", "\n", "rand", ".", "Seed", "(", "t", ".", "UnixNano", "(", ")", ")", "\n", "service", ".", "...
// InitBaseHTTPService initializes BaseHTTPService
[ "InitBaseHTTPService", "initializes", "BaseHTTPService" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/basehttp_service.go#L45-L55
train
hprose/hprose-golang
rpc/basehttp_service.go
AddAccessControlAllowOrigin
func (service *BaseHTTPService) AddAccessControlAllowOrigin(origins ...string) { for _, origin := range origins { service.AccessControlAllowOrigins[origin] = true } }
go
func (service *BaseHTTPService) AddAccessControlAllowOrigin(origins ...string) { for _, origin := range origins { service.AccessControlAllowOrigins[origin] = true } }
[ "func", "(", "service", "*", "BaseHTTPService", ")", "AddAccessControlAllowOrigin", "(", "origins", "...", "string", ")", "{", "for", "_", ",", "origin", ":=", "range", "origins", "{", "service", ".", "AccessControlAllowOrigins", "[", "origin", "]", "=", "true...
// AddAccessControlAllowOrigin add access control allow origin
[ "AddAccessControlAllowOrigin", "add", "access", "control", "allow", "origin" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/basehttp_service.go#L58-L62
train
hprose/hprose-golang
rpc/basehttp_service.go
RemoveAccessControlAllowOrigin
func (service *BaseHTTPService) RemoveAccessControlAllowOrigin(origins ...string) { for _, origin := range origins { delete(service.AccessControlAllowOrigins, origin) } }
go
func (service *BaseHTTPService) RemoveAccessControlAllowOrigin(origins ...string) { for _, origin := range origins { delete(service.AccessControlAllowOrigins, origin) } }
[ "func", "(", "service", "*", "BaseHTTPService", ")", "RemoveAccessControlAllowOrigin", "(", "origins", "...", "string", ")", "{", "for", "_", ",", "origin", ":=", "range", "origins", "{", "delete", "(", "service", ".", "AccessControlAllowOrigins", ",", "origin",...
// RemoveAccessControlAllowOrigin remove access control allow origin
[ "RemoveAccessControlAllowOrigin", "remove", "access", "control", "allow", "origin" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/basehttp_service.go#L65-L69
train
hprose/hprose-golang
rpc/basehttp_service.go
SetCrossDomainXMLFile
func (service *BaseHTTPService) SetCrossDomainXMLFile(filename string) { service.crossDomainXMLFile = filename service.crossDomainXMLContent, _ = ioutil.ReadFile(filename) }
go
func (service *BaseHTTPService) SetCrossDomainXMLFile(filename string) { service.crossDomainXMLFile = filename service.crossDomainXMLContent, _ = ioutil.ReadFile(filename) }
[ "func", "(", "service", "*", "BaseHTTPService", ")", "SetCrossDomainXMLFile", "(", "filename", "string", ")", "{", "service", ".", "crossDomainXMLFile", "=", "filename", "\n", "service", ".", "crossDomainXMLContent", ",", "_", "=", "ioutil", ".", "ReadFile", "("...
// SetCrossDomainXMLFile set the cross domain xml file
[ "SetCrossDomainXMLFile", "set", "the", "cross", "domain", "xml", "file" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/basehttp_service.go#L92-L95
train
hprose/hprose-golang
rpc/basehttp_service.go
SetClientAccessPolicyXMLFile
func (service *BaseHTTPService) SetClientAccessPolicyXMLFile(filename string) { service.clientAccessPolicyXMLFile = filename service.clientAccessPolicyXMLContent, _ = ioutil.ReadFile(filename) }
go
func (service *BaseHTTPService) SetClientAccessPolicyXMLFile(filename string) { service.clientAccessPolicyXMLFile = filename service.clientAccessPolicyXMLContent, _ = ioutil.ReadFile(filename) }
[ "func", "(", "service", "*", "BaseHTTPService", ")", "SetClientAccessPolicyXMLFile", "(", "filename", "string", ")", "{", "service", ".", "clientAccessPolicyXMLFile", "=", "filename", "\n", "service", ".", "clientAccessPolicyXMLContent", ",", "_", "=", "ioutil", "."...
// SetClientAccessPolicyXMLFile set the client access policy xml file
[ "SetClientAccessPolicyXMLFile", "set", "the", "client", "access", "policy", "xml", "file" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/basehttp_service.go#L98-L101
train
hprose/hprose-golang
rpc/basehttp_service.go
SetCrossDomainXMLContent
func (service *BaseHTTPService) SetCrossDomainXMLContent(content []byte) { service.crossDomainXMLFile = "" service.crossDomainXMLContent = content }
go
func (service *BaseHTTPService) SetCrossDomainXMLContent(content []byte) { service.crossDomainXMLFile = "" service.crossDomainXMLContent = content }
[ "func", "(", "service", "*", "BaseHTTPService", ")", "SetCrossDomainXMLContent", "(", "content", "[", "]", "byte", ")", "{", "service", ".", "crossDomainXMLFile", "=", "\"", "\"", "\n", "service", ".", "crossDomainXMLContent", "=", "content", "\n", "}" ]
// SetCrossDomainXMLContent set the cross domain xml content
[ "SetCrossDomainXMLContent", "set", "the", "cross", "domain", "xml", "content" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/basehttp_service.go#L104-L107
train
hprose/hprose-golang
rpc/basehttp_service.go
SetClientAccessPolicyXMLContent
func (service *BaseHTTPService) SetClientAccessPolicyXMLContent(content []byte) { service.clientAccessPolicyXMLFile = "" service.clientAccessPolicyXMLContent = content }
go
func (service *BaseHTTPService) SetClientAccessPolicyXMLContent(content []byte) { service.clientAccessPolicyXMLFile = "" service.clientAccessPolicyXMLContent = content }
[ "func", "(", "service", "*", "BaseHTTPService", ")", "SetClientAccessPolicyXMLContent", "(", "content", "[", "]", "byte", ")", "{", "service", ".", "clientAccessPolicyXMLFile", "=", "\"", "\"", "\n", "service", ".", "clientAccessPolicyXMLContent", "=", "content", ...
// SetClientAccessPolicyXMLContent set the client access policy xml content
[ "SetClientAccessPolicyXMLContent", "set", "the", "client", "access", "policy", "xml", "content" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/basehttp_service.go#L110-L113
train
hprose/hprose-golang
io/byte_writer.go
NewByteWriter
func NewByteWriter(buf []byte) (w *ByteWriter) { w = new(ByteWriter) w.buf = buf return w }
go
func NewByteWriter(buf []byte) (w *ByteWriter) { w = new(ByteWriter) w.buf = buf return w }
[ "func", "NewByteWriter", "(", "buf", "[", "]", "byte", ")", "(", "w", "*", "ByteWriter", ")", "{", "w", "=", "new", "(", "ByteWriter", ")", "\n", "w", ".", "buf", "=", "buf", "\n", "return", "w", "\n", "}" ]
// NewByteWriter create a ByteWriter in append mode
[ "NewByteWriter", "create", "a", "ByteWriter", "in", "append", "mode" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/io/byte_writer.go#L30-L34
train
hprose/hprose-golang
io/byte_writer.go
Grow
func (w *ByteWriter) Grow(n int) { if n < 0 { panic("BytesWriter: negative count") } p := w.grow(n) w.buf = w.buf[0:p] }
go
func (w *ByteWriter) Grow(n int) { if n < 0 { panic("BytesWriter: negative count") } p := w.grow(n) w.buf = w.buf[0:p] }
[ "func", "(", "w", "*", "ByteWriter", ")", "Grow", "(", "n", "int", ")", "{", "if", "n", "<", "0", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "p", ":=", "w", ".", "grow", "(", "n", ")", "\n", "w", ".", "buf", "=", "w", ".", "bu...
// Grow the the byte slice capacity of this writer.
[ "Grow", "the", "the", "byte", "slice", "capacity", "of", "this", "writer", "." ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/io/byte_writer.go#L81-L87
train
hprose/hprose-golang
io/byte_writer.go
WriteByte
func (w *ByteWriter) WriteByte(c byte) error { p := w.grow(1) w.buf[p] = c return nil }
go
func (w *ByteWriter) WriteByte(c byte) error { p := w.grow(1) w.buf[p] = c return nil }
[ "func", "(", "w", "*", "ByteWriter", ")", "WriteByte", "(", "c", "byte", ")", "error", "{", "p", ":=", "w", ".", "grow", "(", "1", ")", "\n", "w", ".", "buf", "[", "p", "]", "=", "c", "\n", "return", "nil", "\n", "}" ]
// WriteByte c to the byte slice of this writer.
[ "WriteByte", "c", "to", "the", "byte", "slice", "of", "this", "writer", "." ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/io/byte_writer.go#L90-L94
train
hprose/hprose-golang
io/byte_writer.go
Write
func (w *ByteWriter) Write(b []byte) (int, error) { p := w.grow(len(b)) return copy(w.buf[p:], b), nil }
go
func (w *ByteWriter) Write(b []byte) (int, error) { p := w.grow(len(b)) return copy(w.buf[p:], b), nil }
[ "func", "(", "w", "*", "ByteWriter", ")", "Write", "(", "b", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "p", ":=", "w", ".", "grow", "(", "len", "(", "b", ")", ")", "\n", "return", "copy", "(", "w", ".", "buf", "[", "p", "...
// Write the contents of b to the byte slice of this writer.
[ "Write", "the", "contents", "of", "b", "to", "the", "byte", "slice", "of", "this", "writer", "." ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/io/byte_writer.go#L97-L100
train
hprose/hprose-golang
rpc/unix_client.go
NewUnixClient
func NewUnixClient(uri ...string) (client *UnixClient) { client = new(UnixClient) client.initSocketClient() client.setCreateConn(client.createUnixConn) client.SetURIList(uri) return }
go
func NewUnixClient(uri ...string) (client *UnixClient) { client = new(UnixClient) client.initSocketClient() client.setCreateConn(client.createUnixConn) client.SetURIList(uri) return }
[ "func", "NewUnixClient", "(", "uri", "...", "string", ")", "(", "client", "*", "UnixClient", ")", "{", "client", "=", "new", "(", "UnixClient", ")", "\n", "client", ".", "initSocketClient", "(", ")", "\n", "client", ".", "setCreateConn", "(", "client", "...
// NewUnixClient is the constructor of UnixClient
[ "NewUnixClient", "is", "the", "constructor", "of", "UnixClient" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/unix_client.go#L34-L40
train
hprose/hprose-golang
rpc/unix_server.go
NewUnixServer
func NewUnixServer(uri string) (server *UnixServer) { if uri == "" { uri = "unix:/tmp/hprose.sock" } server = new(UnixServer) server.initSocketService() server.starter.server = server server.uri = uri return }
go
func NewUnixServer(uri string) (server *UnixServer) { if uri == "" { uri = "unix:/tmp/hprose.sock" } server = new(UnixServer) server.initSocketService() server.starter.server = server server.uri = uri return }
[ "func", "NewUnixServer", "(", "uri", "string", ")", "(", "server", "*", "UnixServer", ")", "{", "if", "uri", "==", "\"", "\"", "{", "uri", "=", "\"", "\"", "\n", "}", "\n", "server", "=", "new", "(", "UnixServer", ")", "\n", "server", ".", "initSoc...
// NewUnixServer is the constructor for UnixServer
[ "NewUnixServer", "is", "the", "constructor", "for", "UnixServer" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/unix_server.go#L36-L45
train
hprose/hprose-golang
rpc/unix_server.go
Handle
func (server *UnixServer) Handle() (err error) { if server.listener != nil { return ErrServerIsAlreadyStarted } u, err := url.Parse(server.uri) if err != nil { return err } addr, err := net.ResolveUnixAddr(u.Scheme, u.Path) if err != nil { return err } if server.listener, err = net.ListenUnix(u.Scheme, a...
go
func (server *UnixServer) Handle() (err error) { if server.listener != nil { return ErrServerIsAlreadyStarted } u, err := url.Parse(server.uri) if err != nil { return err } addr, err := net.ResolveUnixAddr(u.Scheme, u.Path) if err != nil { return err } if server.listener, err = net.ListenUnix(u.Scheme, a...
[ "func", "(", "server", "*", "UnixServer", ")", "Handle", "(", ")", "(", "err", "error", ")", "{", "if", "server", ".", "listener", "!=", "nil", "{", "return", "ErrServerIsAlreadyStarted", "\n", "}", "\n", "u", ",", "err", ":=", "url", ".", "Parse", "...
// Handle the hprose unix server
[ "Handle", "the", "hprose", "unix", "server" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/unix_server.go#L56-L73
train
hprose/hprose-golang
rpc/unix_server.go
Close
func (server *UnixServer) Close() { if server.listener != nil { listener := server.listener server.listener = nil listener.Close() } }
go
func (server *UnixServer) Close() { if server.listener != nil { listener := server.listener server.listener = nil listener.Close() } }
[ "func", "(", "server", "*", "UnixServer", ")", "Close", "(", ")", "{", "if", "server", ".", "listener", "!=", "nil", "{", "listener", ":=", "server", ".", "listener", "\n", "server", ".", "listener", "=", "nil", "\n", "listener", ".", "Close", "(", "...
// Close the hprose unix server
[ "Close", "the", "hprose", "unix", "server" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/unix_server.go#L76-L82
train
hprose/hprose-golang
rpc/filter.go
Filter
func (fm *filterManager) Filter() Filter { fm.fmLocker.RLock() defer fm.fmLocker.RUnlock() if len(fm.filters) == 0 { return nil } return fm.filters[0] }
go
func (fm *filterManager) Filter() Filter { fm.fmLocker.RLock() defer fm.fmLocker.RUnlock() if len(fm.filters) == 0 { return nil } return fm.filters[0] }
[ "func", "(", "fm", "*", "filterManager", ")", "Filter", "(", ")", "Filter", "{", "fm", ".", "fmLocker", ".", "RLock", "(", ")", "\n", "defer", "fm", ".", "fmLocker", ".", "RUnlock", "(", ")", "\n", "if", "len", "(", "fm", ".", "filters", ")", "==...
// Filter return the first filter
[ "Filter", "return", "the", "first", "filter" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/filter.go#L37-L44
train
hprose/hprose-golang
rpc/filter.go
NumFilter
func (fm *filterManager) NumFilter() int { fm.fmLocker.RLock() defer fm.fmLocker.RUnlock() return len(fm.filters) }
go
func (fm *filterManager) NumFilter() int { fm.fmLocker.RLock() defer fm.fmLocker.RUnlock() return len(fm.filters) }
[ "func", "(", "fm", "*", "filterManager", ")", "NumFilter", "(", ")", "int", "{", "fm", ".", "fmLocker", ".", "RLock", "(", ")", "\n", "defer", "fm", ".", "fmLocker", ".", "RUnlock", "(", ")", "\n", "return", "len", "(", "fm", ".", "filters", ")", ...
// NumFilter return the filter count
[ "NumFilter", "return", "the", "filter", "count" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/filter.go#L47-L51
train
hprose/hprose-golang
rpc/filter.go
FilterByIndex
func (fm *filterManager) FilterByIndex(index int) Filter { fm.fmLocker.RLock() defer fm.fmLocker.RUnlock() n := len(fm.filters) if index < 0 && index >= n { return nil } return fm.filters[index] }
go
func (fm *filterManager) FilterByIndex(index int) Filter { fm.fmLocker.RLock() defer fm.fmLocker.RUnlock() n := len(fm.filters) if index < 0 && index >= n { return nil } return fm.filters[index] }
[ "func", "(", "fm", "*", "filterManager", ")", "FilterByIndex", "(", "index", "int", ")", "Filter", "{", "fm", ".", "fmLocker", ".", "RLock", "(", ")", "\n", "defer", "fm", ".", "fmLocker", ".", "RUnlock", "(", ")", "\n", "n", ":=", "len", "(", "fm"...
// FilterByIndex return the filter by index
[ "FilterByIndex", "return", "the", "filter", "by", "index" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/filter.go#L54-L62
train
hprose/hprose-golang
rpc/filter.go
AddFilter
func (fm *filterManager) AddFilter(filter ...Filter) { fm.fmLocker.Lock() fm.addFilter(filter...) fm.fmLocker.Unlock() }
go
func (fm *filterManager) AddFilter(filter ...Filter) { fm.fmLocker.Lock() fm.addFilter(filter...) fm.fmLocker.Unlock() }
[ "func", "(", "fm", "*", "filterManager", ")", "AddFilter", "(", "filter", "...", "Filter", ")", "{", "fm", ".", "fmLocker", ".", "Lock", "(", ")", "\n", "fm", ".", "addFilter", "(", "filter", "...", ")", "\n", "fm", ".", "fmLocker", ".", "Unlock", ...
// AddFilter add the filter to this FilterManager
[ "AddFilter", "add", "the", "filter", "to", "this", "FilterManager" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/filter.go#L79-L83
train
hprose/hprose-golang
rpc/filter.go
RemoveFilter
func (fm *filterManager) RemoveFilter(filter ...Filter) { for i := range filter { fm.removeFilter(filter[i]) } }
go
func (fm *filterManager) RemoveFilter(filter ...Filter) { for i := range filter { fm.removeFilter(filter[i]) } }
[ "func", "(", "fm", "*", "filterManager", ")", "RemoveFilter", "(", "filter", "...", "Filter", ")", "{", "for", "i", ":=", "range", "filter", "{", "fm", ".", "removeFilter", "(", "filter", "[", "i", "]", ")", "\n", "}", "\n", "}" ]
// RemoveFilter remove the filter from this FilterManager
[ "RemoveFilter", "remove", "the", "filter", "from", "this", "FilterManager" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/filter.go#L111-L115
train
hprose/hprose-golang
io/struct_encoder.go
Register
func Register(proto interface{}, alias string, tag ...string) { structType := reflect.TypeOf(proto) if structType.Kind() == reflect.Ptr { structType = structType.Elem() } if structType.Kind() != reflect.Struct { panic("invalid type: " + structType.String()) } structTypesLocker.Lock() structTypes[alias] = str...
go
func Register(proto interface{}, alias string, tag ...string) { structType := reflect.TypeOf(proto) if structType.Kind() == reflect.Ptr { structType = structType.Elem() } if structType.Kind() != reflect.Struct { panic("invalid type: " + structType.String()) } structTypesLocker.Lock() structTypes[alias] = str...
[ "func", "Register", "(", "proto", "interface", "{", "}", ",", "alias", "string", ",", "tag", "...", "string", ")", "{", "structType", ":=", "reflect", ".", "TypeOf", "(", "proto", ")", "\n", "if", "structType", ".", "Kind", "(", ")", "==", "reflect", ...
// Register the type of the proto with alias & tag.
[ "Register", "the", "type", "of", "the", "proto", "with", "alias", "&", "tag", "." ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/io/struct_encoder.go#L164-L185
train
hprose/hprose-golang
io/struct_encoder.go
GetStructType
func GetStructType(alias string) (structType reflect.Type) { structTypesLocker.RLock() structType = structTypes[alias] structTypesLocker.RUnlock() return structType }
go
func GetStructType(alias string) (structType reflect.Type) { structTypesLocker.RLock() structType = structTypes[alias] structTypesLocker.RUnlock() return structType }
[ "func", "GetStructType", "(", "alias", "string", ")", "(", "structType", "reflect", ".", "Type", ")", "{", "structTypesLocker", ".", "RLock", "(", ")", "\n", "structType", "=", "structTypes", "[", "alias", "]", "\n", "structTypesLocker", ".", "RUnlock", "(",...
// GetStructType by alias.
[ "GetStructType", "by", "alias", "." ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/io/struct_encoder.go#L188-L193
train
hprose/hprose-golang
io/byte_pool.go
AcquireBytes
func AcquireBytes(size int) []byte { if size < 1 { return nil } capacity := pow2roundup(int64(size)) if capacity > maxSize { return make([]byte, size, capacity) } if capacity < 512 { capacity = 512 } return bytePool[log2(capacity)-9].Get().([]byte)[:size] }
go
func AcquireBytes(size int) []byte { if size < 1 { return nil } capacity := pow2roundup(int64(size)) if capacity > maxSize { return make([]byte, size, capacity) } if capacity < 512 { capacity = 512 } return bytePool[log2(capacity)-9].Get().([]byte)[:size] }
[ "func", "AcquireBytes", "(", "size", "int", ")", "[", "]", "byte", "{", "if", "size", "<", "1", "{", "return", "nil", "\n", "}", "\n", "capacity", ":=", "pow2roundup", "(", "int64", "(", "size", ")", ")", "\n", "if", "capacity", ">", "maxSize", "{"...
// AcquireBytes from pool.
[ "AcquireBytes", "from", "pool", "." ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/io/byte_pool.go#L68-L80
train
hprose/hprose-golang
io/byte_pool.go
ReleaseBytes
func ReleaseBytes(bytes []byte) bool { capacity := int64(cap(bytes)) if capacity < 512 || capacity > maxSize || capacity != pow2roundup(capacity) { return false } bytePool[log2(capacity)-9].Put(bytes) return true }
go
func ReleaseBytes(bytes []byte) bool { capacity := int64(cap(bytes)) if capacity < 512 || capacity > maxSize || capacity != pow2roundup(capacity) { return false } bytePool[log2(capacity)-9].Put(bytes) return true }
[ "func", "ReleaseBytes", "(", "bytes", "[", "]", "byte", ")", "bool", "{", "capacity", ":=", "int64", "(", "cap", "(", "bytes", ")", ")", "\n", "if", "capacity", "<", "512", "||", "capacity", ">", "maxSize", "||", "capacity", "!=", "pow2roundup", "(", ...
// ReleaseBytes to pool.
[ "ReleaseBytes", "to", "pool", "." ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/io/byte_pool.go#L83-L90
train
hprose/hprose-golang
rpc/method.go
AddFunction
func (mm *methodManager) AddFunction( name string, function interface{}, option ...Options) { if name == "" { panic("name can't be empty") } if function == nil { panic("function can't be nil") } f, ok := function.(reflect.Value) if !ok { f = reflect.ValueOf(function) } if f.Kind() != reflect.Func { pan...
go
func (mm *methodManager) AddFunction( name string, function interface{}, option ...Options) { if name == "" { panic("name can't be empty") } if function == nil { panic("function can't be nil") } f, ok := function.(reflect.Value) if !ok { f = reflect.ValueOf(function) } if f.Kind() != reflect.Func { pan...
[ "func", "(", "mm", "*", "methodManager", ")", "AddFunction", "(", "name", "string", ",", "function", "interface", "{", "}", ",", "option", "...", "Options", ")", "{", "if", "name", "==", "\"", "\"", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\...
// AddFunction publish a func or bound method // name is the method name // function is a func or bound method // option includes Mode, Simple, Oneway and NameSpace
[ "AddFunction", "publish", "a", "func", "or", "bound", "method", "name", "is", "the", "method", "name", "function", "is", "a", "func", "or", "bound", "method", "option", "includes", "Mode", "Simple", "Oneway", "and", "NameSpace" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/method.go#L59-L87
train
hprose/hprose-golang
rpc/service_context.go
InitServiceContext
func (context *BaseServiceContext) InitServiceContext(service Service) { context.InitBaseContext() context.service = service context.method = nil context.isMissingMethod = false context.byRef = false }
go
func (context *BaseServiceContext) InitServiceContext(service Service) { context.InitBaseContext() context.service = service context.method = nil context.isMissingMethod = false context.byRef = false }
[ "func", "(", "context", "*", "BaseServiceContext", ")", "InitServiceContext", "(", "service", "Service", ")", "{", "context", ".", "InitBaseContext", "(", ")", "\n", "context", ".", "service", "=", "service", "\n", "context", ".", "method", "=", "nil", "\n",...
// InitServiceContext initializes BaseServiceContext
[ "InitServiceContext", "initializes", "BaseServiceContext" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/service_context.go#L45-L51
train
hprose/hprose-golang
rpc/tcp_service.go
ServeTCPConn
func (service *TCPService) ServeTCPConn(conn *net.TCPConn) { conn.SetLinger(service.Linger) conn.SetNoDelay(service.NoDelay) conn.SetKeepAlive(service.KeepAlive) if service.KeepAlivePeriod > 0 { conn.SetKeepAlivePeriod(service.KeepAlivePeriod) } if service.TLSConfig != nil { tlsConn := tls.Server(conn, servic...
go
func (service *TCPService) ServeTCPConn(conn *net.TCPConn) { conn.SetLinger(service.Linger) conn.SetNoDelay(service.NoDelay) conn.SetKeepAlive(service.KeepAlive) if service.KeepAlivePeriod > 0 { conn.SetKeepAlivePeriod(service.KeepAlivePeriod) } if service.TLSConfig != nil { tlsConn := tls.Server(conn, servic...
[ "func", "(", "service", "*", "TCPService", ")", "ServeTCPConn", "(", "conn", "*", "net", ".", "TCPConn", ")", "{", "conn", ".", "SetLinger", "(", "service", ".", "Linger", ")", "\n", "conn", ".", "SetNoDelay", "(", "service", ".", "NoDelay", ")", "\n",...
// ServeTCPConn runs on a single tcp connection. ServeTCPConn blocks, serving // the connection until the client hangs up. The caller typically invokes // ServeTCPConn in a go statement.
[ "ServeTCPConn", "runs", "on", "a", "single", "tcp", "connection", ".", "ServeTCPConn", "blocks", "serving", "the", "connection", "until", "the", "client", "hangs", "up", ".", "The", "caller", "typically", "invokes", "ServeTCPConn", "in", "a", "go", "statement", ...
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/tcp_service.go#L55-L69
train
hprose/hprose-golang
rpc/tcp_service.go
ServeTCP
func (service *TCPService) ServeTCP(listener *net.TCPListener) { service.workerPool.Start(); defer service.workerPool.Stop(); var tempDelay time.Duration // how long to sleep on accept failure for { conn, err := listener.AcceptTCP() if err != nil { tempDelay = nextTempDelay(err, service.Event, tempDelay) ...
go
func (service *TCPService) ServeTCP(listener *net.TCPListener) { service.workerPool.Start(); defer service.workerPool.Stop(); var tempDelay time.Duration // how long to sleep on accept failure for { conn, err := listener.AcceptTCP() if err != nil { tempDelay = nextTempDelay(err, service.Event, tempDelay) ...
[ "func", "(", "service", "*", "TCPService", ")", "ServeTCP", "(", "listener", "*", "net", ".", "TCPListener", ")", "{", "service", ".", "workerPool", ".", "Start", "(", ")", ";", "defer", "service", ".", "workerPool", ".", "Stop", "(", ")", ";", "var", ...
// ServeTCP runs on the TCPListener. ServeTCP blocks, serving the listener // until the server is stop. The caller typically invokes ServeTCP in a go // statement.
[ "ServeTCP", "runs", "on", "the", "TCPListener", ".", "ServeTCP", "blocks", "serving", "the", "listener", "until", "the", "server", "is", "stop", ".", "The", "caller", "typically", "invokes", "ServeTCP", "in", "a", "go", "statement", "." ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/tcp_service.go#L81-L99
train
hprose/hprose-golang
rpc/filter/jsonrpc/service_filter.go
InputFilter
func (filter ServiceFilter) InputFilter(data []byte, context rpc.Context) []byte { if (len(data) > 0) && (data[0] == '[' || data[0] == '{') { var requests []map[string]interface{} if data[0] == '[' { if err := json.Unmarshal(data, &requests); err != nil { return data } } else { requests = make([]map...
go
func (filter ServiceFilter) InputFilter(data []byte, context rpc.Context) []byte { if (len(data) > 0) && (data[0] == '[' || data[0] == '{') { var requests []map[string]interface{} if data[0] == '[' { if err := json.Unmarshal(data, &requests); err != nil { return data } } else { requests = make([]map...
[ "func", "(", "filter", "ServiceFilter", ")", "InputFilter", "(", "data", "[", "]", "byte", ",", "context", "rpc", ".", "Context", ")", "[", "]", "byte", "{", "if", "(", "len", "(", "data", ")", ">", "0", ")", "&&", "(", "data", "[", "0", "]", "...
// InputFilter for JSONRPC Service
[ "InputFilter", "for", "JSONRPC", "Service" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/filter/jsonrpc/service_filter.go#L52-L83
train
hprose/hprose-golang
rpc/filter/jsonrpc/service_filter.go
OutputFilter
func (filter ServiceFilter) OutputFilter(data []byte, context rpc.Context) []byte { responses, ok := context.GetInterface("jsonrpc").([]map[string]interface{}) if ok && responses != nil { reader := io.NewReader(data, false) reader.JSONCompatible = true tag, _ := reader.ReadByte() for _, response := range resp...
go
func (filter ServiceFilter) OutputFilter(data []byte, context rpc.Context) []byte { responses, ok := context.GetInterface("jsonrpc").([]map[string]interface{}) if ok && responses != nil { reader := io.NewReader(data, false) reader.JSONCompatible = true tag, _ := reader.ReadByte() for _, response := range resp...
[ "func", "(", "filter", "ServiceFilter", ")", "OutputFilter", "(", "data", "[", "]", "byte", ",", "context", "rpc", ".", "Context", ")", "[", "]", "byte", "{", "responses", ",", "ok", ":=", "context", ".", "GetInterface", "(", "\"", "\"", ")", ".", "(...
// OutputFilter for JSONRPC Service
[ "OutputFilter", "for", "JSONRPC", "Service" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/filter/jsonrpc/service_filter.go#L86-L119
train
hprose/hprose-golang
io/raw_reader.go
NewRawReader
func NewRawReader(buf []byte) (reader *RawReader) { reader = new(RawReader) reader.buf = buf return }
go
func NewRawReader(buf []byte) (reader *RawReader) { reader = new(RawReader) reader.buf = buf return }
[ "func", "NewRawReader", "(", "buf", "[", "]", "byte", ")", "(", "reader", "*", "RawReader", ")", "{", "reader", "=", "new", "(", "RawReader", ")", "\n", "reader", ".", "buf", "=", "buf", "\n", "return", "\n", "}" ]
// NewRawReader is a constructor for RawReader
[ "NewRawReader", "is", "a", "constructor", "for", "RawReader" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/io/raw_reader.go#L30-L34
train
hprose/hprose-golang
io/raw_reader.go
ReadRaw
func (r *RawReader) ReadRaw() (raw []byte) { w := new(ByteWriter) r.ReadRawTo(w) raw = w.Bytes() return }
go
func (r *RawReader) ReadRaw() (raw []byte) { w := new(ByteWriter) r.ReadRawTo(w) raw = w.Bytes() return }
[ "func", "(", "r", "*", "RawReader", ")", "ReadRaw", "(", ")", "(", "raw", "[", "]", "byte", ")", "{", "w", ":=", "new", "(", "ByteWriter", ")", "\n", "r", ".", "ReadRawTo", "(", "w", ")", "\n", "raw", "=", "w", ".", "Bytes", "(", ")", "\n", ...
// ReadRaw from stream
[ "ReadRaw", "from", "stream" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/io/raw_reader.go#L37-L42
train
hprose/hprose-golang
io/raw_reader.go
ReadRawTo
func (r *RawReader) ReadRawTo(w *ByteWriter) { r.readRaw(w, r.readByte()) }
go
func (r *RawReader) ReadRawTo(w *ByteWriter) { r.readRaw(w, r.readByte()) }
[ "func", "(", "r", "*", "RawReader", ")", "ReadRawTo", "(", "w", "*", "ByteWriter", ")", "{", "r", ".", "readRaw", "(", "w", ",", "r", ".", "readByte", "(", ")", ")", "\n", "}" ]
// ReadRawTo buffer from stream
[ "ReadRawTo", "buffer", "from", "stream" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/io/raw_reader.go#L45-L47
train
hprose/hprose-golang
rpc/http_service.go
InitHTTPContext
func (context *HTTPContext) InitHTTPContext( service Service, response http.ResponseWriter, request *http.Request) { context.InitServiceContext(service) context.Response = response context.Request = request }
go
func (context *HTTPContext) InitHTTPContext( service Service, response http.ResponseWriter, request *http.Request) { context.InitServiceContext(service) context.Response = response context.Request = request }
[ "func", "(", "context", "*", "HTTPContext", ")", "InitHTTPContext", "(", "service", "Service", ",", "response", "http", ".", "ResponseWriter", ",", "request", "*", "http", ".", "Request", ")", "{", "context", ".", "InitServiceContext", "(", "service", ")", "...
// InitHTTPContext initializes HTTPContext
[ "InitHTTPContext", "initializes", "HTTPContext" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/http_service.go#L41-L48
train
hprose/hprose-golang
rpc/http_service.go
InitHTTPService
func (service *HTTPService) InitHTTPService() { service.InitBaseHTTPService() service.contextPool = sync.Pool{ New: func() interface{} { return new(HTTPContext) }, } service.FixArguments = httpFixArguments }
go
func (service *HTTPService) InitHTTPService() { service.InitBaseHTTPService() service.contextPool = sync.Pool{ New: func() interface{} { return new(HTTPContext) }, } service.FixArguments = httpFixArguments }
[ "func", "(", "service", "*", "HTTPService", ")", "InitHTTPService", "(", ")", "{", "service", ".", "InitBaseHTTPService", "(", ")", "\n", "service", ".", "contextPool", "=", "sync", ".", "Pool", "{", "New", ":", "func", "(", ")", "interface", "{", "}", ...
// InitHTTPService initializes HTTPService
[ "InitHTTPService", "initializes", "HTTPService" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/http_service.go#L88-L94
train
hprose/hprose-golang
rpc/client.go
CheckAddresses
func CheckAddresses(uriList []string, schemes []string) (scheme string) { count := len(uriList) if count < 1 { panic(ErrURIListEmpty) } u, err := url.Parse(uriList[0]) if err != nil { panic(err) } scheme = u.Scheme if sort.SearchStrings(schemes, scheme) == len(schemes) { panic(errors.New("This client desn...
go
func CheckAddresses(uriList []string, schemes []string) (scheme string) { count := len(uriList) if count < 1 { panic(ErrURIListEmpty) } u, err := url.Parse(uriList[0]) if err != nil { panic(err) } scheme = u.Scheme if sort.SearchStrings(schemes, scheme) == len(schemes) { panic(errors.New("This client desn...
[ "func", "CheckAddresses", "(", "uriList", "[", "]", "string", ",", "schemes", "[", "]", "string", ")", "(", "scheme", "string", ")", "{", "count", ":=", "len", "(", "uriList", ")", "\n", "if", "count", "<", "1", "{", "panic", "(", "ErrURIListEmpty", ...
// CheckAddresses returns the uri scheme if the address is valid.
[ "CheckAddresses", "returns", "the", "uri", "scheme", "if", "the", "address", "is", "valid", "." ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/client.go#L111-L134
train
hprose/hprose-golang
rpc/client.go
RegisterClientFactory
func RegisterClientFactory(scheme string, newClient func(...string) Client) { clientFactories[strings.ToLower(scheme)] = newClient }
go
func RegisterClientFactory(scheme string, newClient func(...string) Client) { clientFactories[strings.ToLower(scheme)] = newClient }
[ "func", "RegisterClientFactory", "(", "scheme", "string", ",", "newClient", "func", "(", "...", "string", ")", "Client", ")", "{", "clientFactories", "[", "strings", ".", "ToLower", "(", "scheme", ")", "]", "=", "newClient", "\n", "}" ]
// RegisterClientFactory registers the default client factory
[ "RegisterClientFactory", "registers", "the", "default", "client", "factory" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/client.go#L139-L141
train
hprose/hprose-golang
util/util.go
UTF16Length
func UTF16Length(str string) (n int) { length := len(str) n = length p := 0 for p < length { a := str[p] switch a >> 4 { case 0, 1, 2, 3, 4, 5, 6, 7: p++ case 12, 13: p += 2 n-- case 14: p += 3 n -= 2 case 15: if a&8 == 8 { return -1 } p += 4 n -= 2 default: return -1...
go
func UTF16Length(str string) (n int) { length := len(str) n = length p := 0 for p < length { a := str[p] switch a >> 4 { case 0, 1, 2, 3, 4, 5, 6, 7: p++ case 12, 13: p += 2 n-- case 14: p += 3 n -= 2 case 15: if a&8 == 8 { return -1 } p += 4 n -= 2 default: return -1...
[ "func", "UTF16Length", "(", "str", "string", ")", "(", "n", "int", ")", "{", "length", ":=", "len", "(", "str", ")", "\n", "n", "=", "length", "\n", "p", ":=", "0", "\n", "for", "p", "<", "length", "{", "a", ":=", "str", "[", "p", "]", "\n", ...
// UTF16Length return the UTF16 length of str. // str must be an UTF8 encode string, otherwise return -1.
[ "UTF16Length", "return", "the", "UTF16", "length", "of", "str", ".", "str", "must", "be", "an", "UTF8", "encode", "string", "otherwise", "return", "-", "1", "." ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/util/util.go#L242-L268
train
hprose/hprose-golang
util/util.go
StringByte
func StringByte(s string) []byte { sh := (*reflect.StringHeader)(unsafe.Pointer(&s)) bh := reflect.SliceHeader{ Data: sh.Data, Len: sh.Len, Cap: sh.Len, } return *(*[]byte)(unsafe.Pointer(&bh)) }
go
func StringByte(s string) []byte { sh := (*reflect.StringHeader)(unsafe.Pointer(&s)) bh := reflect.SliceHeader{ Data: sh.Data, Len: sh.Len, Cap: sh.Len, } return *(*[]byte)(unsafe.Pointer(&bh)) }
[ "func", "StringByte", "(", "s", "string", ")", "[", "]", "byte", "{", "sh", ":=", "(", "*", "reflect", ".", "StringHeader", ")", "(", "unsafe", ".", "Pointer", "(", "&", "s", ")", ")", "\n", "bh", ":=", "reflect", ".", "SliceHeader", "{", "Data", ...
// StringByte converts string to string without memory allocation by block magic
[ "StringByte", "converts", "string", "to", "string", "without", "memory", "allocation", "by", "block", "magic" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/util/util.go#L276-L284
train
hprose/hprose-golang
util/util.go
Itoa
func Itoa(i int) string { var buf [20]byte return ByteString(GetIntBytes(buf[:], int64(i))) }
go
func Itoa(i int) string { var buf [20]byte return ByteString(GetIntBytes(buf[:], int64(i))) }
[ "func", "Itoa", "(", "i", "int", ")", "string", "{", "var", "buf", "[", "20", "]", "byte", "\n", "return", "ByteString", "(", "GetIntBytes", "(", "buf", "[", ":", "]", ",", "int64", "(", "i", ")", ")", ")", "\n", "}" ]
// Itoa returns the string representation of i
[ "Itoa", "returns", "the", "string", "representation", "of", "i" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/util/util.go#L287-L290
train
hprose/hprose-golang
util/util.go
UUIDv4
func UUIDv4() (uid string) { u := make([]byte, 16) rand.Read(u) u[6] = (u[6] & 0x0f) | 0x40 u[8] = (u[8] & 0x3f) | 0x80 uid = fmt.Sprintf("%x-%x-%x-%x-%x", u[0:4], u[4:6], u[6:8], u[8:10], u[10:]) return }
go
func UUIDv4() (uid string) { u := make([]byte, 16) rand.Read(u) u[6] = (u[6] & 0x0f) | 0x40 u[8] = (u[8] & 0x3f) | 0x80 uid = fmt.Sprintf("%x-%x-%x-%x-%x", u[0:4], u[4:6], u[6:8], u[8:10], u[10:]) return }
[ "func", "UUIDv4", "(", ")", "(", "uid", "string", ")", "{", "u", ":=", "make", "(", "[", "]", "byte", ",", "16", ")", "\n", "rand", ".", "Read", "(", "u", ")", "\n", "u", "[", "6", "]", "=", "(", "u", "[", "6", "]", "&", "0x0f", ")", "|...
// UUIDv4 returns a version 4 UUID string
[ "UUIDv4", "returns", "a", "version", "4", "UUID", "string" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/util/util.go#L309-L316
train
hprose/hprose-golang
util/util.go
ToUint32
func ToUint32(b []byte) uint32 { return uint32(b[0])<<24 | uint32(b[1])<<16 | uint32(b[2])<<8 | uint32(b[3]) }
go
func ToUint32(b []byte) uint32 { return uint32(b[0])<<24 | uint32(b[1])<<16 | uint32(b[2])<<8 | uint32(b[3]) }
[ "func", "ToUint32", "(", "b", "[", "]", "byte", ")", "uint32", "{", "return", "uint32", "(", "b", "[", "0", "]", ")", "<<", "24", "|", "uint32", "(", "b", "[", "1", "]", ")", "<<", "16", "|", "uint32", "(", "b", "[", "2", "]", ")", "<<", ...
// ToUint32 translates 4 byte to uint32
[ "ToUint32", "translates", "4", "byte", "to", "uint32" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/util/util.go#L319-L321
train
hprose/hprose-golang
util/util.go
FromUint32
func FromUint32(b []byte, i uint32) { b[0] = byte(i >> 24) b[1] = byte(i >> 16) b[2] = byte(i >> 8) b[3] = byte(i) }
go
func FromUint32(b []byte, i uint32) { b[0] = byte(i >> 24) b[1] = byte(i >> 16) b[2] = byte(i >> 8) b[3] = byte(i) }
[ "func", "FromUint32", "(", "b", "[", "]", "byte", ",", "i", "uint32", ")", "{", "b", "[", "0", "]", "=", "byte", "(", "i", ">>", "24", ")", "\n", "b", "[", "1", "]", "=", "byte", "(", "i", ">>", "16", ")", "\n", "b", "[", "2", "]", "=",...
// FromUint32 translates uint32 to 4 byte
[ "FromUint32", "translates", "uint32", "to", "4", "byte" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/util/util.go#L324-L329
train
hprose/hprose-golang
util/util.go
LocalProxy
func LocalProxy(proxy, local interface{}) error { dstValue := reflect.ValueOf(proxy) srcValue := reflect.ValueOf(local) if dstValue.Kind() != reflect.Ptr { return errors.New("proxy must be a pointer") } dstValue = dstValue.Elem() t := dstValue.Type() et := t if et.Kind() == reflect.Ptr { et = et.Elem() } ...
go
func LocalProxy(proxy, local interface{}) error { dstValue := reflect.ValueOf(proxy) srcValue := reflect.ValueOf(local) if dstValue.Kind() != reflect.Ptr { return errors.New("proxy must be a pointer") } dstValue = dstValue.Elem() t := dstValue.Type() et := t if et.Kind() == reflect.Ptr { et = et.Elem() } ...
[ "func", "LocalProxy", "(", "proxy", ",", "local", "interface", "{", "}", ")", "error", "{", "dstValue", ":=", "reflect", ".", "ValueOf", "(", "proxy", ")", "\n", "srcValue", ":=", "reflect", ".", "ValueOf", "(", "local", ")", "\n", "if", "dstValue", "....
// LocalProxy make a local object to a proxy struct
[ "LocalProxy", "make", "a", "local", "object", "to", "a", "proxy", "struct" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/util/util.go#L332-L364
train
hprose/hprose-golang
rpc/context.go
GetInt
func (context *BaseContext) GetInt( key string, defaultValue ...int) int { if value, ok := context.userData[key]; ok { if value, ok := value.(int); ok { return value } } if len(defaultValue) > 0 { return defaultValue[0] } return 0 }
go
func (context *BaseContext) GetInt( key string, defaultValue ...int) int { if value, ok := context.userData[key]; ok { if value, ok := value.(int); ok { return value } } if len(defaultValue) > 0 { return defaultValue[0] } return 0 }
[ "func", "(", "context", "*", "BaseContext", ")", "GetInt", "(", "key", "string", ",", "defaultValue", "...", "int", ")", "int", "{", "if", "value", ",", "ok", ":=", "context", ".", "userData", "[", "key", "]", ";", "ok", "{", "if", "value", ",", "o...
// GetInt from hprose context
[ "GetInt", "from", "hprose", "context" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/context.go#L61-L72
train
hprose/hprose-golang
rpc/context.go
GetUInt
func (context *BaseContext) GetUInt( key string, defaultValue ...uint) uint { if value, ok := context.userData[key]; ok { if value, ok := value.(uint); ok { return value } } if len(defaultValue) > 0 { return defaultValue[0] } return 0 }
go
func (context *BaseContext) GetUInt( key string, defaultValue ...uint) uint { if value, ok := context.userData[key]; ok { if value, ok := value.(uint); ok { return value } } if len(defaultValue) > 0 { return defaultValue[0] } return 0 }
[ "func", "(", "context", "*", "BaseContext", ")", "GetUInt", "(", "key", "string", ",", "defaultValue", "...", "uint", ")", "uint", "{", "if", "value", ",", "ok", ":=", "context", ".", "userData", "[", "key", "]", ";", "ok", "{", "if", "value", ",", ...
// GetUInt from hprose context
[ "GetUInt", "from", "hprose", "context" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/context.go#L75-L86
train
hprose/hprose-golang
rpc/context.go
GetInt64
func (context *BaseContext) GetInt64( key string, defaultValue ...int64) int64 { if value, ok := context.userData[key]; ok { if value, ok := value.(int64); ok { return value } } if len(defaultValue) > 0 { return defaultValue[0] } return 0 }
go
func (context *BaseContext) GetInt64( key string, defaultValue ...int64) int64 { if value, ok := context.userData[key]; ok { if value, ok := value.(int64); ok { return value } } if len(defaultValue) > 0 { return defaultValue[0] } return 0 }
[ "func", "(", "context", "*", "BaseContext", ")", "GetInt64", "(", "key", "string", ",", "defaultValue", "...", "int64", ")", "int64", "{", "if", "value", ",", "ok", ":=", "context", ".", "userData", "[", "key", "]", ";", "ok", "{", "if", "value", ","...
// GetInt64 from hprose context
[ "GetInt64", "from", "hprose", "context" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/context.go#L89-L100
train
hprose/hprose-golang
rpc/context.go
GetUInt64
func (context *BaseContext) GetUInt64( key string, defaultValue ...uint64) uint64 { if value, ok := context.userData[key]; ok { if value, ok := value.(uint64); ok { return value } } if len(defaultValue) > 0 { return defaultValue[0] } return 0 }
go
func (context *BaseContext) GetUInt64( key string, defaultValue ...uint64) uint64 { if value, ok := context.userData[key]; ok { if value, ok := value.(uint64); ok { return value } } if len(defaultValue) > 0 { return defaultValue[0] } return 0 }
[ "func", "(", "context", "*", "BaseContext", ")", "GetUInt64", "(", "key", "string", ",", "defaultValue", "...", "uint64", ")", "uint64", "{", "if", "value", ",", "ok", ":=", "context", ".", "userData", "[", "key", "]", ";", "ok", "{", "if", "value", ...
// GetUInt64 from hprose context
[ "GetUInt64", "from", "hprose", "context" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/context.go#L103-L114
train
hprose/hprose-golang
rpc/context.go
GetFloat
func (context *BaseContext) GetFloat( key string, defaultValue ...float64) float64 { if value, ok := context.userData[key]; ok { if value, ok := value.(float64); ok { return value } } if len(defaultValue) > 0 { return defaultValue[0] } return 0 }
go
func (context *BaseContext) GetFloat( key string, defaultValue ...float64) float64 { if value, ok := context.userData[key]; ok { if value, ok := value.(float64); ok { return value } } if len(defaultValue) > 0 { return defaultValue[0] } return 0 }
[ "func", "(", "context", "*", "BaseContext", ")", "GetFloat", "(", "key", "string", ",", "defaultValue", "...", "float64", ")", "float64", "{", "if", "value", ",", "ok", ":=", "context", ".", "userData", "[", "key", "]", ";", "ok", "{", "if", "value", ...
// GetFloat from hprose context
[ "GetFloat", "from", "hprose", "context" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/context.go#L117-L128
train
hprose/hprose-golang
rpc/context.go
GetBool
func (context *BaseContext) GetBool( key string, defaultValue ...bool) bool { if value, ok := context.userData[key]; ok { if value, ok := value.(bool); ok { return value } } if len(defaultValue) > 0 { return defaultValue[0] } return false }
go
func (context *BaseContext) GetBool( key string, defaultValue ...bool) bool { if value, ok := context.userData[key]; ok { if value, ok := value.(bool); ok { return value } } if len(defaultValue) > 0 { return defaultValue[0] } return false }
[ "func", "(", "context", "*", "BaseContext", ")", "GetBool", "(", "key", "string", ",", "defaultValue", "...", "bool", ")", "bool", "{", "if", "value", ",", "ok", ":=", "context", ".", "userData", "[", "key", "]", ";", "ok", "{", "if", "value", ",", ...
// GetBool from hprose context
[ "GetBool", "from", "hprose", "context" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/context.go#L131-L142
train
hprose/hprose-golang
rpc/context.go
GetString
func (context *BaseContext) GetString( key string, defaultValue ...string) string { if value, ok := context.userData[key]; ok { if value, ok := value.(string); ok { return value } } if len(defaultValue) > 0 { return defaultValue[0] } return "" }
go
func (context *BaseContext) GetString( key string, defaultValue ...string) string { if value, ok := context.userData[key]; ok { if value, ok := value.(string); ok { return value } } if len(defaultValue) > 0 { return defaultValue[0] } return "" }
[ "func", "(", "context", "*", "BaseContext", ")", "GetString", "(", "key", "string", ",", "defaultValue", "...", "string", ")", "string", "{", "if", "value", ",", "ok", ":=", "context", ".", "userData", "[", "key", "]", ";", "ok", "{", "if", "value", ...
// GetString from hprose context
[ "GetString", "from", "hprose", "context" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/context.go#L145-L156
train
hprose/hprose-golang
rpc/context.go
GetInterface
func (context *BaseContext) GetInterface( key string, defaultValue ...interface{}) interface{} { if value, ok := context.userData[key]; ok { return value } if len(defaultValue) > 0 { return defaultValue[0] } return nil }
go
func (context *BaseContext) GetInterface( key string, defaultValue ...interface{}) interface{} { if value, ok := context.userData[key]; ok { return value } if len(defaultValue) > 0 { return defaultValue[0] } return nil }
[ "func", "(", "context", "*", "BaseContext", ")", "GetInterface", "(", "key", "string", ",", "defaultValue", "...", "interface", "{", "}", ")", "interface", "{", "}", "{", "if", "value", ",", "ok", ":=", "context", ".", "userData", "[", "key", "]", ";",...
// GetInterface from hprose context
[ "GetInterface", "from", "hprose", "context" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/context.go#L159-L168
train
hprose/hprose-golang
rpc/context.go
Get
func (context *BaseContext) Get(key string) interface{} { if value, ok := context.userData[key]; ok { return value } return nil }
go
func (context *BaseContext) Get(key string) interface{} { if value, ok := context.userData[key]; ok { return value } return nil }
[ "func", "(", "context", "*", "BaseContext", ")", "Get", "(", "key", "string", ")", "interface", "{", "}", "{", "if", "value", ",", "ok", ":=", "context", ".", "userData", "[", "key", "]", ";", "ok", "{", "return", "value", "\n", "}", "\n", "return"...
// Get value from hprose context
[ "Get", "value", "from", "hprose", "context" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/context.go#L171-L176
train
hprose/hprose-golang
rpc/context.go
SetInt
func (context *BaseContext) SetInt(key string, value int) { context.userData[key] = value }
go
func (context *BaseContext) SetInt(key string, value int) { context.userData[key] = value }
[ "func", "(", "context", "*", "BaseContext", ")", "SetInt", "(", "key", "string", ",", "value", "int", ")", "{", "context", ".", "userData", "[", "key", "]", "=", "value", "\n", "}" ]
// SetInt to hprose context
[ "SetInt", "to", "hprose", "context" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/context.go#L179-L181
train
hprose/hprose-golang
rpc/context.go
SetUInt
func (context *BaseContext) SetUInt(key string, value uint) { context.userData[key] = value }
go
func (context *BaseContext) SetUInt(key string, value uint) { context.userData[key] = value }
[ "func", "(", "context", "*", "BaseContext", ")", "SetUInt", "(", "key", "string", ",", "value", "uint", ")", "{", "context", ".", "userData", "[", "key", "]", "=", "value", "\n", "}" ]
// SetUInt to hprose context
[ "SetUInt", "to", "hprose", "context" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/context.go#L184-L186
train
hprose/hprose-golang
rpc/context.go
SetInt64
func (context *BaseContext) SetInt64(key string, value int64) { context.userData[key] = value }
go
func (context *BaseContext) SetInt64(key string, value int64) { context.userData[key] = value }
[ "func", "(", "context", "*", "BaseContext", ")", "SetInt64", "(", "key", "string", ",", "value", "int64", ")", "{", "context", ".", "userData", "[", "key", "]", "=", "value", "\n", "}" ]
// SetInt64 to hprose context
[ "SetInt64", "to", "hprose", "context" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/context.go#L189-L191
train
hprose/hprose-golang
rpc/context.go
SetUInt64
func (context *BaseContext) SetUInt64(key string, value uint64) { context.userData[key] = value }
go
func (context *BaseContext) SetUInt64(key string, value uint64) { context.userData[key] = value }
[ "func", "(", "context", "*", "BaseContext", ")", "SetUInt64", "(", "key", "string", ",", "value", "uint64", ")", "{", "context", ".", "userData", "[", "key", "]", "=", "value", "\n", "}" ]
// SetUInt64 to hprose context
[ "SetUInt64", "to", "hprose", "context" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/context.go#L194-L196
train
hprose/hprose-golang
rpc/context.go
SetFloat
func (context *BaseContext) SetFloat(key string, value float64) { context.userData[key] = value }
go
func (context *BaseContext) SetFloat(key string, value float64) { context.userData[key] = value }
[ "func", "(", "context", "*", "BaseContext", ")", "SetFloat", "(", "key", "string", ",", "value", "float64", ")", "{", "context", ".", "userData", "[", "key", "]", "=", "value", "\n", "}" ]
// SetFloat to hprose context
[ "SetFloat", "to", "hprose", "context" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/context.go#L199-L201
train
hprose/hprose-golang
rpc/context.go
SetBool
func (context *BaseContext) SetBool(key string, value bool) { context.userData[key] = value }
go
func (context *BaseContext) SetBool(key string, value bool) { context.userData[key] = value }
[ "func", "(", "context", "*", "BaseContext", ")", "SetBool", "(", "key", "string", ",", "value", "bool", ")", "{", "context", ".", "userData", "[", "key", "]", "=", "value", "\n", "}" ]
// SetBool to hprose context
[ "SetBool", "to", "hprose", "context" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/context.go#L204-L206
train
hprose/hprose-golang
rpc/context.go
SetString
func (context *BaseContext) SetString(key string, value string) { context.userData[key] = value }
go
func (context *BaseContext) SetString(key string, value string) { context.userData[key] = value }
[ "func", "(", "context", "*", "BaseContext", ")", "SetString", "(", "key", "string", ",", "value", "string", ")", "{", "context", ".", "userData", "[", "key", "]", "=", "value", "\n", "}" ]
// SetString to hprose context
[ "SetString", "to", "hprose", "context" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/context.go#L209-L211
train
hprose/hprose-golang
rpc/context.go
SetInterface
func (context *BaseContext) SetInterface(key string, value interface{}) { context.userData[key] = value }
go
func (context *BaseContext) SetInterface(key string, value interface{}) { context.userData[key] = value }
[ "func", "(", "context", "*", "BaseContext", ")", "SetInterface", "(", "key", "string", ",", "value", "interface", "{", "}", ")", "{", "context", ".", "userData", "[", "key", "]", "=", "value", "\n", "}" ]
// SetInterface to hprose context
[ "SetInterface", "to", "hprose", "context" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/context.go#L214-L216
train
hprose/hprose-golang
rpc/context.go
Set
func (context *BaseContext) Set(key string, value interface{}) { context.userData[key] = value }
go
func (context *BaseContext) Set(key string, value interface{}) { context.userData[key] = value }
[ "func", "(", "context", "*", "BaseContext", ")", "Set", "(", "key", "string", ",", "value", "interface", "{", "}", ")", "{", "context", ".", "userData", "[", "key", "]", "=", "value", "\n", "}" ]
// Set is an alias of SetInterface
[ "Set", "is", "an", "alias", "of", "SetInterface" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/context.go#L219-L221
train
hprose/hprose-golang
rpc/filter/jsonrpc/client_filter.go
NewClientFilter
func NewClientFilter(version string) *ClientFilter { if version == "1.0" || version == "1.1" || version == "2.0" { return &ClientFilter{Version: version} } panic("version must be 1.0, 1.1 or 2.0 in string format.") }
go
func NewClientFilter(version string) *ClientFilter { if version == "1.0" || version == "1.1" || version == "2.0" { return &ClientFilter{Version: version} } panic("version must be 1.0, 1.1 or 2.0 in string format.") }
[ "func", "NewClientFilter", "(", "version", "string", ")", "*", "ClientFilter", "{", "if", "version", "==", "\"", "\"", "||", "version", "==", "\"", "\"", "||", "version", "==", "\"", "\"", "{", "return", "&", "ClientFilter", "{", "Version", ":", "version...
// NewClientFilter is a constructor for JSONRPCClientFilter
[ "NewClientFilter", "is", "a", "constructor", "for", "JSONRPCClientFilter" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/filter/jsonrpc/client_filter.go#L37-L42
train
hprose/hprose-golang
rpc/filter/jsonrpc/client_filter.go
InputFilter
func (filter *ClientFilter) InputFilter(data []byte, context rpc.Context) []byte { if context.GetBool("jsonrpc") { var response map[string]interface{} if err := json.Unmarshal(data, &response); err != nil { return data } err := response["error"] writer := io.NewWriter(true) if err != nil { e := err.(...
go
func (filter *ClientFilter) InputFilter(data []byte, context rpc.Context) []byte { if context.GetBool("jsonrpc") { var response map[string]interface{} if err := json.Unmarshal(data, &response); err != nil { return data } err := response["error"] writer := io.NewWriter(true) if err != nil { e := err.(...
[ "func", "(", "filter", "*", "ClientFilter", ")", "InputFilter", "(", "data", "[", "]", "byte", ",", "context", "rpc", ".", "Context", ")", "[", "]", "byte", "{", "if", "context", ".", "GetBool", "(", "\"", "\"", ")", "{", "var", "response", "map", ...
// InputFilter for JSONRPC Client
[ "InputFilter", "for", "JSONRPC", "Client" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/filter/jsonrpc/client_filter.go#L45-L65
train
hprose/hprose-golang
rpc/filter/jsonrpc/client_filter.go
OutputFilter
func (filter *ClientFilter) OutputFilter(data []byte, context rpc.Context) []byte { if context.GetBool("jsonrpc") { request := make(map[string]interface{}) if filter.Version == "1.1" { request["version"] = "1.1" } else if filter.Version == "2.0" { request["jsonrpc"] = "2.0" } reader := io.NewReader(dat...
go
func (filter *ClientFilter) OutputFilter(data []byte, context rpc.Context) []byte { if context.GetBool("jsonrpc") { request := make(map[string]interface{}) if filter.Version == "1.1" { request["version"] = "1.1" } else if filter.Version == "2.0" { request["jsonrpc"] = "2.0" } reader := io.NewReader(dat...
[ "func", "(", "filter", "*", "ClientFilter", ")", "OutputFilter", "(", "data", "[", "]", "byte", ",", "context", "rpc", ".", "Context", ")", "[", "]", "byte", "{", "if", "context", ".", "GetBool", "(", "\"", "\"", ")", "{", "request", ":=", "make", ...
// OutputFilter for JSONRPC Client
[ "OutputFilter", "for", "JSONRPC", "Client" ]
6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74
https://github.com/hprose/hprose-golang/blob/6c2a3b7138ea2c7dc4a8907d644f9f134e0fae74/rpc/filter/jsonrpc/client_filter.go#L68-L96
train
theupdateframework/notary
tuf/utils/x509.go
X509PublicKeyID
func X509PublicKeyID(certPubKey data.PublicKey) (string, error) { // Note that this only loads the first certificate from the public key cert, err := LoadCertFromPEM(certPubKey.Public()) if err != nil { return "", err } pubKeyBytes, err := x509.MarshalPKIXPublicKey(cert.PublicKey) if err != nil { return "", e...
go
func X509PublicKeyID(certPubKey data.PublicKey) (string, error) { // Note that this only loads the first certificate from the public key cert, err := LoadCertFromPEM(certPubKey.Public()) if err != nil { return "", err } pubKeyBytes, err := x509.MarshalPKIXPublicKey(cert.PublicKey) if err != nil { return "", e...
[ "func", "X509PublicKeyID", "(", "certPubKey", "data", ".", "PublicKey", ")", "(", "string", ",", "error", ")", "{", "// Note that this only loads the first certificate from the public key", "cert", ",", "err", ":=", "LoadCertFromPEM", "(", "certPubKey", ".", "Public", ...
// X509PublicKeyID returns a public key ID as a string, given a // data.PublicKey that contains an X509 Certificate
[ "X509PublicKeyID", "returns", "a", "public", "key", "ID", "as", "a", "string", "given", "a", "data", ".", "PublicKey", "that", "contains", "an", "X509", "Certificate" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/utils/x509.go#L66-L86
train
theupdateframework/notary
tuf/utils/x509.go
CertToPEM
func CertToPEM(cert *x509.Certificate) []byte { pemCert := pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: cert.Raw}) return pemCert }
go
func CertToPEM(cert *x509.Certificate) []byte { pemCert := pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: cert.Raw}) return pemCert }
[ "func", "CertToPEM", "(", "cert", "*", "x509", ".", "Certificate", ")", "[", "]", "byte", "{", "pemCert", ":=", "pem", ".", "EncodeToMemory", "(", "&", "pem", ".", "Block", "{", "Type", ":", "\"", "\"", ",", "Bytes", ":", "cert", ".", "Raw", "}", ...
// CertToPEM is a utility function returns a PEM encoded x509 Certificate
[ "CertToPEM", "is", "a", "utility", "function", "returns", "a", "PEM", "encoded", "x509", "Certificate" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/utils/x509.go#L171-L175
train
theupdateframework/notary
tuf/utils/x509.go
CertChainToPEM
func CertChainToPEM(certChain []*x509.Certificate) ([]byte, error) { var pemBytes bytes.Buffer for _, cert := range certChain { if err := pem.Encode(&pemBytes, &pem.Block{Type: "CERTIFICATE", Bytes: cert.Raw}); err != nil { return nil, err } } return pemBytes.Bytes(), nil }
go
func CertChainToPEM(certChain []*x509.Certificate) ([]byte, error) { var pemBytes bytes.Buffer for _, cert := range certChain { if err := pem.Encode(&pemBytes, &pem.Block{Type: "CERTIFICATE", Bytes: cert.Raw}); err != nil { return nil, err } } return pemBytes.Bytes(), nil }
[ "func", "CertChainToPEM", "(", "certChain", "[", "]", "*", "x509", ".", "Certificate", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "pemBytes", "bytes", ".", "Buffer", "\n", "for", "_", ",", "cert", ":=", "range", "certChain", "{", "if"...
// CertChainToPEM is a utility function returns a PEM encoded chain of x509 Certificates, in the order they are passed
[ "CertChainToPEM", "is", "a", "utility", "function", "returns", "a", "PEM", "encoded", "chain", "of", "x509", "Certificates", "in", "the", "order", "they", "are", "passed" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/utils/x509.go#L178-L186
train
theupdateframework/notary
tuf/utils/x509.go
LoadCertFromFile
func LoadCertFromFile(filename string) (*x509.Certificate, error) { certs, err := LoadCertBundleFromFile(filename) if err != nil { return nil, err } return certs[0], nil }
go
func LoadCertFromFile(filename string) (*x509.Certificate, error) { certs, err := LoadCertBundleFromFile(filename) if err != nil { return nil, err } return certs[0], nil }
[ "func", "LoadCertFromFile", "(", "filename", "string", ")", "(", "*", "x509", ".", "Certificate", ",", "error", ")", "{", "certs", ",", "err", ":=", "LoadCertBundleFromFile", "(", "filename", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ","...
// LoadCertFromFile loads the first certificate from the file provided. The // data is expected to be PEM Encoded and contain one of more certificates // with PEM type "CERTIFICATE"
[ "LoadCertFromFile", "loads", "the", "first", "certificate", "from", "the", "file", "provided", ".", "The", "data", "is", "expected", "to", "be", "PEM", "Encoded", "and", "contain", "one", "of", "more", "certificates", "with", "PEM", "type", "CERTIFICATE" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/utils/x509.go#L191-L197
train
theupdateframework/notary
tuf/utils/x509.go
GetLeafCerts
func GetLeafCerts(certs []*x509.Certificate) []*x509.Certificate { var leafCerts []*x509.Certificate for _, cert := range certs { if cert.IsCA { continue } leafCerts = append(leafCerts, cert) } return leafCerts }
go
func GetLeafCerts(certs []*x509.Certificate) []*x509.Certificate { var leafCerts []*x509.Certificate for _, cert := range certs { if cert.IsCA { continue } leafCerts = append(leafCerts, cert) } return leafCerts }
[ "func", "GetLeafCerts", "(", "certs", "[", "]", "*", "x509", ".", "Certificate", ")", "[", "]", "*", "x509", ".", "Certificate", "{", "var", "leafCerts", "[", "]", "*", "x509", ".", "Certificate", "\n", "for", "_", ",", "cert", ":=", "range", "certs"...
// GetLeafCerts parses a list of x509 Certificates and returns all of them // that aren't CA
[ "GetLeafCerts", "parses", "a", "list", "of", "x509", "Certificates", "and", "returns", "all", "of", "them", "that", "aren", "t", "CA" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/utils/x509.go#L239-L248
train
theupdateframework/notary
tuf/utils/x509.go
GetIntermediateCerts
func GetIntermediateCerts(certs []*x509.Certificate) []*x509.Certificate { var intCerts []*x509.Certificate for _, cert := range certs { if cert.IsCA { intCerts = append(intCerts, cert) } } return intCerts }
go
func GetIntermediateCerts(certs []*x509.Certificate) []*x509.Certificate { var intCerts []*x509.Certificate for _, cert := range certs { if cert.IsCA { intCerts = append(intCerts, cert) } } return intCerts }
[ "func", "GetIntermediateCerts", "(", "certs", "[", "]", "*", "x509", ".", "Certificate", ")", "[", "]", "*", "x509", ".", "Certificate", "{", "var", "intCerts", "[", "]", "*", "x509", ".", "Certificate", "\n", "for", "_", ",", "cert", ":=", "range", ...
// GetIntermediateCerts parses a list of x509 Certificates and returns all of the // ones marked as a CA, to be used as intermediates
[ "GetIntermediateCerts", "parses", "a", "list", "of", "x509", "Certificates", "and", "returns", "all", "of", "the", "ones", "marked", "as", "a", "CA", "to", "be", "used", "as", "intermediates" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/utils/x509.go#L252-L260
train
theupdateframework/notary
tuf/utils/x509.go
ParsePEMPublicKey
func ParsePEMPublicKey(pubKeyBytes []byte) (data.PublicKey, error) { pemBlock, _ := pem.Decode(pubKeyBytes) if pemBlock == nil { return nil, errors.New("no valid public key found") } switch pemBlock.Type { case "CERTIFICATE": cert, err := x509.ParseCertificate(pemBlock.Bytes) if err != nil { return nil, ...
go
func ParsePEMPublicKey(pubKeyBytes []byte) (data.PublicKey, error) { pemBlock, _ := pem.Decode(pubKeyBytes) if pemBlock == nil { return nil, errors.New("no valid public key found") } switch pemBlock.Type { case "CERTIFICATE": cert, err := x509.ParseCertificate(pemBlock.Bytes) if err != nil { return nil, ...
[ "func", "ParsePEMPublicKey", "(", "pubKeyBytes", "[", "]", "byte", ")", "(", "data", ".", "PublicKey", ",", "error", ")", "{", "pemBlock", ",", "_", ":=", "pem", ".", "Decode", "(", "pubKeyBytes", ")", "\n", "if", "pemBlock", "==", "nil", "{", "return"...
// ParsePEMPublicKey returns a data.PublicKey from a PEM encoded public key or certificate.
[ "ParsePEMPublicKey", "returns", "a", "data", ".", "PublicKey", "from", "a", "PEM", "encoded", "public", "key", "or", "certificate", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/utils/x509.go#L263-L289
train
theupdateframework/notary
tuf/utils/x509.go
ValidateCertificate
func ValidateCertificate(c *x509.Certificate, checkExpiry bool) error { if (c.NotBefore).After(c.NotAfter) { return fmt.Errorf("certificate validity window is invalid") } // Can't have SHA1 sig algorithm if c.SignatureAlgorithm == x509.SHA1WithRSA || c.SignatureAlgorithm == x509.DSAWithSHA1 || c.SignatureAlgorith...
go
func ValidateCertificate(c *x509.Certificate, checkExpiry bool) error { if (c.NotBefore).After(c.NotAfter) { return fmt.Errorf("certificate validity window is invalid") } // Can't have SHA1 sig algorithm if c.SignatureAlgorithm == x509.SHA1WithRSA || c.SignatureAlgorithm == x509.DSAWithSHA1 || c.SignatureAlgorith...
[ "func", "ValidateCertificate", "(", "c", "*", "x509", ".", "Certificate", ",", "checkExpiry", "bool", ")", "error", "{", "if", "(", "c", ".", "NotBefore", ")", ".", "After", "(", "c", ".", "NotAfter", ")", "{", "return", "fmt", ".", "Errorf", "(", "\...
// ValidateCertificate returns an error if the certificate is not valid for notary // Currently this is only ensuring the public key has a large enough modulus if RSA, // using a non SHA1 signature algorithm, and an optional time expiry check
[ "ValidateCertificate", "returns", "an", "error", "if", "the", "certificate", "is", "not", "valid", "for", "notary", "Currently", "this", "is", "only", "ensuring", "the", "public", "key", "has", "a", "large", "enough", "modulus", "if", "RSA", "using", "a", "n...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/utils/x509.go#L308-L339
train
theupdateframework/notary
tuf/utils/x509.go
GenerateKey
func GenerateKey(algorithm string) (data.PrivateKey, error) { switch algorithm { case data.ECDSAKey: return GenerateECDSAKey(rand.Reader) case data.ED25519Key: return GenerateED25519Key(rand.Reader) } return nil, fmt.Errorf("private key type not supported for key generation: %s", algorithm) }
go
func GenerateKey(algorithm string) (data.PrivateKey, error) { switch algorithm { case data.ECDSAKey: return GenerateECDSAKey(rand.Reader) case data.ED25519Key: return GenerateED25519Key(rand.Reader) } return nil, fmt.Errorf("private key type not supported for key generation: %s", algorithm) }
[ "func", "GenerateKey", "(", "algorithm", "string", ")", "(", "data", ".", "PrivateKey", ",", "error", ")", "{", "switch", "algorithm", "{", "case", "data", ".", "ECDSAKey", ":", "return", "GenerateECDSAKey", "(", "rand", ".", "Reader", ")", "\n", "case", ...
// GenerateKey returns a new private key using the provided algorithm or an // error detailing why the key could not be generated
[ "GenerateKey", "returns", "a", "new", "private", "key", "using", "the", "provided", "algorithm", "or", "an", "error", "detailing", "why", "the", "key", "could", "not", "be", "generated" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/utils/x509.go#L343-L351
train
theupdateframework/notary
tuf/utils/x509.go
RSAToPrivateKey
func RSAToPrivateKey(rsaPrivKey *rsa.PrivateKey) (data.PrivateKey, error) { // Get a DER-encoded representation of the PublicKey rsaPubBytes, err := x509.MarshalPKIXPublicKey(&rsaPrivKey.PublicKey) if err != nil { return nil, fmt.Errorf("failed to marshal public key: %v", err) } // Get a DER-encoded representat...
go
func RSAToPrivateKey(rsaPrivKey *rsa.PrivateKey) (data.PrivateKey, error) { // Get a DER-encoded representation of the PublicKey rsaPubBytes, err := x509.MarshalPKIXPublicKey(&rsaPrivKey.PublicKey) if err != nil { return nil, fmt.Errorf("failed to marshal public key: %v", err) } // Get a DER-encoded representat...
[ "func", "RSAToPrivateKey", "(", "rsaPrivKey", "*", "rsa", ".", "PrivateKey", ")", "(", "data", ".", "PrivateKey", ",", "error", ")", "{", "// Get a DER-encoded representation of the PublicKey", "rsaPubBytes", ",", "err", ":=", "x509", ".", "MarshalPKIXPublicKey", "(...
// RSAToPrivateKey converts an rsa.Private key to a TUF data.PrivateKey type
[ "RSAToPrivateKey", "converts", "an", "rsa", ".", "Private", "key", "to", "a", "TUF", "data", ".", "PrivateKey", "type" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/utils/x509.go#L354-L366
train
theupdateframework/notary
tuf/utils/x509.go
GenerateECDSAKey
func GenerateECDSAKey(random io.Reader) (data.PrivateKey, error) { ecdsaPrivKey, err := ecdsa.GenerateKey(elliptic.P256(), random) if err != nil { return nil, err } tufPrivKey, err := ECDSAToPrivateKey(ecdsaPrivKey) if err != nil { return nil, err } logrus.Debugf("generated ECDSA key with keyID: %s", tufPr...
go
func GenerateECDSAKey(random io.Reader) (data.PrivateKey, error) { ecdsaPrivKey, err := ecdsa.GenerateKey(elliptic.P256(), random) if err != nil { return nil, err } tufPrivKey, err := ECDSAToPrivateKey(ecdsaPrivKey) if err != nil { return nil, err } logrus.Debugf("generated ECDSA key with keyID: %s", tufPr...
[ "func", "GenerateECDSAKey", "(", "random", "io", ".", "Reader", ")", "(", "data", ".", "PrivateKey", ",", "error", ")", "{", "ecdsaPrivKey", ",", "err", ":=", "ecdsa", ".", "GenerateKey", "(", "elliptic", ".", "P256", "(", ")", ",", "random", ")", "\n"...
// GenerateECDSAKey generates an ECDSA Private key and returns a TUF PrivateKey
[ "GenerateECDSAKey", "generates", "an", "ECDSA", "Private", "key", "and", "returns", "a", "TUF", "PrivateKey" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/utils/x509.go#L369-L383
train
theupdateframework/notary
tuf/utils/x509.go
GenerateED25519Key
func GenerateED25519Key(random io.Reader) (data.PrivateKey, error) { pub, priv, err := ed25519.GenerateKey(random) if err != nil { return nil, err } var serialized [ed25519.PublicKeySize + ed25519.PrivateKeySize]byte copy(serialized[:], pub[:]) copy(serialized[ed25519.PublicKeySize:], priv[:]) tufPrivKey, er...
go
func GenerateED25519Key(random io.Reader) (data.PrivateKey, error) { pub, priv, err := ed25519.GenerateKey(random) if err != nil { return nil, err } var serialized [ed25519.PublicKeySize + ed25519.PrivateKeySize]byte copy(serialized[:], pub[:]) copy(serialized[ed25519.PublicKeySize:], priv[:]) tufPrivKey, er...
[ "func", "GenerateED25519Key", "(", "random", "io", ".", "Reader", ")", "(", "data", ".", "PrivateKey", ",", "error", ")", "{", "pub", ",", "priv", ",", "err", ":=", "ed25519", ".", "GenerateKey", "(", "random", ")", "\n", "if", "err", "!=", "nil", "{...
// GenerateED25519Key generates an ED25519 private key and returns a TUF // PrivateKey. The serialization format we use is just the public key bytes // followed by the private key bytes
[ "GenerateED25519Key", "generates", "an", "ED25519", "private", "key", "and", "returns", "a", "TUF", "PrivateKey", ".", "The", "serialization", "format", "we", "use", "is", "just", "the", "public", "key", "bytes", "followed", "by", "the", "private", "key", "byt...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/utils/x509.go#L388-L406
train
theupdateframework/notary
tuf/utils/x509.go
ECDSAToPrivateKey
func ECDSAToPrivateKey(ecdsaPrivKey *ecdsa.PrivateKey) (data.PrivateKey, error) { // Get a DER-encoded representation of the PublicKey ecdsaPubBytes, err := x509.MarshalPKIXPublicKey(&ecdsaPrivKey.PublicKey) if err != nil { return nil, fmt.Errorf("failed to marshal public key: %v", err) } // Get a DER-encoded r...
go
func ECDSAToPrivateKey(ecdsaPrivKey *ecdsa.PrivateKey) (data.PrivateKey, error) { // Get a DER-encoded representation of the PublicKey ecdsaPubBytes, err := x509.MarshalPKIXPublicKey(&ecdsaPrivKey.PublicKey) if err != nil { return nil, fmt.Errorf("failed to marshal public key: %v", err) } // Get a DER-encoded r...
[ "func", "ECDSAToPrivateKey", "(", "ecdsaPrivKey", "*", "ecdsa", ".", "PrivateKey", ")", "(", "data", ".", "PrivateKey", ",", "error", ")", "{", "// Get a DER-encoded representation of the PublicKey", "ecdsaPubBytes", ",", "err", ":=", "x509", ".", "MarshalPKIXPublicKe...
// ECDSAToPrivateKey converts an ecdsa.Private key to a TUF data.PrivateKey type
[ "ECDSAToPrivateKey", "converts", "an", "ecdsa", ".", "Private", "key", "to", "a", "TUF", "data", ".", "PrivateKey", "type" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/utils/x509.go#L409-L424
train
theupdateframework/notary
tuf/utils/x509.go
ED25519ToPrivateKey
func ED25519ToPrivateKey(privKeyBytes []byte) (data.PrivateKey, error) { if len(privKeyBytes) != ed25519.PublicKeySize+ed25519.PrivateKeySize { return nil, errors.New("malformed ed25519 private key") } pubKey := data.NewED25519PublicKey(privKeyBytes[:ed25519.PublicKeySize]) return data.NewED25519PrivateKey(*pubK...
go
func ED25519ToPrivateKey(privKeyBytes []byte) (data.PrivateKey, error) { if len(privKeyBytes) != ed25519.PublicKeySize+ed25519.PrivateKeySize { return nil, errors.New("malformed ed25519 private key") } pubKey := data.NewED25519PublicKey(privKeyBytes[:ed25519.PublicKeySize]) return data.NewED25519PrivateKey(*pubK...
[ "func", "ED25519ToPrivateKey", "(", "privKeyBytes", "[", "]", "byte", ")", "(", "data", ".", "PrivateKey", ",", "error", ")", "{", "if", "len", "(", "privKeyBytes", ")", "!=", "ed25519", ".", "PublicKeySize", "+", "ed25519", ".", "PrivateKeySize", "{", "re...
// ED25519ToPrivateKey converts a serialized ED25519 key to a TUF // data.PrivateKey type
[ "ED25519ToPrivateKey", "converts", "a", "serialized", "ED25519", "key", "to", "a", "TUF", "data", ".", "PrivateKey", "type" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/utils/x509.go#L428-L435
train
theupdateframework/notary
tuf/utils/x509.go
ExtractPrivateKeyAttributes
func ExtractPrivateKeyAttributes(pemBytes []byte) (data.RoleName, data.GUN, error) { return extractPrivateKeyAttributes(pemBytes, notary.FIPSEnabled()) }
go
func ExtractPrivateKeyAttributes(pemBytes []byte) (data.RoleName, data.GUN, error) { return extractPrivateKeyAttributes(pemBytes, notary.FIPSEnabled()) }
[ "func", "ExtractPrivateKeyAttributes", "(", "pemBytes", "[", "]", "byte", ")", "(", "data", ".", "RoleName", ",", "data", ".", "GUN", ",", "error", ")", "{", "return", "extractPrivateKeyAttributes", "(", "pemBytes", ",", "notary", ".", "FIPSEnabled", "(", ")...
// ExtractPrivateKeyAttributes extracts role and gun values from private key bytes
[ "ExtractPrivateKeyAttributes", "extracts", "role", "and", "gun", "values", "from", "private", "key", "bytes" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/utils/x509.go#L438-L440
train
theupdateframework/notary
tuf/utils/x509.go
CertToKey
func CertToKey(cert *x509.Certificate) data.PublicKey { block := pem.Block{Type: "CERTIFICATE", Bytes: cert.Raw} pemdata := pem.EncodeToMemory(&block) switch cert.PublicKeyAlgorithm { case x509.RSA: return data.NewRSAx509PublicKey(pemdata) case x509.ECDSA: return data.NewECDSAx509PublicKey(pemdata) default: ...
go
func CertToKey(cert *x509.Certificate) data.PublicKey { block := pem.Block{Type: "CERTIFICATE", Bytes: cert.Raw} pemdata := pem.EncodeToMemory(&block) switch cert.PublicKeyAlgorithm { case x509.RSA: return data.NewRSAx509PublicKey(pemdata) case x509.ECDSA: return data.NewECDSAx509PublicKey(pemdata) default: ...
[ "func", "CertToKey", "(", "cert", "*", "x509", ".", "Certificate", ")", "data", ".", "PublicKey", "{", "block", ":=", "pem", ".", "Block", "{", "Type", ":", "\"", "\"", ",", "Bytes", ":", "cert", ".", "Raw", "}", "\n", "pemdata", ":=", "pem", ".", ...
// CertToKey transforms a single input certificate into its corresponding // PublicKey
[ "CertToKey", "transforms", "a", "single", "input", "certificate", "into", "its", "corresponding", "PublicKey" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/utils/x509.go#L493-L506
train
theupdateframework/notary
tuf/utils/x509.go
CertsToKeys
func CertsToKeys(leafCerts map[string]*x509.Certificate, intCerts map[string][]*x509.Certificate) map[string]data.PublicKey { keys := make(map[string]data.PublicKey) for id, leafCert := range leafCerts { if key, err := CertBundleToKey(leafCert, intCerts[id]); err == nil { keys[key.ID()] = key } } return keys...
go
func CertsToKeys(leafCerts map[string]*x509.Certificate, intCerts map[string][]*x509.Certificate) map[string]data.PublicKey { keys := make(map[string]data.PublicKey) for id, leafCert := range leafCerts { if key, err := CertBundleToKey(leafCert, intCerts[id]); err == nil { keys[key.ID()] = key } } return keys...
[ "func", "CertsToKeys", "(", "leafCerts", "map", "[", "string", "]", "*", "x509", ".", "Certificate", ",", "intCerts", "map", "[", "string", "]", "[", "]", "*", "x509", ".", "Certificate", ")", "map", "[", "string", "]", "data", ".", "PublicKey", "{", ...
// CertsToKeys transforms each of the input certificate chains into its corresponding // PublicKey
[ "CertsToKeys", "transforms", "each", "of", "the", "input", "certificate", "chains", "into", "its", "corresponding", "PublicKey" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/utils/x509.go#L510-L518
train
theupdateframework/notary
tuf/utils/x509.go
CertBundleToKey
func CertBundleToKey(leafCert *x509.Certificate, intCerts []*x509.Certificate) (data.PublicKey, error) { certBundle := []*x509.Certificate{leafCert} certBundle = append(certBundle, intCerts...) certChainPEM, err := CertChainToPEM(certBundle) if err != nil { return nil, err } var newKey data.PublicKey // Use th...
go
func CertBundleToKey(leafCert *x509.Certificate, intCerts []*x509.Certificate) (data.PublicKey, error) { certBundle := []*x509.Certificate{leafCert} certBundle = append(certBundle, intCerts...) certChainPEM, err := CertChainToPEM(certBundle) if err != nil { return nil, err } var newKey data.PublicKey // Use th...
[ "func", "CertBundleToKey", "(", "leafCert", "*", "x509", ".", "Certificate", ",", "intCerts", "[", "]", "*", "x509", ".", "Certificate", ")", "(", "data", ".", "PublicKey", ",", "error", ")", "{", "certBundle", ":=", "[", "]", "*", "x509", ".", "Certif...
// CertBundleToKey creates a TUF key from a leaf certs and a list of // intermediates
[ "CertBundleToKey", "creates", "a", "TUF", "key", "from", "a", "leaf", "certs", "and", "a", "list", "of", "intermediates" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/utils/x509.go#L522-L541
train
theupdateframework/notary
tuf/utils/x509.go
NewCertificate
func NewCertificate(commonName string, startTime, endTime time.Time) (*x509.Certificate, error) { serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128) serialNumber, err := rand.Int(rand.Reader, serialNumberLimit) if err != nil { return nil, fmt.Errorf("failed to generate new certificate: %v", err) } retur...
go
func NewCertificate(commonName string, startTime, endTime time.Time) (*x509.Certificate, error) { serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128) serialNumber, err := rand.Int(rand.Reader, serialNumberLimit) if err != nil { return nil, fmt.Errorf("failed to generate new certificate: %v", err) } retur...
[ "func", "NewCertificate", "(", "commonName", "string", ",", "startTime", ",", "endTime", "time", ".", "Time", ")", "(", "*", "x509", ".", "Certificate", ",", "error", ")", "{", "serialNumberLimit", ":=", "new", "(", "big", ".", "Int", ")", ".", "Lsh", ...
// NewCertificate returns an X509 Certificate following a template, given a Common Name and validity interval.
[ "NewCertificate", "returns", "an", "X509", "Certificate", "following", "a", "template", "given", "a", "Common", "Name", "and", "validity", "interval", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/utils/x509.go#L544-L564
train